diff options
author | Brad King <brad.king@kitware.com> | 2024-08-27 13:42:13 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-08-27 13:42:37 (GMT) |
commit | a0317334ae0fe69443d4bffa1ac8ccd81c2fe8d5 (patch) | |
tree | 48138d7e14bb4bdeac122269c2fadb3712a9f14d | |
parent | 7400c1e9bb0ea8f3b1a795c4b496004dbf316d15 (diff) | |
parent | 10abd2ac5a9dd8dd3b8d48c2e1735d813fe2aab0 (diff) | |
download | CMake-a0317334ae0fe69443d4bffa1ac8ccd81c2fe8d5.zip CMake-a0317334ae0fe69443d4bffa1ac8ccd81c2fe8d5.tar.gz CMake-a0317334ae0fe69443d4bffa1ac8ccd81c2fe8d5.tar.bz2 |
Merge topic 'FindPython-free-threaded-python' into release-3.30
10abd2ac5a FindPython: ensure a usable environment is set for the free threaded Python
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9775
-rw-r--r-- | Help/release/3.30.rst | 8 | ||||
-rw-r--r-- | Modules/FindPython.cmake | 5 | ||||
-rw-r--r-- | Modules/FindPython/Support.cmake | 27 | ||||
-rw-r--r-- | Modules/FindPython3.cmake | 5 |
4 files changed, 45 insertions, 0 deletions
diff --git a/Help/release/3.30.rst b/Help/release/3.30.rst index 2d57249..ca35d1f 100644 --- a/Help/release/3.30.rst +++ b/Help/release/3.30.rst @@ -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. diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake index 345afc5..58e1348 100644 --- a/Modules/FindPython.cmake +++ b/Modules/FindPython.cmake @@ -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 diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 294e7d9..35a1d67 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -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} diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake index 9002209..55d33a2 100644 --- a/Modules/FindPython3.cmake +++ b/Modules/FindPython3.cmake @@ -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 |