From 28ef3aba5245260bdd059568e01a9e6bbaf7fbc1 Mon Sep 17 00:00:00 2001 From: Benson Muite Date: Mon, 1 Sep 2025 19:04:34 +0300 Subject: [PATCH] Check if GTest is available before downloading --- tests/CMakeLists.txt | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c74e679..951e0eb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -56,14 +56,22 @@ target_sources(test_run PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/test.cpp ) -target_link_libraries(test_run - GTest::gtest_main - gmock_main - ${Google_Tests_LIBS} - OndselSolver -) +if(GTest_FOUND) + target_link_libraries(test_run + GTest::gtest_main + GTest::gmock_main + OndselSolver + ) +else() + target_link_libraries(test_run + gtest_main + gmock_main + ${Google_Tests_LIBS} + OndselSolver + ) -include(GoogleTest) + include(GoogleTest) +endif() # discovers tests by asking the compiled test executable to enumerate its tests set(CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE PRE_TEST)