Skip to content

[Bug]: CMake 3.22 cannot find python version #4847

@arderbud

Description

@arderbud

Describe the issue

I want use gooletest 1.13.0 with CMake 3.22 and Python3

So i change googletest/cmake/internal_utils.cmake:263 to find_package(Python3 COMPONENTS Interpreter),Beacuse my os is macOS 15.6.1,it seems to no python.

the error is:

CMake Error at /Users/bytedance/Library/Android/sdk/cmake/3.22.1/share/cmake-3.22/Modules/FindPython/Support.cmake:1841 (list):
    list GET given empty list

check the Support.cmake, it should get python3 version, but not

execute_process (COMMAND ${_${_PYTHON_PREFIX}_INTERPRETER_LAUNCHER} "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c
                             "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:3]]))"
                     RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT
                     OUTPUT_VARIABLE ${_PYTHON_PREFIX}_VERSION
                     ERROR_QUIET
                     OUTPUT_STRIP_TRAILING_WHITESPACE)

Why i summit issue to googletest instead of android NDK?

because in my project find_package(Python3 COMPONENTS Interpreter) works well,so i summit here.

Steps to reproduce the problem

MacOS: 15.6

Python3:
$ /opt/homebrew/bin/python3 -c "import sys; sys.stdout.write('.'.join([str(x) for x in sys.version_info[:3]]))"
3.13.7

Cmake: Library/Android/sdk/cmake/3.22.1/

What version of GoogleTest are you using?

1.13.0

What operating system and version are you using?

macOS: 15.6

What compiler and version are you using?

ndk/21.3.6528147/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++

What build system are you using?

cmake 3.22

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions