Skip to content

Commit

Permalink
[build] Add DART_USE_SYSTEM_GOOGLETEST option
Browse files Browse the repository at this point in the history
  • Loading branch information
jslee02 committed Jul 8, 2024
1 parent 6585763 commit f8fddac
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
* macOS 14 / Clang 15 / arm64
* Windows / MSVC 19.40 / x86_64

* Build
* Added DART_USE_SYSTEM_GOOGLETEST option

### [DART 6.14.4 (TBD)](https://github.com/dartsim/dart/milestone/81?closed=1)

* Tested Platforms
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ dart_option(DART_FAST_DEBUG "Add -O1 option for DEBUG mode build" OFF)
dart_option(DART_FORCE_COLORED_OUTPUT
"Always produce ANSI-colored output (GNU/Clang only)." OFF)
dart_option(DART_USE_SYSTEM_IMGUI "Use system ImGui" OFF)
dart_option(DART_USE_SYSTEM_GOOGLETEST "Use system GoogleTest" OFF)

#===============================================================================
# Print intro
Expand Down
28 changes: 16 additions & 12 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,21 @@
#

# Set up GoogleTest
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG v1.14.0
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(gtest_disable_pthreads ON CACHE BOOL "" FORCE)
set(BUILD_GMOCK ON CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
if(DART_USE_SYSTEM_GOOGLETEST)
find_package(GTest MODULE REQUIRED)
else()
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest
GIT_TAG v1.14.0
)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
set(gtest_disable_pthreads ON CACHE BOOL "" FORCE)
set(BUILD_GMOCK ON CACHE BOOL "" FORCE)
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
end()

#===============================================================================
# This function uses following global properties:
Expand All @@ -65,7 +69,7 @@ function(dart_add_test test_type target_name) # ARGN for source files

add_executable(${target_name} ${sources})
add_test(${target_name} ${target_name})
target_link_libraries(${target_name} dart gtest gtest_main)
target_link_libraries(${target_name} dart GTest::gtest GTest::gtest_main)

dart_format_add(${sources})

Expand Down

0 comments on commit f8fddac

Please sign in to comment.