mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-21 14:40:48 +08:00
FindPython: ensure a usable environment is set for the free threaded Python
Define the `Python_DEFINITIONS` variable for the support of free
threaded Python developments on Windows.
This is a complement to commit 9a0dee7257
(FindPython: Add support for
free threaded python, 2024-05-30).
This commit is contained in:
@@ -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.
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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)
|
||||
@@ -4067,6 +4083,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)
|
||||
@@ -4123,6 +4145,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}
|
||||
|
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user