mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-21 14:40:26 -06:00
The internal helper variable '_GOOGLETEST_DISCOVER_TESTS_SCRIPT' can have gone
out-of-scope when 'gtest_discover_tests()' is called, depending on where the
GoogleTest module is actually included. This leads to a silent failure of
dynamic test discovery, since the custom post-build commands actually does
nothing (it basically invokes 'cmake -P ""'). Ctest will then fail to run the
tests, considering them to be 'not built'.
Fix this by determining the path to the GoogleTest module based on
'${CMAKE_ROOT}' instead, which is always available.
A new test case was added to test suite 'RunCMake/GoogleTest' to ensure that
'gtest_discover_tests()' works correctly when invoked in a different variable
scope.
Fixes: #25477
14 lines
412 B
CMake
14 lines
412 B
CMake
enable_language(CXX)
|
|
|
|
# 'GoogleTest' module is NOT included here by design to validate that including
|
|
# it in a subdirectory will still result in test discovery working correctly if
|
|
# 'gtest_discover_tests()' is invoked from a different scope.
|
|
|
|
enable_testing()
|
|
|
|
include(xcode_sign_adhoc.cmake)
|
|
|
|
add_subdirectory(GoogleTestDiscoveryTestListScoped)
|
|
|
|
add_gtest_executable(test_list_scoped_test test_list_test.cpp)
|