diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2014-10-21 13:27:47 -0400 |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2014-10-23 16:42:34 -0400 |
commit | fa3ff758624e9c9704a4a541c195e10335debc3c (patch) | |
tree | c72ffebff0ef2daabf7dccfde9e8eaf1f6491e19 /tests/CMakeLists.txt | |
parent | cmake: put each test executable in its own directory (diff) | |
download | monero-fa3ff758624e9c9704a4a541c195e10335debc3c.tar.xz |
gtest: support an external gtest
Diffstat (limited to 'tests/CMakeLists.txt')
-rw-r--r-- | tests/CMakeLists.txt | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 63a213a34..3da9fdb6b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -32,8 +32,25 @@ add_definitions(-DSTATICLIB) # miniupnp changed their static define add_definitions(-DMINIUPNP_STATICLIB) -add_subdirectory(gtest) -include_directories(${gtest_SOURCE_DIR}/include ${gtest_SOURCE_DIR}) +find_package(GTest) + +if (GTest_FOUND) + include_directories(SYSTEM ${GTEST_INCLUDE_DIRS}) +else () + add_subdirectory(gtest) + include_directories(SYSTEM "${gtest_SOURCE_DIR}/include" "${gtest_SOURCE_DIR}") + + # Emulate the FindGTest module's variable. + set(GTEST_MAIN_LIBRARIES gtest_main) + + # Ignore some warnings when building gtest binaries. + if(NOT MSVC) + set_property(TARGET gtest gtest_main + APPEND_STRING + PROPERTY + COMPILE_FLAGS " -Wno-undef -Wno-sign-compare") + endif() +endif () add_subdirectory(core_tests) add_subdirectory(crypto) @@ -66,9 +83,5 @@ add_test( NAME hash-target COMMAND hash-target-tests) -if(NOT MSVC) - set_property(TARGET gtest gtest_main APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-sign-compare") -endif() - add_custom_target(tests DEPENDS coretests difficulty hash performance_tests core_proxy unit_tests) set_property(TARGET gtest gtest_main hash-target-tests tests PROPERTY FOLDER "tests") |