FindPython: On Windows, Enhance python debug version support

Add the following variables:
* Python_EXECUTABLE_DEBUG
* Python_INTERPRETER
* Python_DEBUG_POSTFIX

and target Python::InterpreterDebug.

python_add_library() command Manage DEBUG_POSTFIX target property based
on the value of Python_DEBUG_POSTFIX variable.

Fixes: #25874
This commit is contained in:
Marc Chevrier
2024-04-27 17:16:52 +02:00
parent 648a7fb9b9
commit c164404b2e
43 changed files with 279 additions and 62 deletions

View File

@@ -0,0 +1,20 @@
FindPython-DEBUG
----------------
* The :module:`FindPython`, :module:`FindPython2` and :module:`FindPython3`
modules offer, on ``Windows`` platform, a better support of the ``Python``
debug version:
* new variables:
* ``Python_EXECUTABLE_DEBUG``
* ``Python_INTERPRETER``
* ``Python_DEBUG_POSTFIX``
* new targets:
* ``Python::InterpreterDebug``
* ``Python::InterpreterMultiConfig``
And the ``python_add_library()`` command manage the :prop_tgt:`DEBUG_POSTFIX`
target property based on the value of the ``Python_DEBUG_POSTFIX`` variable.

View File

@@ -77,9 +77,25 @@ This module defines the following :ref:`Imported Targets <Imported Targets>`:
:prop_gbl:`CMAKE_ROLE` is ``PROJECT``.
``Python::Interpreter``
Python interpreter. Target defined if component ``Interpreter`` is found.
Python interpreter. This target is defined only if the ``Interpreter``
component is found.
``Python::InterpreterDebug``
.. versionadded:: 3.30
Python debug interpreter. This target is defined only if the ``Interpreter``
component is found and the ``Python_EXECUTABLE_DEBUG`` variable is defined.
The target is only defined on the ``Windows`` platform.
``Python::InterpreterMultiConfig``
.. versionadded:: 3.30
Python interpreter. The release or debug version of the interpreter will be
used, based on the context (platform, configuration).
This target is defined only if the ``Interpreter`` component is found
``Python::Compiler``
Python compiler. Target defined if component ``Compiler`` is found.
Python compiler. This target is defined only if the ``Compiler`` component is
found.
``Python::Module``
.. versionadded:: 3.15
@@ -114,6 +130,20 @@ This module will set the following variables in your project
System has the Python interpreter.
``Python_EXECUTABLE``
Path to the Python interpreter.
``Python_EXECUTABLE_DEBUG``
.. versionadded:: 3.30
Path to the debug Python interpreter. It is only defined on the ``Windows``
platform.
``Python_INTERPRETER``
.. versionadded:: 3.30
Path to the Python interpreter, defined as a
:manual:`generator expression <cmake-generator-expressions(7)>` selecting
the ``Python_EXECUTABLE`` or ``Python_EXECUTABLE_DEBUG`` variable based on
the context (platform, configuration).
``Python_INTERPRETER_ID``
A short string unique to the interpreter. Possible values include:
* Python
@@ -194,6 +224,12 @@ This module will set the following variables in your project
The Python include directories.
``Python_DEBUG_POSTFIX``
.. versionadded.. 3.30
Postfix of debug python module. This variable can be used to define the
:prop_tgt:`DEBUG_POSTFIX` target property.
``Python_LINK_OPTIONS``
.. versionadded:: 3.19
@@ -537,6 +573,10 @@ If the library type is not specified, ``MODULE`` is assumed.
When option ``WITH_SOABI`` is also specified, the module suffix will include
the ``Python_SOSABI`` value, if any.
.. versionadded:: 3.30
For ``MODULE`` type, the :prop_tgt:`DEBUG_POSTFIX` target property is
initialized with the value of ``Python_DEBUG_POSTFIX`` variable if defined.
#]=======================================================================]

View File

