diff options
author | Andrei Polushin <polushin@gmail.com> | 2022-07-11 10:35:43 (GMT) |
---|---|---|
committer | Andrei Polushin <polushin@gmail.com> | 2022-07-12 19:12:53 (GMT) |
commit | 96ddde12359c8f20b6c27a99a6814c40b51f4452 (patch) | |
tree | bebf932bbddbed3714f706c436b589c854f0e72f /googletest | |
parent | bea621c3c39d8a7f71f07bd543c3a58bfa684f92 (diff) | |
download | googletest-96ddde12359c8f20b6c27a99a6814c40b51f4452.zip googletest-96ddde12359c8f20b6c27a99a6814c40b51f4452.tar.gz googletest-96ddde12359c8f20b6c27a99a6814c40b51f4452.tar.bz2 |
cmake: find python in order specified by PATH environment variable.refs/pull/3939/head
CMake policy CMP0094 controls a lookup strategy used to find a Python
executable:
* CMP0094=OLD selects a Python executable with a higher version.
* CMP0094=NEW selects a Python executable found earlier in PATH.
NEW behavior is critical in presence of a Python virtual environment
established and activated, i.e. added to the PATH variable.
In case GoogleTest is embedded into a larger project, the result of
`find_package(Python)` affects the whole build, not only GoogleTest
component itself.
Diffstat (limited to 'googletest')
-rw-r--r-- | googletest/cmake/internal_utils.cmake | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/googletest/cmake/internal_utils.cmake b/googletest/cmake/internal_utils.cmake index 107147f..42850f5 100644 --- a/googletest/cmake/internal_utils.cmake +++ b/googletest/cmake/internal_utils.cmake @@ -244,6 +244,12 @@ function(cxx_executable name dir libs) ${name} "${cxx_default}" "${libs}" "${dir}/${name}.cc" ${ARGN}) endfunction() +# CMP0094 policy enables finding a Python executable in the LOCATION order, as +# specified by the PATH environment variable. +if (POLICY CMP0094) + cmake_policy(SET CMP0094 NEW) +endif() + # Sets PYTHONINTERP_FOUND and PYTHON_EXECUTABLE. if ("${CMAKE_VERSION}" VERSION_LESS "3.12.0") find_package(PythonInterp) |