From f426a71abf31a26d0f68523e221c9ed48bac9570 Mon Sep 17 00:00:00 2001 From: fresh3nough Date: Sat, 28 Feb 2026 16:19:07 +0000 Subject: [PATCH] Fix CMake 3.22 crash in find_package(Python3) when Python is absent --- googletest/cmake/internal_utils.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index ca76f42d7..56dbf00d5 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -255,7 +255,12 @@ function(cxx_executable name dir libs) endfunction() if(gtest_build_tests) - find_package(Python3) + # Only the interpreter is needed for Python tests. Specifying the component + # explicitly avoids a crash in CMake <= 3.23's FindPython3 module when no + # Python installation is present (the module calls list(GET) on an empty + # list). QUIET lets the build continue without Python tests instead of + # failing outright. + find_package(Python3 COMPONENTS Interpreter QUIET) endif() # cxx_test_with_flags(name cxx_flags libs srcs...)