@@ -360,7 +360,11 @@ function (_PYTHON_GET_NAMES _PYTHON_PGN_NAMES)
foreach (implementation IN LISTS _PGN_IMPLEMENTATIONS)
if (implementation STREQUAL "CPython")
if (_PGN_INTERPRETER AND _${_PYTHON_PREFIX}_FIND_UNVERSIONED_NAMES STREQUAL "FIRST")
list (APPEND names python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} python)
if (_PGN_DEBUG)
list (APPEND names python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}_d python_d)
else()
list (APPEND names python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} python)
endif()
endif()
foreach (version IN LISTS _PGN_VERSION)
if (_PGN_WIN32)
@@ -412,7 +416,11 @@ function (_PYTHON_GET_NAMES _PYTHON_PGN_NAMES)
endif()
endforeach()
if (_PGN_INTERPRETER AND _${_PYTHON_PREFIX}_FIND_UNVERSIONED_NAMES STREQUAL "LAST")
list (APPEND names python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} python)
if (_PGN_DEBUG)
list (APPEND names python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR}_d python_d)
else()
list (APPEND names python${_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR} python)
endif()
endif()
elseif (implementation STREQUAL "IronPython")
if (_PGN_INTERPRETER)
@@ -458,7 +466,7 @@ endfunction()
function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME)
unset (${_PYTHON_PGCV_VALUE} PARENT_SCOPE)
if (NOT NAME MATCHES "^(PREFIX|ABIFLAGS|CONFIGDIR|INCLUDES|LIBS|SOABI|SOSABI)$")
if (NOT NAME MATCHES "^(PREFIX|ABIFLAGS|CONFIGDIR|INCLUDES|LIBS|SOABI|SOSABI|POSTFIX)$")
return()
endif()
@@ -494,7 +502,7 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME)
if (_values MATCHES "^(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.so|\\.pyd)$")
set(_values "")
else()
string (REGEX REPLACE "^[.-](.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.(so|pyd))$" "\\1" _values "${_values}")
string (REGEX REPLACE "^([.-]|_d\\.)(.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.(so|pyd))$" "\\2" _values "${_values}")
endif()
endif()
endif()
@@ -545,7 +553,7 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME)
if (_values MATCHES "^(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.so|\\.pyd)$")
set(_values "")
else()
string (REGEX REPLACE "^[.-](.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.(so|pyd))$" "\\1" _values "${_values}")
string (REGEX REPLACE "^([.-]|_d\\.)(.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.(so|pyd))$" "\\2" _values "${_values}")
endif()
endif()
endif()
@@ -572,7 +580,7 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME)
if (_values MATCHES "^(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.so|\\.pyd)$")
set(_values "")
else()
string (REGEX REPLACE "^[.-](.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.(so|pyd))$" "\\1" _values "${_values}")
string (REGEX REPLACE "^([.-]|_d\\.)(.+)(${CMAKE_SHARED_LIBRARY_SUFFIX}|\\.(so|pyd))$" "\\1" _values "${_values}")
endif()
endif()
endif()
@@ -588,6 +596,10 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME)
else()
string (REGEX REPLACE "^\\.(.+)\\.[^.]+$" "\\1" _values "${_values}")
endif()
elseif (NAME STREQUAL "POSTFIX")
if (WIN32 AND _${_PYTHON_PREFIX}_LIBRARY_DEBUG MATCHES "_d${CMAKE_IMPORT_LIBRARY_SUFFIX}$")
set (_values "_d")
endif()
else()
set (config_flag "${NAME}")
if (NAME STREQUAL "CONFIGDIR")
@@ -605,7 +617,7 @@ function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME)
endif()
endif()
if (NAME STREQUAL "ABIFLAGS" OR NAME STREQUAL "SOABI" OR NAME STREQUAL "SOSABI")
if (NAME STREQUAL "ABIFLAGS" OR NAME STREQUAL "SOABI" OR NAME STREQUAL "SOSABI" OR NAME STREQUAL "POSTFIX")
set (${_PYTHON_PGCV_VALUE} "${_values}" PARENT_SCOPE)
return()
endif()
@@ -817,6 +829,7 @@ endfunction()
function (_PYTHON_VALIDATE_INTERPRETER)
if (NOT _${_PYTHON_PREFIX}_EXECUTABLE)
unset (_${_PYTHON_PREFIX}_EXECUTABLE_DEBUG CACHE)
return()
endif()
@@ -826,6 +839,9 @@ function (_PYTHON_VALIDATE_INTERPRETER)
# interpreter does not exist anymore
set_property (CACHE _${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE PROPERTY VALUE "Cannot find the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"")
set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND")
if (WIN32)
set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE_DEBUG PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE_DEBUG-NOTFOUND")
endif()
return()
endif()
@@ -863,6 +879,9 @@ function (_PYTHON_VALIDATE_INTERPRETER)
# interpreter is not usable
set_property (CACHE _${_PYTHON_PREFIX}_Interpreter_REASON_FAILURE PROPERTY VALUE "Cannot use the interpreter \"${_${_PYTHON_PREFIX}_EXECUTABLE}\"")
set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE-NOTFOUND")
if (WIN32)
set_property (CACHE _${_PYTHON_PREFIX}_EXECUTABLE_DEBUG PROPERTY VALUE "${_PYTHON_PREFIX}_EXECUTABLE_DEBUG-NOTFOUND")
endif()
return()
endif()
@@ -1106,7 +1125,7 @@ endfunction()
function (_PYTHON_VALIDATE_LIBRARY)
if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
unset (_${_PYTHON_PREFIX}_LIBRARY_DEBUG)
unset (_${_PYTHON_PREFIX}_LIBRARY_DEBUG CACHE)
return()
endif()
@@ -1173,7 +1192,7 @@ endfunction()
function (_PYTHON_VALIDATE_SABI_LIBRARY)
if (NOT _${_PYTHON_PREFIX}_SABI_LIBRARY_RELEASE)
unset (_${_PYTHON_PREFIX}_SABI_LIBRARY_DEBUG)
unset (_${_PYTHON_PREFIX}_SABI_LIBRARY_DEBUG CACHE)
return()
endif()
@@ -1452,6 +1471,9 @@ endif()
unset (${_PYTHON_PREFIX}_SOABI)
unset (${_PYTHON_PREFIX}_SOSABI)
# Windows CPython implementation may be requiring a postfix in debug mode
unset (${_PYTHON_PREFIX}_DEBUG_POSTFIX)
# Define lookup strategy
cmake_policy (GET CMP0094 _${_PYTHON_PREFIX}_LOOKUP_POLICY)
if (_${_PYTHON_PREFIX}_LOOKUP_POLICY STREQUAL "NEW")
@@ -1788,6 +1810,7 @@ endif()
# first step, search for the interpreter
if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS _${_PYTHON_PREFIX}_EXECUTABLE
_${_PYTHON_PREFIX}_EXECUTABLE_DEBUG
_${_PYTHON_PREFIX}_INTERPRETER_PROPERTIES)
if (${_PYTHON_PREFIX}_FIND_REQUIRED_Interpreter)
list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_EXECUTABLE)
@@ -1800,6 +1823,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
unset (_${_PYTHON_PREFIX}_INTERPRETER_PROPERTIES CACHE)
endif()
set (_${_PYTHON_PREFIX}_EXECUTABLE "${${_PYTHON_PREFIX}_EXECUTABLE}" CACHE INTERNAL "")
unset (_${_PYTHON_PREFIX}_EXECUTABLE_DEBUG CACHE)
elseif (DEFINED _${_PYTHON_PREFIX}_EXECUTABLE)
# compute interpreter signature and check validity of definition
string (MD5 __${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_EXECUTABLE}")
@@ -1816,6 +1840,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
endif()
else()
unset (_${_PYTHON_PREFIX}_EXECUTABLE CACHE)
unset (_${_PYTHON_PREFIX}_EXECUTABLE_DEBUG CACHE)
endif()
if (NOT _${_PYTHON_PREFIX}_EXECUTABLE)
unset (_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE CACHE)
@@ -2263,7 +2288,30 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
set (${_PYTHON_PREFIX}_EXECUTABLE "${_${_PYTHON_PREFIX}_EXECUTABLE}" CACHE FILEPATH "${_PYTHON_PREFIX} Interpreter")
endif()
if (WIN32 AND _${_PYTHON_PREFIX}_EXECUTABLE AND "CPython" IN_LIST _${_PYTHON_PREFIX}_FIND_IMPLEMENTATIONS)
# search for debug interpreter
# use release interpreter location as a hint
_python_get_names (_${_PYTHON_PREFIX}_INTERPRETER_NAMES_DEBUG VERSION ${_${_PYTHON_PREFIX}_FIND_VERSIONS} IMPLEMENTATIONS CPython INTERPRETER WIN32 DEBUG)
get_filename_component (_${_PYTHON_PREFIX}_PATH "${_${_PYTHON_PREFIX}_EXECUTABLE}" DIRECTORY)
set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR)
find_program (_${_PYTHON_PREFIX}_EXECUTABLE_DEBUG
NAMES ${_${_PYTHON_PREFIX}_INTERPRETER_NAMES_DEBUG}
NAMES_PER_DIR
HINTS "${_${_PYTHON_PREFIX}_PATH}" ${${_PYTHON_PREFIX}_HINTS}
NO_DEFAULT_PATH)
# second try including CMAKE variables to catch-up non conventional layouts
find_program (_${_PYTHON_PREFIX}_EXECUTABLE_DEBUG
NAMES ${_${_PYTHON_PREFIX}_INTERPRETER_NAMES_DEBUG}
NAMES_PER_DIR
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH)
endif()
set (${_PYTHON_PREFIX}_EXECUTABLE_DEBUG "${_${_PYTHON_PREFIX}_EXECUTABLE_DEBUG}")
set (${_PYTHON_PREFIX}_INTERPRETER "$<IF:$<AND:$<CONFIG:Debug>,$<BOOL:${WIN32}>,$<BOOL:${${_PYTHON_PREFIX}_EXECUTABLE_DEBUG}>>,${${_PYTHON_PREFIX}_EXECUTABLE_DEBUG},${${_PYTHON_PREFIX}_EXECUTABLE}>")
_python_mark_as_internal (_${_PYTHON_PREFIX}_EXECUTABLE
_${_PYTHON_PREFIX}_EXECUTABLE_DEBUG
_${_PYTHON_PREFIX}_INTERPRETER_PROPERTIES
_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE)
endif()
@@ -3730,6 +3778,10 @@ if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
_python_get_config_var (${_PYTHON_PREFIX}_SOSABI SOSABI)
endif()
if (WIN32 AND NOT DEFINED ${_PYTHON_PREFIX}_DEBUG_POSTFIX)
_python_get_config_var (${_PYTHON_PREFIX}_DEBUG_POSTFIX POSTFIX)
endif()
_python_compute_development_signature (Module)
_python_compute_development_signature (SABIModule)
_python_compute_development_signature (Embed)
@@ -3892,11 +3944,27 @@ find_package_handle_standard_args (${_PYTHON_PREFIX}
# Create imported targets and helper functions
if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT")
if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
AND ${_PYTHON_PREFIX}_Interpreter_FOUND
AND NOT TARGET ${_PYTHON_PREFIX}::Interpreter)
add_executable (${_PYTHON_PREFIX}::Interpreter IMPORTED)
set_property (TARGET ${_PYTHON_PREFIX}::Interpreter
PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_EXECUTABLE}")
AND ${_PYTHON_PREFIX}_Interpreter_FOUND)
if(NOT TARGET ${_PYTHON_PREFIX}::Interpreter)
add_executable (${_PYTHON_PREFIX}::Interpreter IMPORTED)
set_property (TARGET ${_PYTHON_PREFIX}::Interpreter
PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_EXECUTABLE}")
endif()
if(${_PYTHON_PREFIX}_EXECUTABLE_DEBUG AND NOT TARGET ${_PYTHON_PREFIX}::InterpreterDebug)
add_executable (${_PYTHON_PREFIX}::InterpreterDebug IMPORTED)
set_property (TARGET ${_PYTHON_PREFIX}::InterpreterDebug
PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_EXECUTABLE_DEBUG}")
endif()
if(NOT TARGET ${_PYTHON_PREFIX}::InterpreterMultiConfig)
add_executable (${_PYTHON_PREFIX}::InterpreterMultiConfig IMPORTED)
set_property (TARGET ${_PYTHON_PREFIX}::InterpreterMultiConfig
PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_EXECUTABLE}")
if(${_PYTHON_PREFIX}_EXECUTABLE_DEBUG)
set_target_properties (${_PYTHON_PREFIX}::InterpreterMultiConfig
PROPERTIES IMPORTED_CONFIGURATIONS DEBUG
IMPORTED_LOCATION_DEBUG "${${_PYTHON_PREFIX}_EXECUTABLE_DEBUG}")
endif()
endif()
endif()
if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
@@ -4108,6 +4176,9 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT")
set_property (TARGET ${name} PROPERTY PREFIX "")
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set_property (TARGET ${name} PROPERTY SUFFIX ".pyd")
if (${prefix}_DEBUG_POSTFIX)
set_property (TARGET ${name} PROPERTY DEBUG_POSTFIX "${${prefix}_DEBUG_POSTFIX}")
endif()
endif()
if (PYTHON_ADD_LIBRARY_WITH_SOABI)

View File

@@ -71,9 +71,25 @@ This module defines the following :ref:`Imported Targets <Imported Targets>`:
:prop_gbl:`CMAKE_ROLE` is ``PROJECT``.
``Python2::Interpreter``
Python 2 interpreter. Target defined if component ``Interpreter`` is found.
Python 2 interpreter. This target is defined only if the ``Interpreter``
component is found.
``Python2::InterpreterDebug``
.. versionadded:: 3.30
Python 2 debug interpreter. This target is defined only if the
``Interpreter`` component is found and the ``Python2_EXECUTABLE_DEBUG``
variable is defined. The target is only defined on the ``Windows`` platform.
``Python2::InterpreterMultiConfig``
.. versionadded:: 3.30
Python 2 interpreter. The release or debug version of the interpreter will be
used, based on the context (platform, configuration).
This target is defined only if the ``Interpreter`` component is found
``Python2::Compiler``
Python 2 compiler. Target defined if component ``Compiler`` is found.
Python 2 compiler. This target is defined only if the ``Compiler`` component
is found.
``Python2::Module``
.. versionadded:: 3.15
@@ -101,6 +117,20 @@ This module will set the following variables in your project
System has the Python 2 interpreter.
``Python2_EXECUTABLE``
Path to the Python 2 interpreter.
``Python2_EXECUTABLE_DEBUG``
.. versionadded:: 3.30
Path to the debug Python 2 interpreter. It is only defined on the ``Windows``
platform.
``Python2_INTERPRETER``
.. versionadded:: 3.30
Path to the Python 2 interpreter, defined as a
:manual:`generator expression <cmake-generator-expressions(7)>` selecting
the ``Python2_EXECUTABLE`` or ``Python2_EXECUTABLE_DEBUG`` variable based on
the context (platform, configuration).
``Python2_INTERPRETER_ID``
A short string unique to the interpreter. Possible values include:
* Python
@@ -158,6 +188,12 @@ This module will set the following variables in your project
``Python2_INCLUDE_DIRS``
The Python 2 include directories.
``Python2_DEBUG_POSTFIX``
.. versionadded.. 3.30
Postfix of debug python module. This variable can be used to define the
:prop_tgt:`DEBUG_POSTFIX` target property.
``Python2_LINK_OPTIONS``
.. versionadded:: 3.19
@@ -417,6 +453,10 @@ of Python module naming rules::
<source1> [<source2> ...])
If library type is not specified, ``MODULE`` is assumed.
.. versionadded:: 3.30
For ``MODULE`` type, the :prop_tgt:`DEBUG_POSTFIX` target property is
initialized with the value of ``Python2_DEBUG_POSTFIX`` variable if defined.
#]=======================================================================]

