diff --git a/services/backup/CMakeLists.txt b/services/backup/CMakeLists.txt --- a/services/backup/CMakeLists.txt +++ b/services/backup/CMakeLists.txt @@ -12,9 +12,6 @@ # For C++17 on MacOS, we must set minimum target to 10.14+ set(CMAKE_OSX_DEPLOYMENT_TARGET 10.14) -set(BUILD_TESTING OFF CACHE BOOL "Turn off tests" FORCE) -set(WITH_GTEST "Use Google Test" OFF) - find_package(glog REQUIRED) find_package(Protobuf REQUIRED) find_package(gRPC REQUIRED) @@ -55,17 +52,12 @@ add_executable( backup - ${GENERATED_CODE} - ${FOLLY_SOURCES} - ${SOURCE_CODE} ) add_library_rust(PATH blob_client NAMESPACE backup) -target_include_directories( - backup - PUBLIC +set(INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/src/DatabaseEntities ${CMAKE_CURRENT_SOURCE_DIR}/src/Reactors @@ -75,6 +67,12 @@ ${Boost_INCLUDE_DIR} ) +target_include_directories( + backup + PUBLIC + ${INCLUDE_DIRS} +) + set( LIBS @@ -104,7 +102,9 @@ ) # TEST -if ($ENV{COMM_TEST_SERVICES} MATCHES 1) +option(BUILD_TESTING "Turn off tests" ON) + +if (BUILD_TESTING) file(GLOB TEST_CODE "./test/*.cpp") list(FILTER SOURCE_CODE EXCLUDE REGEX "./src/server.cpp") enable_testing() @@ -118,21 +118,23 @@ add_executable( runTests - ${GENERATED_CODE} - ${FOLLY_SOURCES} ${SOURCE_CODE} ${TEST_CODE} ) + + target_include_directories( + runTests + PUBLIC + ${INCLUDE_DIRS} + ) + target_link_libraries( runTests ${LIBS} - gtest - gtest_main + GTest::gtest_main ) - add_test( - NAME runTests - COMMAND runTests - ) + include(GoogleTest) + gtest_discover_tests(runTests) endif()