Merge topic 'FindPython-free-threaded-python'

10abd2ac5a FindPython: ensure a usable environment is set for the free threaded Python

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9775
This commit is contained in:
Brad King 2024-08-27 13:42:13 +00:00 committed by Kitware Robot
commit a818a9afd6
4 changed files with 45 additions and 0 deletions

View File

@ -254,3 +254,11 @@ Changes made since CMake 3.30.0 include the following.
* These versions made no changes to documented features or interfaces.
Some implementation updates were made to support ecosystem changes
and/or fix regressions.
.. 3.30.3 (unreleased)
* The :module:`FindPython` and :module:`FindPython3` modules now define,
respectively, the ``Python_DEFINITIONS`` and ``Python3_DEFINITIONS``
variables on Windows to support development with the free threaded
version of Python. The :prop_tgt:`INTERFACE_COMPILE_DEFINITIONS` target
property is also defined for the various targets provided by these modules.

View File

@ -224,6 +224,11 @@ This module will set the following variables in your project
The Python include directories.
``Python_DEFINITIONS``
.. versionadded:: 3.30.3
The Python preprocessor definitions.
``Python_DEBUG_POSTFIX``
.. versionadded.. 3.30

View File

@ -3740,6 +3740,14 @@ if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
_${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE
_${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG)
endif()
if (WIN32 AND _${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "t${CMAKE_IMPORT_LIBRARY_SUFFIX}$")
# On windows, header file is shared between the different implementations
# So Py_GIL_DISABLED should be set explicitly
set (${_PYTHON_PREFIX}_DEFINITIONS Py_GIL_DISABLED=1)
else()
unset (${_PYTHON_PREFIX}_DEFINITIONS)
endif()
endif()
if ("SABI_LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS)
@ -3769,6 +3777,14 @@ if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
_${_PYTHON_PREFIX}_RUNTIME_SABI_LIBRARY_RELEASE
_${_PYTHON_PREFIX}_RUNTIME_SABI_LIBRARY_DEBUG)
endif()
if (WIN32 AND _${_PYTHON_PREFIX}_SABI_LIBRARY_RELEASE MATCHES "t${CMAKE_IMPORT_LIBRARY_SUFFIX}$")
# On windows, header file is shared between the different implementations
# So Py_GIL_DISABLED should be set explicitly
set (${_PYTHON_PREFIX}_DEFINITIONS Py_GIL_DISABLED=1)
else()
unset (${_PYTHON_PREFIX}_DEFINITIONS)
endif()
endif()
if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE OR _${_PYTHON_PREFIX}_SABI_LIBRARY_RELEASE OR _${_PYTHON_PREFIX}_INCLUDE_DIR)
@ -4066,6 +4082,12 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT")
set_property (TARGET ${__name}
PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIRS}")
if (${_PYTHON_PREFIX}_DEFINITIONS)
set_property (TARGET ${__name}
PROPERTY INTERFACE_COMPILE_DEFINITIONS "${${_PYTHON_PREFIX}_DEFINITIONS}")
endif()
if (${_PYTHON_PREFIX}_${_PREFIX}LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_RUNTIME_${_PREFIX}LIBRARY_RELEASE)
# System manage shared libraries in two parts: import and runtime
if (${_PYTHON_PREFIX}_${_PREFIX}LIBRARY_RELEASE AND ${_PYTHON_PREFIX}_${_PREFIX}LIBRARY_DEBUG)
@ -4122,6 +4144,11 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT")
set_property (TARGET ${__name}
PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIRS}")
if (${_PYTHON_PREFIX}_DEFINITIONS)
set_property (TARGET ${__name}
PROPERTY INTERFACE_COMPILE_DEFINITIONS "${${_PYTHON_PREFIX}_DEFINITIONS}")
endif()
# When available, enforce shared library generation with undefined symbols
if (APPLE)
set_property (TARGET ${__name}

View File

@ -226,6 +226,11 @@ This module will set the following variables in your project
The Python 3 include directories.
``Python3_DEFINITIONS``
.. versionadded:: 3.30.3
The Python 3 preprocessor definitions.
``Python3_DEBUG_POSTFIX``
.. versionadded.. 3.30