diff --git a/Help/release/4.4.rst b/Help/release/4.4.rst index e49729a0d7..0f94f452e3 100644 --- a/Help/release/4.4.rst +++ b/Help/release/4.4.rst @@ -432,3 +432,14 @@ Other Changes * Targets which provide C++ modules may now be consumed by targets with different :prop_tgt:`compile features ` and :prop_tgt:`options ` than the provider. + +Updates +======= + +Changes made since CMake 4.4.0 include the following. + +4.4.1 +----- + +* The :module:`FindPython`, :module:`FindPython3` modules learned to manage, on + ``Windows`` systems, the ``pydebug`` ABI flag. diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake index 10611530a8..381147d30e 100644 --- a/Modules/FindPython.cmake +++ b/Modules/FindPython.cmake @@ -183,7 +183,7 @@ This module defines the following variables * IronPython * PyPy -``Python3_FREE_THREADED`` +``Python_FREE_THREADED`` .. versionadded:: 4.4 Boolean value, which is ``true`` if the python is free threaded (i.e. @@ -363,6 +363,10 @@ Hints threaded python), is added and is optional. If not specified, the value is ``OFF``. + .. versionadded:: 4.4.1 + The ``pydebug`` flag is now supported on ``Windows`` systems for ``Python`` + 3.14+. + Each element can be set to one of the following: * ``ON``: Corresponding flag is selected. @@ -371,8 +375,10 @@ Hints .. note:: - If ``Python3_FIND_ABI`` is not defined, any ABI, excluding the - ``gil_disabled`` flag, will be searched. + If ``Python_FIND_ABI`` is not defined, the following default apply: + + * On ``POSIX`` systems: ``ANY``, ``ANY``, ``ANY``, ``OFF``. + * On ``Windows`` systems: ``OFF``, ``OFF``, ``OFF``, ``OFF``. From this 4-tuple, various ABIs will be searched starting from the most specialized to the most general. Moreover, when ``ANY`` is specified for @@ -386,7 +392,10 @@ Hints set (Python_FIND_ABI "ON" "ANY" "ANY" "ON") The following flags combinations will be appended, in that order, to the - artifact names: ``tdmu``, ``tdm``, ``tdu``, and ``td``. + artifact names: + + * On ``POSIX`` systems: ``tdmu``, ``tdm``, ``tdu``, and ``td``. + * On ``Windows`` systems: ``tmu_d``, ``tm_d``, ``tu_d``, and ``t_d``. And to search any possible ABIs: @@ -394,18 +403,24 @@ Hints set (Python_FIND_ABI "ANY" "ANY" "ANY" "ANY") - The following combinations, in that order, will be used: ``mu``, ``m``, - ``u``, ````, ``dmu``, ``dm``, ``du``, ``d``, ``tmu``, ``tm``, ``tu``, - ``t``, ``tdmu``, ``tdm``, ``tdu``, and ``td``. + The following combinations, in that order, will be used: + + * On ``POSIX`` systems: ``mu``, ``m``, ``u``, ````, ``dmu``, ``dm``, + ``du``, ``d``, ``tmu``, ``tm``, ``tu``, ``t``, ``tdmu``, ``tdm``, ``tdu``, + and ``td``. + * On ``Windows`` systems: ``mu``, ``m``, ``u``, ````, ``mu_d``, + ``m_d``, ``u_d``, ``_d``, ``tmu``, ``tm``, ``tu``, ``t``, ``tmu_d``, ``tm_d``, + ``tu_d``, and ``t_d``. .. note:: - This hint is useful only on ``POSIX`` systems except for the - ``gil_disabled`` flag. So, on ``Windows`` systems, - when ``Python_FIND_ABI`` is defined, ``Python`` distributions from - `python.org `_ will be found only if the value for - each flag is ``OFF`` or ``ANY`` except for the fourth one - (``gil_disabled``). + This hint is fully usable on ``POSIX`` systems. On ``Windows`` systems, + only the ``gil_disabled`` and ``pydebug`` flags are supported. Moreover, + the ``pydebug`` flag is only supported for ``Python`` 3.14+. So, on + ``Windows`` systems, when ``Python_FIND_ABI`` is defined, ``Python`` + distributions from `python.org `_ will be found + only if the value for the flags ``pymalloc`` and ``unicode`` is ``OFF`` or + ``ANY``. ``Python_FIND_STRATEGY`` .. versionadded:: 3.15 @@ -659,7 +674,7 @@ If the library type is not specified, ``MODULE`` is assumed. was introduced. Specifying only major version ``3`` is equivalent to ``3.2``. .. versionchanged:: 4.4 - When ``USE_SABI`` is specified, if ``Python3_FREE_THREADED`` is ``true`` and + When ``USE_SABI`` is specified, if ``Python_FREE_THREADED`` is ``true`` and Python version is ``3.15`` or upper, ``Py_TARGET_ABI3T`` preprocessor definition will be defined rather than ``Py_LIMITED_API`` (see :pep:`803` for more details). diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 7fde096b8b..f5f7576b68 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -312,18 +312,36 @@ function (_PYTHON_GET_ABIFLAGS _PGA_FIND_ABI _PGABIFLAGS) endif() if (pydebug STREQUAL "ON") - if (abiflags) - list (TRANSFORM abiflags PREPEND "d") + if (WIN32) + if (NOT abiflags STREQUAL "") + list (TRANSFORM abiflags APPEND "_d") + else() + set (abiflags "_d") + endif() else() - set (abiflags "d") + if (NOT abiflags STREQUAL "") + list (TRANSFORM abiflags PREPEND "d") + else() + set (abiflags "d") + endif() endif() elseif (pydebug STREQUAL "ANY") - if (abiflags) - set (flags "${abiflags}") - list (TRANSFORM flags PREPEND "d") - list (APPEND abiflags "${flags}") + if (WIN32) + if (NOT abiflags STREQUAL "") + set (flags "${abiflags}") + list (TRANSFORM flags APPEND "_d") + list (APPEND abiflags "${flags}") + else() + set (abiflags "" "_d") + endif() else() - set (abiflags "" "d") + if (NOT abiflags STREQUAL "") + set (flags "${abiflags}") + list (TRANSFORM flags PREPEND "d") + list (APPEND abiflags "${flags}") + else() + set (abiflags "" "d") + endif() endif() endif() @@ -434,12 +452,26 @@ function (_PYTHON_GET_NAMES _PYTHON_PGN_NAMES) foreach (implementation IN LISTS _PGN_IMPLEMENTATIONS) if (implementation STREQUAL "CPython") + set (abi "${_${_PYTHON_PREFIX}_ABIFLAGS}") + list (TRANSFORM abi REPLACE "^$" "") + + set (unversionednames python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} python) + if (_PGN_INTERPRETER AND _${_PYTHON_PREFIX}_FIND_UNVERSIONED_NAMES STREQUAL "FIRST") - if (_PGN_DEBUG) - list (APPEND names python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}_d python_d) + if (abi) + unset (fullnames) + foreach (name IN LISTS unversionednames) + set (abinames "${abi}") + list (TRANSFORM abinames PREPEND "${name}") + list(APPEND fullnames "${abinames}") + endforeach() else() - list (APPEND names python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} python) + set (fullnames ${unversionednames}) endif() + if (_PGN_DEBUG AND NOT abi MATCHES "_d") + list (TRANSFORM fullnames APPEND "_d") + endif() + list (APPEND names ${fullnames}) endif() foreach (version IN LISTS _PGN_VERSION) if (_PGN_WIN32) @@ -448,24 +480,19 @@ function (_PYTHON_GET_NAMES _PYTHON_PGN_NAMES) else() string (REPLACE "." "" name_version ${version}) endif() - set (abi "${_${_PYTHON_PREFIX}_ABIFLAGS}") - list (TRANSFORM abi REPLACE "^$" "") if (abi) set (abinames "${abi}") list (TRANSFORM abinames PREPEND "python${name_version}") else() set (abinames "python${name_version}") endif() - if (_PGN_DEBUG) + if (_PGN_DEBUG AND NOT abi MATCHES "_d") list (TRANSFORM abinames APPEND "_d") endif() list (APPEND names ${abinames}) endif() if (_PGN_POSIX) - set (abi "${_${_PYTHON_PREFIX}_ABIFLAGS}") - list (TRANSFORM abi REPLACE "^$" "") - if (abi) if (_PGN_CONFIG AND DEFINED CMAKE_LIBRARY_ARCHITECTURE) set (abinames "${abi}") @@ -493,11 +520,20 @@ function (_PYTHON_GET_NAMES _PYTHON_PGN_NAMES) endif() endforeach() if (_PGN_INTERPRETER AND _${_PYTHON_PREFIX}_FIND_UNVERSIONED_NAMES STREQUAL "LAST") - if (_PGN_DEBUG) - list (APPEND names python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}_d python_d) + if (abi) + unset (fullnames) + foreach (name IN LISTS unversionednames) + set (abinames "${abi}") + list (TRANSFORM abinames PREPEND "${name}") + list(APPEND fullnames "${abinames}") + endforeach() else() - list (APPEND names python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} python) + set (fullnames ${unversionednames}) endif() + if (_PGN_DEBUG AND NOT abi MATCHES "_d") + list (TRANSFORM fullnames APPEND "_d") + endif() + list(APPEND names ${fullnames}) endif() elseif (implementation STREQUAL "IronPython") if (_PGN_INTERPRETER) @@ -831,7 +867,7 @@ function (_PYTHON_GET_VERSION) if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE) get_filename_component (library_name "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}" NAME) # extract version from library name - if (library_name MATCHES "python([23])([0-9]+)([tdmu]*)") + if (library_name MATCHES "python([23])([0-9]+)([tdmu_]*)") set (${_PGV_PREFIX}VERSION_MAJOR "${CMAKE_MATCH_1}" PARENT_SCOPE) set (${_PGV_PREFIX}VERSION_MINOR "${CMAKE_MATCH_2}" PARENT_SCOPE) set (${_PGV_PREFIX}VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}" PARENT_SCOPE) @@ -867,7 +903,7 @@ function (_PYTHON_GET_VERSION) if (_${_PYTHON_PREFIX}_SABI_LIBRARY_RELEASE) get_filename_component (library_name "${_${_PYTHON_PREFIX}_SABI_LIBRARY_RELEASE}" NAME) # extract version from library name - if (library_name MATCHES "python([23])([tdmu]*)") + if (library_name MATCHES "python([23])([tdmu_]*)") set (${_PGV_PREFIX}VERSION_MAJOR "${CMAKE_MATCH_1}" PARENT_SCOPE) set (${_PGV_PREFIX}VERSION "${CMAKE_MATCH_1}" PARENT_SCOPE) set (abi "${CMAKE_MATCH_2}") diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake index f4d0bba3bc..657587ec00 100644 --- a/Modules/FindPython3.cmake +++ b/Modules/FindPython3.cmake @@ -362,6 +362,10 @@ Hints threaded python), is added and is optional. If not specified, the value is ``OFF``. + .. versionadded:: 4.4.1 + The ``pydebug`` flag is now supported on ``Windows`` systems for ``Python`` + 3.14+. + Each element can be set to one of the following: * ``ON``: Corresponding flag is selected. @@ -370,8 +374,10 @@ Hints .. note:: - If ``Python3_FIND_ABI`` is not defined, any ABI, excluding the - ``gil_disabled`` flag, will be searched. + If ``Python3_FIND_ABI`` is not defined, the following default apply: + + * On ``POSIX`` systems: ``ANY``, ``ANY``, ``ANY``, ``OFF``. + * On ``Windows`` systems: ``OFF``, ``OFF``, ``OFF``, ``OFF``. From this 4-tuple, various ABIs will be searched starting from the most specialized to the most general. Moreover, when ``ANY`` is specified for @@ -385,7 +391,10 @@ Hints set (Python3_FIND_ABI "ON" "ANY" "ANY" "ON") The following flags combinations will be appended, in that order, to the - artifact names: ``tdmu``, ``tdm``, ``tdu``, and ``td``. + artifact names: + + * On ``POSIX`` systems: ``tdmu``, ``tdm``, ``tdu``, and ``td``. + * On ``Windows`` systems: ``tmu_d``, ``tm_d``, ``tu_d``, and ``t_d``. And to search any possible ABIs: @@ -393,18 +402,24 @@ Hints set (Python3_FIND_ABI "ANY" "ANY" "ANY" "ANY") - The following combinations, in that order, will be used: ``mu``, ``m``, - ``u``, ````, ``dmu``, ``dm``, ``du``, ``d``, ``tmu``, ``tm``, ``tu``, - ``t``, ``tdmu``, ``tdm``, ``tdu``, and ``td``. + The following combinations, in that order, will be used: + + * On ``POSIX`` systems: ``mu``, ``m``, ``u``, ````, ``dmu``, ``dm``, + ``du``, ``d``, ``tmu``, ``tm``, ``tu``, ``t``, ``tdmu``, ``tdm``, ``tdu``, + and ``td``. + * On ``Windows`` systems: ``mu``, ``m``, ``u``, ````, ``mu_d``, + ``m_d``, ``u_d``, ``_d``, ``tmu``, ``tm``, ``tu``, ``t``, ``tmu_d``, ``tm_d``, + ``tu_d``, and ``t_d``. .. note:: - This hint is useful only on ``POSIX`` systems except for the - ``gil_disabled`` flag. So, on ``Windows`` systems, - when ``Python_FIND_ABI`` is defined, ``Python`` distributions from - `python.org `_ will be found only if the value for - each flag is ``OFF`` or ``ANY`` except for the fourth one - (``gil_disabled``). + This hint is fully usable on ``POSIX`` systems. On ``Windows`` systems, + only the ``gil_disabled`` and ``pydebug`` flags are supported. Moreover, + the ``pydebug`` flag is only supported for ``Python`` 3.14+. So, on + ``Windows`` systems, when ``Python3_FIND_ABI`` is defined, ``Python`` + distributions from `python.org `_ will be found + only if the value for the flags ``pymalloc`` and ``unicode`` is ``OFF`` or + ``ANY``. ``Python3_FIND_STRATEGY`` .. versionadded:: 3.15