Skip to content

Commit

Permalink
make tests optional
Browse files Browse the repository at this point in the history
  • Loading branch information
riasc committed Sep 26, 2024
1 parent 1a9f00a commit 858dfcc
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,32 @@ install(EXPORT genogrove-targets
)

##### Tests #####
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.15.0
)
FetchContent_MakeAvailable(googletest)
enable_testing() # enable the testing framework
include(GoogleTest)
option(TESTS "building unit tests" OFF)
if(TESTS)
message(STATUS "Building unit tests")
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.15.0
)
FetchContent_MakeAvailable(googletest)
enable_testing() # enable the testing framework
include(GoogleTest)

file(GLOB SOURCES "src/*.cpp")
file(GLOB TEST_SOURCES "tests/*.cpp")
add_executable(IBPTree_Test ${SOURCES} ${TEST_SOURCES})
target_include_directories(IBPTree_Test PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(IBPTree_Test GTest::gtest_main)

gtest_discover_tests(IBPTree_Test)
else()
message(STATUS "Building unit tests disabled")
endif()




file(GLOB SOURCES "src/*.cpp")
file(GLOB TEST_SOURCES "tests/*.cpp")
add_executable(IBPTree_Test ${SOURCES} ${TEST_SOURCES})
target_include_directories(IBPTree_Test PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(IBPTree_Test GTest::gtest_main)

gtest_discover_tests(IBPTree_Test)

0 comments on commit 858dfcc

Please sign in to comment.