Unverified Commit 93814bde authored by Kip's avatar Kip Committed by GitHub

Merge pull request #907 from Tachi107/cmake-gtest-target

Use GTest imported target in tests/CMakeLists.txt
parents c065b648 06a1f4d0
......@@ -102,8 +102,6 @@ if (PISTACHE_BUILD_TESTS)
add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
endif()
endif()
enable_testing()
add_subdirectory(tests)
endif()
......
......@@ -5,8 +5,13 @@ function(pistache_test test_name)
set(TEST_SOURCE ${test_name}.cc)
add_executable(${TEST_EXECUTABLE} ${TEST_SOURCE})
target_include_directories(${TEST_EXECUTABLE} PRIVATE ${GTEST_INCLUDE_DIRS} ${CURL_INCLUDE_DIRS})
target_link_libraries(${TEST_EXECUTABLE} gtest gtest_main pistache_static ${CURL_LIBRARIES})
target_include_directories(${TEST_EXECUTABLE} PRIVATE ${CURL_INCLUDE_DIRS})
# CMake 3.20 and upstream GTest define GTest::gtest, older versions define GTest::GTest
if (TARGET GTest::gtest)
target_link_libraries(${TEST_EXECUTABLE} GTest::gtest GTest::gtest_main pistache_static ${CURL_LIBRARIES})
else ()
target_link_libraries(${TEST_EXECUTABLE} GTest::GTest GTest::Main pistache_static ${CURL_LIBRARIES})
endif ()
add_test(${test_name} ${TEST_EXECUTABLE})
endfunction()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment