From a6c71d85515301b395460e6ee7e22b2782f6e36c Mon Sep 17 00:00:00 2001 From: Sam Yates <halfflat@gmail.com> Date: Thu, 7 Jul 2016 10:41:19 +0200 Subject: [PATCH] Use one gtest lib for test subdirectories --- tests/CMakeLists.txt | 8 +++++--- tests/unit/CMakeLists.txt | 3 --- tests/validation/CMakeLists.txt | 5 +---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f9668fd5..c29c9606 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -16,11 +16,13 @@ #add_subdirectory(regression) # google test framework -# This fails with lots of undefined reference to `testing::UnitTest::Run()' -#add_library(GTEST gtest-all.cpp gtest.h) +add_library(gtest gtest-all.cpp) + +# tests look for gtest.h here +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) # Unit tests add_subdirectory(unit) # Test validating models, possebly needing other software installed -add_subdirectory(validation) \ No newline at end of file +add_subdirectory(validation) diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index f46816bb..24c08242 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -8,9 +8,6 @@ set(HEADERS ${PROJECT_SOURCE_DIR}/src/tree.hpp ) -# google test framework -add_library(gtest gtest-all.cpp gtest.h) - set(TEST_SOURCES # unit tests test_algorithms.cpp diff --git a/tests/validation/CMakeLists.txt b/tests/validation/CMakeLists.txt index e413bbe2..31477528 100644 --- a/tests/validation/CMakeLists.txt +++ b/tests/validation/CMakeLists.txt @@ -23,9 +23,6 @@ set(VALIDATION_SOURCES validate.cpp ) -# google test framework -add_library(gtest_validate gtest-all.cpp gtest.h) - add_definitions("-DDATADIR=\"${CMAKE_SOURCE_DIR}/data\"") add_executable(validate.exe ${VALIDATION_SOURCES} ${HEADERS}) @@ -33,7 +30,7 @@ add_executable(validate.exe ${VALIDATION_SOURCES} ${HEADERS}) set(TARGETS validate.exe) foreach(target ${TARGETS}) - target_link_libraries(${target} LINK_PUBLIC cellalgo gtest_validate) + target_link_libraries(${target} LINK_PUBLIC cellalgo gtest) if(WITH_TBB) target_link_libraries(${target} LINK_PUBLIC ${TBB_LIBRARIES}) -- GitLab