Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
find_package(GTest)
if(NOT GTest_FOUND)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
endif()

if(MSVC)
add_compile_options(/wd4251)
Expand Down Expand Up @@ -53,14 +56,22 @@ target_sources(test_run
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/test.cpp
)
target_link_libraries(test_run
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)

Expand Down