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 e570192 commit 076ba65
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

* Build
* Enabled building dartpy with multi-core support in setup.py
* Added DART_USE_SYSTEM_GOOGLETEST option

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

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)
endif()

#===============================================================================
# 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 076ba65

Please sign in to comment.