cmake: Improve compatibility with Python version managers

This commit is contained in:
Hennadii Stepanov 2025-02-08 06:49:05 +00:00
parent ae69fc37e4
commit dead908654
No known key found for this signature in database
GPG key ID: 410108112E7EA81F

View file

@ -534,6 +534,13 @@ if(WERROR)
unset(werror_flag)
endif()
# Prefer Unix-style package components over frameworks on macOS.
# This improves compatibility with Python version managers.
set(Python3_FIND_FRAMEWORK LAST CACHE STRING "")
# Search for generic names before more specialized ones. This
# improves compatibility with Python version managers that use shims.
set(Python3_FIND_UNVERSIONED_NAMES FIRST CACHE STRING "")
mark_as_advanced(Python3_FIND_FRAMEWORK Python3_FIND_UNVERSIONED_NAMES)
find_package(Python3 3.10 COMPONENTS Interpreter)
if(Python3_EXECUTABLE)
set(PYTHON_COMMAND ${Python3_EXECUTABLE})