View File

@@ -78,9 +78,25 @@ This module defines the following :ref:`Imported Targets <Imported Targets>`:
:prop_gbl:`CMAKE_ROLE` is ``PROJECT``.
``Python3::Interpreter``
Python 3 interpreter. Target defined if component ``Interpreter`` is found.
Python 3 interpreter. This target is defined only if the ``Interpreter``
component is found.
``Python3::InterpreterDebug``
.. versionadded:: 3.30
Python 3 debug interpreter. This target is defined only if the
``Interpreter`` component is found and the ``Python3_EXECUTABLE_DEBUG``
variable is defined. The target is only defined on the ``Windows`` platform.
``Python3::InterpreterMultiConfig``
.. versionadded:: 3.30
Python 3 interpreter. The release or debug version of the interpreter will be
used, based on the context (platform, configuration).
This target is defined only if the ``Interpreter`` component is found
``Python3::Compiler``
Python 3 compiler. Target defined if component ``Compiler`` is found.
Python 3 compiler. This target is defined only if the ``Compiler`` component
is found.
``Python3::Module``
.. versionadded:: 3.15
@@ -115,6 +131,20 @@ This module will set the following variables in your project
System has the Python 3 interpreter.
``Python3_EXECUTABLE``
Path to the Python 3 interpreter.
``Python3_EXECUTABLE_DEBUG``
.. versionadded:: 3.30
Path to the debug Python 3 interpreter. It is only defined on ``Windows``
platform.
``Python3_INTERPRETER``
.. versionadded:: 3.30
Path to the Python 3 interpreter, defined as a
:manual:`generator expression <cmake-generator-expressions(7)>` selecting
the ``Python3_EXECUTABLE`` or ``Python3_EXECUTABLE_DEBUG`` variable based on
the context (platform, configuration).
``Python3_INTERPRETER_ID``
A short string unique to the interpreter. Possible values include:
* Python
@@ -196,6 +226,12 @@ This module will set the following variables in your project
The Python 3 include directories.
``Python3_DEBUG_POSTFIX``
.. versionadded.. 3.30
Postfix of debug python module. This variable can be used to define the
:prop_tgt:`DEBUG_POSTFIX` target property.
``Python3_LINK_OPTIONS``
.. versionadded:: 3.19
@@ -535,6 +571,10 @@ If the library type is not specified, ``MODULE`` is assumed.
When option ``WITH_SOABI`` is also specified, the module suffix will include
the ``Python3_SOSABI`` value, if any.
.. versionadded:: 3.30
For ``MODULE`` type, the :prop_tgt:`DEBUG_POSTFIX` target property is
initialized with the value of ``Python3_DEBUG_POSTFIX`` variable if defined.
#]=======================================================================]

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestArtifactsInteractive LANGUAGES C)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestCustomFailureMessage LANGUAGES NONE)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestCustomFailureMessage.Check LANGUAGES NONE)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestDifferentComponents LANGUAGES C)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestExactVersion LANGUAGES C)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.12)
cmake_minimum_required(VERSION 3.15)
if (PYTHON_MUST_NOT_BE_FOUND)
find_package(${PYTHON_PACKAGE_NAME} QUIET)
if (${PYTHON_PACKAGE_NAME}_FOUND)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestImplementation${Python_REQUESTED_IMPLEMENTATION} LANGUAGES NONE)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestIronPython LANGUAGES NONE)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestIronPython2 LANGUAGES NONE)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestIronPython3 LANGUAGES NONE)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestMultiplePackages C)
@@ -20,7 +20,7 @@ if (CMake_TEST_FindPython2)
add_test (NAME python2_spam2
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>"
"${Python2_EXECUTABLE}" -c "import spam2; spam2.system(\"cd\")")
"${Python2_INTERPRETER}" -c "import spam2; spam2.system(\"cd\")")
endif()
@@ -40,6 +40,6 @@ if (CMake_TEST_FindPython3)
add_test (NAME python3_spam3
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>"
"${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")")
"${Python3_INTERPRETER}" -c "import spam3; spam3.system(\"cd\")")
endif()

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestNumPy LANGUAGES C)
@@ -12,7 +12,7 @@ if(CMake_TEST_FindPython2_NumPy)
add_test (NAME python2_arraytest
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:arraytest2>"
"${Python2_EXECUTABLE}" -c "import numpy; import arraytest2; arraytest2.vecsq(numpy.array([1, 2, 3]));")
"${Python2_INTERPRETER}" -c "import numpy; import arraytest2; arraytest2.vecsq(numpy.array([1, 2, 3]));")
endif()
@@ -26,6 +26,6 @@ if(CMake_TEST_FindPython3_NumPy)
add_test (NAME python3_arraytest
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:arraytest3>"
"${Python3_EXECUTABLE}" -c "import numpy; import arraytest3; arraytest3.vecsq(numpy.array([1, 2, 3]));")
"${Python3_INTERPRETER}" -c "import numpy; import arraytest3; arraytest3.vecsq(numpy.array([1, 2, 3]));")
endif()

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestNumPyOnly LANGUAGES C)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestPyPy LANGUAGES C)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestPyPy2 LANGUAGES C)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestPyPy3 LANGUAGES C)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestPython LANGUAGES C)
@@ -32,7 +32,7 @@ if (Python_REQUESTED_VERSION)
add_test (NAME python_spam${Python_REQUESTED_VERSION}
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam${Python_REQUESTED_VERSION}>"
"${Python_EXECUTABLE}" -c "import spam${Python_REQUESTED_VERSION}; spam${Python_REQUESTED_VERSION}.system(\"cd\")")
"${Python_INTERPRETER}" -c "import spam${Python_REQUESTED_VERSION}; spam${Python_REQUESTED_VERSION}.system(\"cd\")")
else()
add_test(NAME findpython_script
COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestPython2 LANGUAGES C)
@@ -39,7 +39,7 @@ target_compile_definitions (spam2 PRIVATE PYTHON2)
add_test (NAME python2_spam2
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam2>"
"${Python2_EXECUTABLE}" -c "import spam2; spam2.system(\"cd\")")
"${Python2_INTERPRETER}" -c "import spam2; spam2.system(\"cd\")")
add_test(NAME findpython2_script
COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python2

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestPython2Embedded LANGUAGES C)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestPython2Fail C)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestPython2Module LANGUAGES C)
@@ -34,4 +34,4 @@ target_compile_definitions (spam2 PRIVATE PYTHON2)
add_test (NAME python2_spam2
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam2>"
"${Python2_EXECUTABLE}" -c "import spam2; spam2.system(\"cd\")")
"${Python2_INTERPRETER}" -c "import spam2; spam2.system(\"cd\")")

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestPython2SABIModule LANGUAGES C)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestPython3 LANGUAGES C)
@@ -39,7 +39,7 @@ target_compile_definitions (spam3 PRIVATE PYTHON3)
add_test (NAME python3_spam3
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>"
"${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")")
"${Python3_INTERPRETER}" -c "import spam3; spam3.system(\"cd\")")
add_test(NAME findpython3_script
COMMAND "${CMAKE_COMMAND}" -DPYTHON_PACKAGE_NAME=Python3

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestPython3Embedded LANGUAGES C)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestPython3Fail C)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestPython3Module LANGUAGES C)
@@ -43,4 +43,4 @@ target_compile_definitions (spam3 PRIVATE PYTHON3)
add_test (NAME python3_spam3
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>"
"${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")")
"${Python3_INTERPRETER}" -c "import spam3; spam3.system(\"cd\")")

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.7)
cmake_minimum_required(VERSION 3.15)
project(TestPython3SABIModule LANGUAGES C)
@@ -52,4 +52,4 @@ endif()
add_test (NAME python3_spam3
COMMAND "${CMAKE_COMMAND}" -E env "PYTHONPATH=$<TARGET_FILE_DIR:spam3>"
"${Python3_EXECUTABLE}" -c "import spam3; spam3.system(\"cd\")")
"${Python3_INTERPRETER}" -c "import spam3; spam3.system(\"cd\")")

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestRequiredArtifacts LANGUAGES C)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestRequiredArtifacts.Check LANGUAGES C)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestSOABI LANGUAGES C)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestVirtualEnv LANGUAGES NONE)

View File

@@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.15)
find_package (Python3 REQUIRED)

View File

@@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.15)
#
# Virtual environment is defined for python3

View File

@@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.15)
set (Python3_FIND_VIRTUALENV STANDARD)
find_package (Python3 REQUIRED)

View File

@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.15)
project(TestVirtualEnvConda LANGUAGES NONE)

View File

@@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.15)
find_package (Python3 REQUIRED)

View File

@@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.15)
#
# Virtual environment is defined for python3

View File

@@ -1,3 +1,4 @@
cmake_minimum_required(VERSION 3.15)
set (Python3_FIND_VIRTUALENV STANDARD)
find_package (Python3 REQUIRED)