Register googlemock Python tests with CTest

py_test() relies on Python3_Interpreter_FOUND and the imported
Python3::Interpreter target, both of which are directory-scoped and set
in googletest's scope. googlemock adds googletest as a subdirectory, so
neither is visible where py_test() is called from, and gmock_leak_test
and gmock_output_test were never registered.

Repeat the interpreter search in googlemock's own scope.

Fixes #5070
This commit is contained in:
YedilB 2026-08-20 16:41:48 +07:00
parent 0daf775f8c
commit dfcf2d4d57
1 changed files with 5 additions and 0 deletions

View File

@ -202,6 +202,11 @@ if (gmock_build_tests)
############################################################ ############################################################
# Python tests. # Python tests.
# Python is found in googletest's directory scope, which does not propagate
# to this parent scope, and the imported Python3::Interpreter target used by
# py_test() is directory-scoped as well, so the search is repeated here.
find_package(Python3 COMPONENTS Interpreter QUIET)
cxx_executable(gmock_leak_test_ test gmock_main) cxx_executable(gmock_leak_test_ test gmock_main)
py_test(gmock_leak_test) py_test(gmock_leak_test)