Skip to content
Snippets Groups Projects
Commit b544edd5 authored by Ammar Nejati's avatar Ammar Nejati
Browse files

CMake: Avoid executing tests during the build phase

GoogleTest: `gtest_discover_tests` discovers tests by asking the _compiled test
executable_ to enumerate its tests. `PRE_TEST` delays test discovery until just
prior to test execution; this avoids calling the executables during the build
phase and hence, error messages like "Error running test executable".

Related to issue #133
parent 1d9ea98e
No related branches found
No related tags found
1 merge request!390CMake: Avoid executing tests during the build phase
Pipeline #46741 passed
...@@ -37,6 +37,11 @@ if(NOT CMAKE_BUILD_TYPE) ...@@ -37,6 +37,11 @@ if(NOT CMAKE_BUILD_TYPE)
endif() endif()
message(" CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") message(" CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
# GoogleTest: `gtest_discover_tests` discovers tests by asking the _compiled test executable_
# to enumerate its tests. `PRE_TEST` delays test discovery until just prior to test execution;
# this avoids calling the executables during the build phase.
set(CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE PRE_TEST)
include(CTest) # equivalent to "enable_testing() ??? include(CTest) # equivalent to "enable_testing() ???
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -LE Fullcheck) add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -LE Fullcheck)
# => 'make check' is an alias for 'ctest' # => 'make check' is an alias for 'ctest'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment