mirror of
https://github.com/reactos/CMake.git
synced 2024-11-23 11:39:48 +00:00
Merge topic 'FindPython-dev-subcomponents'
c1b4044d3e
FindPython: add sub-components to Development component
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Ben Boeckel <ben.boeckel@kitware.com>
Merge-request: !4616
This commit is contained in:
commit
d601a2c75c
6
Help/release/dev/FindPython-dev-subcomponents.rst
Normal file
6
Help/release/dev/FindPython-dev-subcomponents.rst
Normal file
@ -0,0 +1,6 @@
|
||||
FindPython-dev-subcomponents
|
||||
----------------------------
|
||||
|
||||
* The :module:`FindPython3`, :module:`FindPython2` and :module:`FindPython`
|
||||
modules gained sub-components ``Development.Module`` and
|
||||
``Development.Embed`` for ``Development`` component.
|
@ -13,13 +13,24 @@ The following components are supported:
|
||||
* ``Interpreter``: search for Python interpreter.
|
||||
* ``Compiler``: search for Python compiler. Only offered by IronPython.
|
||||
* ``Development``: search for development artifacts (include directories and
|
||||
libraries).
|
||||
libraries). This component includes two sub-components which can be specified
|
||||
independently:
|
||||
|
||||
* ``Development.Module``: search for artifacts for Python module
|
||||
developments.
|
||||
* ``Development.Embed``: search for artifacts for Python embedding
|
||||
developments.
|
||||
|
||||
* ``NumPy``: search for NumPy include directories.
|
||||
|
||||
If no ``COMPONENTS`` are specified, ``Interpreter`` is assumed.
|
||||
|
||||
If component ``Development`` is specified, it implies sub-components
|
||||
``Development.Module`` and ``Development.Embed``.
|
||||
|
||||
To ensure consistent versions between components ``Interpreter``, ``Compiler``,
|
||||
``Development`` and ``NumPy``, specify all components at the same time::
|
||||
``Development`` (or one of its sub-components) and ``NumPy``, specify all
|
||||
components at the same time::
|
||||
|
||||
find_package (Python COMPONENTS Interpreter Development)
|
||||
|
||||
@ -30,10 +41,11 @@ To manage concurrent versions 3 and 2 of Python, use :module:`FindPython3` and
|
||||
|
||||
.. note::
|
||||
|
||||
If components ``Interpreter`` and ``Development`` are both specified, this
|
||||
module search only for interpreter with same platform architecture as the one
|
||||
defined by ``CMake`` configuration. This contraint does not apply if only
|
||||
``Interpreter`` component is specified.
|
||||
If components ``Interpreter`` and ``Development`` (or one of its
|
||||
sub-components) are both specified, this module search only for interpreter
|
||||
with same platform architecture as the one defined by ``CMake``
|
||||
configuration. This contraint does not apply if only ``Interpreter``
|
||||
component is specified.
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
@ -45,12 +57,12 @@ This module defines the following :ref:`Imported Targets <Imported Targets>`
|
||||
Python interpreter. Target defined if component ``Interpreter`` is found.
|
||||
``Python::Compiler``
|
||||
Python compiler. Target defined if component ``Compiler`` is found.
|
||||
``Python::Module``
|
||||
Python library for Python module. Target defined if component
|
||||
``Development.Module`` is found.
|
||||
``Python::Python``
|
||||
Python library for Python embedding. Target defined if component
|
||||
``Development`` is found.
|
||||
``Python::Module``
|
||||
Python library for Python module. Target defined if component ``Development``
|
||||
is found.
|
||||
``Development.Embed`` is found.
|
||||
``Python::NumPy``
|
||||
NumPy Python library. Target defined if component ``NumPy`` is found.
|
||||
|
||||
@ -115,6 +127,10 @@ This module will set the following variables in your project
|
||||
* IronPython
|
||||
``Python_Development_FOUND``
|
||||
System has the Python development artifacts.
|
||||
``Python_Development.Module_FOUND``
|
||||
System has the Python development artifacts for Python module.
|
||||
``Python_Development.Embed_FOUND``
|
||||
System has the Python development artifacts for Python embedding.
|
||||
``Python_INCLUDE_DIRS``
|
||||
The Python include directories.
|
||||
``Python_LIBRARIES``
|
||||
|
@ -22,9 +22,9 @@ endif()
|
||||
if (NOT DEFINED _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
|
||||
message (FATAL_ERROR "FindPython: INTERNAL ERROR")
|
||||
endif()
|
||||
if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL 3)
|
||||
if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL "3")
|
||||
set(_${_PYTHON_PREFIX}_VERSIONS 3.9 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
|
||||
elseif (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL 2)
|
||||
elseif (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL "2")
|
||||
set(_${_PYTHON_PREFIX}_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0)
|
||||
else()
|
||||
message (FATAL_ERROR "FindPython: INTERNAL ERROR")
|
||||
@ -572,7 +572,8 @@ function (_PYTHON_VALIDATE_INTERPRETER)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (CMAKE_SIZEOF_VOID_P AND "Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
|
||||
if (CMAKE_SIZEOF_VOID_P AND ("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
|
||||
OR "Development.Embed" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
|
||||
AND NOT CMAKE_CROSSCOMPILING)
|
||||
# In this case, interpreter must have same architecture as environment
|
||||
execute_process (COMMAND "${_${_PYTHON_PREFIX}_EXECUTABLE}" -c
|
||||
@ -651,6 +652,7 @@ endfunction()
|
||||
|
||||
function (_PYTHON_VALIDATE_LIBRARY)
|
||||
if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
|
||||
unset (_${_PYTHON_PREFIX}_LIBRARY_DEBUG)
|
||||
return()
|
||||
endif()
|
||||
|
||||
@ -782,6 +784,25 @@ function (_PYTHON_SET_LIBRARY_DIRS _PYTHON_SLD_RESULT)
|
||||
endfunction()
|
||||
|
||||
|
||||
function (_PYTHON_SET_DEVELOPMENT_MODULE_FOUND module)
|
||||
if ("Development.${module}" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
|
||||
string(TOUPPER "${module}" id)
|
||||
set (module_found TRUE)
|
||||
|
||||
if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_${id}_ARTIFACTS
|
||||
AND NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
|
||||
set (module_found FALSE)
|
||||
endif()
|
||||
if ("INCLUDE_DIR" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_${id}_ARTIFACTS
|
||||
AND NOT _${_PYTHON_PREFIX}_INCLUDE_DIR)
|
||||
set (module_found FALSE)
|
||||
endif()
|
||||
|
||||
set (${_PYTHON_PREFIX}_Development.${module}_FOUND ${module_found} PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
# If major version is specified, it must be the same as internal major version
|
||||
if (DEFINED ${_PYTHON_PREFIX}_FIND_VERSION_MAJOR
|
||||
AND NOT ${_PYTHON_PREFIX}_FIND_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
|
||||
@ -795,19 +816,42 @@ if (NOT ${_PYTHON_PREFIX}_FIND_COMPONENTS)
|
||||
set (${_PYTHON_PREFIX}_FIND_REQUIRED_Interpreter TRUE)
|
||||
endif()
|
||||
if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
|
||||
list (APPEND ${_PYTHON_PREFIX}_FIND_COMPONENTS "Interpreter" "Development")
|
||||
list (REMOVE_DUPLICATES ${_PYTHON_PREFIX}_FIND_COMPONENTS)
|
||||
list (APPEND ${_PYTHON_PREFIX}_FIND_COMPONENTS "Interpreter" "Development.Module")
|
||||
endif()
|
||||
foreach (_${_PYTHON_PREFIX}_COMPONENT IN ITEMS Interpreter Compiler Development NumPy)
|
||||
if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
|
||||
list (APPEND ${_PYTHON_PREFIX}_FIND_COMPONENTS "Development.Module" "Development.Embed")
|
||||
endif()
|
||||
list (REMOVE_DUPLICATES ${_PYTHON_PREFIX}_FIND_COMPONENTS)
|
||||
foreach (_${_PYTHON_PREFIX}_COMPONENT IN ITEMS Interpreter Compiler Development Development.Module Development.Embed NumPy)
|
||||
set (${_PYTHON_PREFIX}_${_${_PYTHON_PREFIX}_COMPONENT}_FOUND FALSE)
|
||||
endforeach()
|
||||
if (${_PYTHON_PREFIX}_FIND_REQUIRED_Development)
|
||||
set (${_PYTHON_PREFIX}_FIND_REQUIRED_Development.Module TRUE)
|
||||
set (${_PYTHON_PREFIX}_FIND_REQUIRED_Development.Embed TRUE)
|
||||
endif()
|
||||
|
||||
unset (_${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS)
|
||||
unset (_${_PYTHON_PREFIX}_FIND_DEVELOPMENT_MODULE_ARTIFACTS)
|
||||
unset (_${_PYTHON_PREFIX}_FIND_DEVELOPMENT_EMBED_ARTIFACTS)
|
||||
if ("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "^(Windows.*|CYGWIN|MSYS)$")
|
||||
list (APPEND _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_MODULE_ARTIFACTS "LIBRARY")
|
||||
endif()
|
||||
list (APPEND _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_MODULE_ARTIFACTS "INCLUDE_DIR")
|
||||
endif()
|
||||
if ("Development.Embed" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
|
||||
list (APPEND _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_EMBED_ARTIFACTS "LIBRARY" "INCLUDE_DIR")
|
||||
endif()
|
||||
set (_${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS ${_${_PYTHON_PREFIX}_FIND_DEVELOPMENT_MODULE_ARTIFACTS} ${_${_PYTHON_PREFIX}_FIND_DEVELOPMENT_EMBED_ARTIFACTS})
|
||||
list (REMOVE_DUPLICATES _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS)
|
||||
|
||||
unset (_${_PYTHON_PREFIX}_FIND_VERSIONS)
|
||||
|
||||
# Set versions to search
|
||||
## default: search any version
|
||||
set (_${_PYTHON_PREFIX}_FIND_VERSIONS ${_${_PYTHON_PREFIX}_VERSIONS})
|
||||
|
||||
if (${_PYTHON_PREFIX}_FIND_VERSION_COUNT GREATER 1)
|
||||
if (${_PYTHON_PREFIX}_FIND_VERSION_COUNT GREATER "1")
|
||||
if (${_PYTHON_PREFIX}_FIND_VERSION_EXACT)
|
||||
set (_${_PYTHON_PREFIX}_FIND_VERSIONS ${${_PYTHON_PREFIX}_FIND_VERSION_MAJOR}.${${_PYTHON_PREFIX}_FIND_VERSION_MINOR})
|
||||
else()
|
||||
@ -962,6 +1006,63 @@ if (CMAKE_HOST_WIN32)
|
||||
string (APPEND _${_PYTHON_PREFIX}_SIGNATURE ":${_${_PYTHON_PREFIX}_FIND_REGISTRY}")
|
||||
endif()
|
||||
|
||||
function (_PYTHON_CHECK_DEVELOPMENT_SIGNATURE module)
|
||||
if ("Development.${module}" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
|
||||
string (TOUPPER "${module}" id)
|
||||
set (signature "${_${_PYTHON_PREFIX}_SIGNATURE}:")
|
||||
if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_${id}_ARTIFACTS)
|
||||
list (APPEND signature "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}:")
|
||||
endif()
|
||||
if ("INCLUDE_DIR" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_${id}_ARTIFACTS)
|
||||
list (APPEND signature "${_${_PYTHON_PREFIX}_INCLUDE_DIR}:")
|
||||
endif()
|
||||
string (MD5 signature "${signature}")
|
||||
if (signature STREQUAL _${_PYTHON_PREFIX}_DEVELOPMENT_${id}_SIGNATURE)
|
||||
if (${_PYTHON_PREFIX}_FIND_VERSION_EXACT)
|
||||
set (exact EXACT)
|
||||
endif()
|
||||
if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_${id}_ARTIFACTS)
|
||||
_python_validate_library (${${_PYTHON_PREFIX}_FIND_VERSION} ${exact} CHECK_EXISTS)
|
||||
endif()
|
||||
if ("INCLUDE_DIR" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_${id}_ARTIFACTS)
|
||||
_python_validate_include_dir (${${_PYTHON_PREFIX}_FIND_VERSION} ${exact} CHECK_EXISTS)
|
||||
endif()
|
||||
else()
|
||||
if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_${id}_ARTIFACTS)
|
||||
unset (_${_PYTHON_PREFIX}_LIBRARY_RELEASE CACHE)
|
||||
unset (_${_PYTHON_PREFIX}_LIBRARY_DEBUG CACHE)
|
||||
endif()
|
||||
if ("INCLUDE_DIR" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_${id}_ARTIFACTS)
|
||||
unset (_${_PYTHON_PREFIX}_INCLUDE_DIR CACHE)
|
||||
endif()
|
||||
endif()
|
||||
if (("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_${id}_ARTIFACTS
|
||||
AND NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
|
||||
OR ("INCLUDE_DIR" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_${id}_ARTIFACTS
|
||||
AND NOT _${_PYTHON_PREFIX}_INCLUDE_DIR))
|
||||
unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
|
||||
unset (_${_PYTHON_PREFIX}_DEVELOPMENT_${id}_SIGNATURE CACHE)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function (_PYTHON_COMPUTE_DEVELOPMENT_SIGNATURE module)
|
||||
string (TOUPPER "${module}" id)
|
||||
if (${_PYTHON_PREFIX}_Development.${module}_FOUND)
|
||||
set (signature "${_${_PYTHON_PREFIX}_SIGNATURE}:")
|
||||
if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_${id}_ARTIFACTS)
|
||||
list (APPEND signature "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}:")
|
||||
endif()
|
||||
if ("INCLUDE_DIR" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_${id}_ARTIFACTS)
|
||||
list (APPEND signature "${_${_PYTHON_PREFIX}_INCLUDE_DIR}:")
|
||||
endif()
|
||||
string (MD5 signature "${signature}")
|
||||
set (_${_PYTHON_PREFIX}_DEVELOPMENT_${id}_SIGNATURE "${signature}" CACHE INTERNAL "")
|
||||
else()
|
||||
unset (_${_PYTHON_PREFIX}_DEVELOPMENT_${id}_SIGNATURE CACHE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
unset (_${_PYTHON_PREFIX}_REQUIRED_VARS)
|
||||
unset (_${_PYTHON_PREFIX}_CACHED_VARS)
|
||||
@ -1633,46 +1734,38 @@ endif()
|
||||
|
||||
# third step, search for the development artifacts
|
||||
## Development environment is not compatible with IronPython interpreter
|
||||
if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
|
||||
if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
|
||||
OR "Development.Embed" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
|
||||
AND NOT ${_PYTHON_PREFIX}_INTERPRETER_ID STREQUAL "IronPython")
|
||||
if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS)
|
||||
list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS _${_PYTHON_PREFIX}_LIBRARY_RELEASE
|
||||
_${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE
|
||||
_${_PYTHON_PREFIX}_LIBRARY_DEBUG
|
||||
_${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG
|
||||
_${_PYTHON_PREFIX}_INCLUDE_DIR)
|
||||
if (${_PYTHON_PREFIX}_FIND_REQUIRED_Development)
|
||||
list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_LIBRARIES
|
||||
${_PYTHON_PREFIX}_INCLUDE_DIRS)
|
||||
_${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG)
|
||||
endif()
|
||||
|
||||
if (DEFINED _${_PYTHON_PREFIX}_LIBRARY_RELEASE OR DEFINED _${_PYTHON_PREFIX}_INCLUDE_DIR)
|
||||
# compute development signature and check validity of definition
|
||||
string (MD5 __${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}:${_${_PYTHON_PREFIX}_INCLUDE_DIR}")
|
||||
if (WIN32 AND NOT DEFINED _${_PYTHON_PREFIX}_LIBRARY_DEBUG)
|
||||
set (_${_PYTHON_PREFIX}_LIBRARY_DEBUG "${_PYTHON_PREFIX}_LIBRARY_DEBUG-NOTFOUND" CACHE INTERNAL "")
|
||||
if ("INCLUDE_DIR" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS)
|
||||
list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS _${_PYTHON_PREFIX}_INCLUDE_DIR)
|
||||
endif()
|
||||
if (${_PYTHON_PREFIX}_FIND_REQUIRED_Development.Module)
|
||||
if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_MODULE_ARTIFACTS)
|
||||
list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_LIBRARIES)
|
||||
endif()
|
||||
if (NOT DEFINED _${_PYTHON_PREFIX}_INCLUDE_DIR)
|
||||
set (_${_PYTHON_PREFIX}_INCLUDE_DIR "${_PYTHON_PREFIX}_INCLUDE_DIR-NOTFOUND" CACHE INTERNAL "")
|
||||
if ("INCLUDE_DIR" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_MODULE_ARTIFACTS)
|
||||
list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_INCLUDE_DIRS)
|
||||
endif()
|
||||
if (__${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE)
|
||||
# check version validity
|
||||
if (${_PYTHON_PREFIX}_FIND_VERSION_EXACT)
|
||||
_python_validate_library (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT CHECK_EXISTS)
|
||||
_python_validate_include_dir (${${_PYTHON_PREFIX}_FIND_VERSION} EXACT CHECK_EXISTS)
|
||||
else()
|
||||
_python_validate_library (${${_PYTHON_PREFIX}_FIND_VERSION} CHECK_EXISTS)
|
||||
_python_validate_include_dir (${${_PYTHON_PREFIX}_FIND_VERSION} CHECK_EXISTS)
|
||||
endif()
|
||||
else()
|
||||
unset (_${_PYTHON_PREFIX}_LIBRARY_RELEASE CACHE)
|
||||
unset (_${_PYTHON_PREFIX}_LIBRARY_DEBUG CACHE)
|
||||
unset (_${_PYTHON_PREFIX}_INCLUDE_DIR CACHE)
|
||||
if (${_PYTHON_PREFIX}_FIND_REQUIRED_Development.Embed)
|
||||
if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_EMBED_ARTIFACTS)
|
||||
list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_LIBRARIES)
|
||||
endif()
|
||||
if ("INCLUDE_DIR" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_EMBED_ARTIFACTS)
|
||||
list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_INCLUDE_DIRS)
|
||||
endif()
|
||||
if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE OR NOT _${_PYTHON_PREFIX}_INCLUDE_DIR)
|
||||
unset (_${_PYTHON_PREFIX}_CONFIG CACHE)
|
||||
unset (_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE CACHE)
|
||||
endif()
|
||||
list (REMOVE_DUPLICATES _${_PYTHON_PREFIX}_REQUIRED_VARS)
|
||||
|
||||
_python_check_development_signature (Module)
|
||||
_python_check_development_signature (Embed)
|
||||
|
||||
if (DEFINED ${_PYTHON_PREFIX}_LIBRARY
|
||||
AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_LIBRARY}")
|
||||
@ -1895,6 +1988,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS)
|
||||
if (NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
|
||||
if ((${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT CMAKE_CROSSCOMPILING) OR _${_PYTHON_PREFIX}_CONFIG)
|
||||
# retrieve root install directory
|
||||
@ -2139,9 +2233,16 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
|
||||
HINTS "${_${_PYTHON_PREFIX}_PATH}" "${_${_PYTHON_PREFIX}_PATH2}" ${_${_PYTHON_PREFIX}_HINTS}
|
||||
PATH_SUFFIXES bin)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if ("INCLUDE_DIR" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS)
|
||||
while (NOT _${_PYTHON_PREFIX}_INCLUDE_DIR)
|
||||
if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS
|
||||
AND NOT _${_PYTHON_PREFIX}_LIBRARY_RELEASE)
|
||||
# Don't search for include dir if no library was founded
|
||||
if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE AND NOT _${_PYTHON_PREFIX}_INCLUDE_DIR)
|
||||
break()
|
||||
endif()
|
||||
|
||||
if ((${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT CMAKE_CROSSCOMPILING) OR _${_PYTHON_PREFIX}_CONFIG)
|
||||
_python_get_config_var (_${_PYTHON_PREFIX}_INCLUDE_DIRS INCLUDES)
|
||||
|
||||
@ -2160,10 +2261,11 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
|
||||
endif()
|
||||
unset (_${_PYTHON_PREFIX}_INCLUDE_HINTS)
|
||||
|
||||
if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE)
|
||||
# Use the library's install prefix as a hint
|
||||
if (${_${_PYTHON_PREFIX}_LIBRARY_RELEASE} MATCHES "^(.+/Frameworks/Python.framework/Versions/[0-9.]+)")
|
||||
if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "^(.+/Frameworks/Python.framework/Versions/[0-9.]+)")
|
||||
list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}")
|
||||
elseif (${_${_PYTHON_PREFIX}_LIBRARY_RELEASE} MATCHES "^(.+)/lib(64|32)?/python[0-9.]+/config")
|
||||
elseif (_${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "^(.+)/lib(64|32)?/python[0-9.]+/config")
|
||||
list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}")
|
||||
elseif (DEFINED CMAKE_LIBRARY_ARCHITECTURE AND ${_${_PYTHON_PREFIX}_LIBRARY_RELEASE} MATCHES "^(.+)/lib/${CMAKE_LIBRARY_ARCHITECTURE}")
|
||||
list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${CMAKE_MATCH_1}")
|
||||
@ -2173,6 +2275,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
|
||||
get_filename_component (_${_PYTHON_PREFIX}_PREFIX "${_${_PYTHON_PREFIX}_PREFIX}" DIRECTORY)
|
||||
list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${_${_PYTHON_PREFIX}_PREFIX}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
_python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION})
|
||||
_python_get_registries (_${_PYTHON_PREFIX}_REGISTRY_PATHS ${_${_PYTHON_PREFIX}_VERSION})
|
||||
@ -2228,7 +2331,9 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
|
||||
# search header file in standard locations
|
||||
find_path (_${_PYTHON_PREFIX}_INCLUDE_DIR
|
||||
NAMES Python.h)
|
||||
endif()
|
||||
|
||||
break()
|
||||
endwhile()
|
||||
|
||||
set (${_PYTHON_PREFIX}_INCLUDE_DIRS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}")
|
||||
|
||||
@ -2241,10 +2346,18 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
|
||||
# retrieve version from header file
|
||||
_python_get_version (INCLUDE PREFIX _${_PYTHON_PREFIX}_INC_)
|
||||
|
||||
if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE)
|
||||
# update versioning
|
||||
if (_${_PYTHON_PREFIX}_INC_VERSION VERSION_EQUAL _${_PYTHON_PREFIX}_VERSION)
|
||||
set (_${_PYTHON_PREFIX}_VERSION_PATCH ${_${_PYTHON_PREFIX}_INC_VERSION_PATCH})
|
||||
endif()
|
||||
else()
|
||||
set (_${_PYTHON_PREFIX}_VERSION ${_${_PYTHON_PREFIX}_INC_VERSION})
|
||||
set (_${_PYTHON_PREFIX}_VERSION_MAJOR ${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR})
|
||||
set (_${_PYTHON_PREFIX}_VERSION_MINOR ${_${_PYTHON_PREFIX}_INC_VERSION_MINOR})
|
||||
set (_${_PYTHON_PREFIX}_VERSION_PATCH ${_${_PYTHON_PREFIX}_INC_VERSION_PATCH})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (NOT ${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT ${_PYTHON_PREFIX}_Compiler_FOUND)
|
||||
@ -2256,6 +2369,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
|
||||
endif()
|
||||
|
||||
# define public variables
|
||||
if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS)
|
||||
set (${_PYTHON_PREFIX}_LIBRARY_DEBUG "${_${_PYTHON_PREFIX}_LIBRARY_DEBUG}")
|
||||
_python_select_library_configurations (${_PYTHON_PREFIX})
|
||||
|
||||
@ -2280,37 +2394,42 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
|
||||
_python_set_library_dirs (${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DIRS
|
||||
_${_PYTHON_PREFIX}_RUNTIME_LIBRARY_RELEASE _${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE AND _${_PYTHON_PREFIX}_INCLUDE_DIR)
|
||||
if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE OR _${_PYTHON_PREFIX}_INCLUDE_DIR)
|
||||
if (${_PYTHON_PREFIX}_Interpreter_FOUND OR ${_PYTHON_PREFIX}_Compiler_FOUND)
|
||||
# development environment must be compatible with interpreter/compiler
|
||||
if ("${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR}" VERSION_EQUAL "${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR}"
|
||||
AND "${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR}" VERSION_EQUAL "${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR}")
|
||||
set (${_PYTHON_PREFIX}_Development_FOUND TRUE)
|
||||
_python_set_development_module_found (Module)
|
||||
_python_set_development_module_found (Embed)
|
||||
endif()
|
||||
elseif (${_PYTHON_PREFIX}_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR
|
||||
AND "${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR}" VERSION_EQUAL "${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR}")
|
||||
set (${_PYTHON_PREFIX}_Development_FOUND TRUE)
|
||||
_python_set_development_module_found (Module)
|
||||
_python_set_development_module_found (Embed)
|
||||
endif()
|
||||
if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND
|
||||
(NOT _${_PYTHON_PREFIX}_ABI IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS
|
||||
OR NOT _${_PYTHON_PREFIX}_INC_ABI IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS))
|
||||
set (${_PYTHON_PREFIX}_Development_FOUND FALSE)
|
||||
set (${_PYTHON_PREFIX}_Development.Module_FOUND FALSE)
|
||||
set (${_PYTHON_PREFIX}_Development.Embed_FOUND FALSE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
|
||||
AND ${_PYTHON_PREFIX}_Development.Module_FOUND
|
||||
AND ${_PYTHON_PREFIX}_Development.Embed_FOUND)
|
||||
set (${_PYTHON_PREFIX}_Development_FOUND TRUE)
|
||||
endif()
|
||||
|
||||
if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_GREATER_EQUAL "3"
|
||||
AND NOT DEFINED ${_PYTHON_PREFIX}_SOABI)
|
||||
_python_get_config_var (${_PYTHON_PREFIX}_SOABI SOABI)
|
||||
endif()
|
||||
|
||||
if (${_PYTHON_PREFIX}_Development_FOUND)
|
||||
# compute and save development signature
|
||||
string (MD5 __${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE "${_${_PYTHON_PREFIX}_SIGNATURE}:${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}:${_${_PYTHON_PREFIX}_INCLUDE_DIR}")
|
||||
set (_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE "${__${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE}" CACHE INTERNAL "")
|
||||
else()
|
||||
unset (_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE CACHE)
|
||||
endif()
|
||||
_python_compute_development_signature (Module)
|
||||
_python_compute_development_signature (Embed)
|
||||
|
||||
# Restore the original find library ordering
|
||||
if (DEFINED _${_PYTHON_PREFIX}_CMAKE_FIND_LIBRARY_SUFFIXES)
|
||||
@ -2318,9 +2437,13 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
|
||||
endif()
|
||||
|
||||
if (${_PYTHON_PREFIX}_ARTIFACTS_INTERACTIVE)
|
||||
if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS)
|
||||
set (${_PYTHON_PREFIX}_LIBRARY "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}" CACHE FILEPATH "${_PYTHON_PREFIX} Library")
|
||||
endif()
|
||||
if ("INCLUDE_DIR" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS)
|
||||
set (${_PYTHON_PREFIX}_INCLUDE_DIR "${_${_PYTHON_PREFIX}_INCLUDE_DIR}" CACHE FILEPATH "${_PYTHON_PREFIX} Include Directory")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
_python_mark_as_internal (_${_PYTHON_PREFIX}_LIBRARY_RELEASE
|
||||
_${_PYTHON_PREFIX}_LIBRARY_DEBUG
|
||||
@ -2328,7 +2451,8 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
|
||||
_${_PYTHON_PREFIX}_RUNTIME_LIBRARY_DEBUG
|
||||
_${_PYTHON_PREFIX}_INCLUDE_DIR
|
||||
_${_PYTHON_PREFIX}_CONFIG
|
||||
_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE)
|
||||
_${_PYTHON_PREFIX}_DEVELOPMENT_MODULE_SIGNATURE
|
||||
_${_PYTHON_PREFIX}_DEVELOPMENT_EMBED_SIGNATURE)
|
||||
endif()
|
||||
|
||||
if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Interpreter_FOUND)
|
||||
@ -2342,7 +2466,7 @@ if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Inte
|
||||
set (_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}" CACHE INTERNAL "")
|
||||
elseif (DEFINED _${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR)
|
||||
# compute numpy signature. Depends on interpreter and development signatures
|
||||
string (MD5 __${_PYTHON_PREFIX}_NUMPY_SIGNATURE "${_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE}:${_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE}:${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}")
|
||||
string (MD5 __${_PYTHON_PREFIX}_NUMPY_SIGNATURE "${_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE}:${_${_PYTHON_PREFIX}_DEVELOPMENT_MODULE_SIGNATURE}:${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}")
|
||||
if (NOT __${_PYTHON_PREFIX}_NUMPY_SIGNATURE STREQUAL _${_PYTHON_PREFIX}_NUMPY_SIGNATURE
|
||||
OR NOT EXISTS "${_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}")
|
||||
unset (_${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR CACHE)
|
||||
@ -2386,15 +2510,15 @@ if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Inte
|
||||
unset (${_PYTHON_PREFIX}_NumPy_VERSION)
|
||||
endif()
|
||||
|
||||
# final step: set NumPy founded only if Development component is founded as well
|
||||
set(${_PYTHON_PREFIX}_NumPy_FOUND ${${_PYTHON_PREFIX}_Development_FOUND})
|
||||
# final step: set NumPy founded only if Development.Module component is founded as well
|
||||
set(${_PYTHON_PREFIX}_NumPy_FOUND ${${_PYTHON_PREFIX}_Development.Module_FOUND})
|
||||
else()
|
||||
set (${_PYTHON_PREFIX}_NumPy_FOUND FALSE)
|
||||
endif()
|
||||
|
||||
if (${_PYTHON_PREFIX}_NumPy_FOUND)
|
||||
# compute and save numpy signature
|
||||
string (MD5 __${_PYTHON_PREFIX}_NUMPY_SIGNATURE "${_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE}:${_${_PYTHON_PREFIX}_DEVELOPMENT_SIGNATURE}:${${_PYTHON_PREFIX}_NumPyINCLUDE_DIR}")
|
||||
string (MD5 __${_PYTHON_PREFIX}_NUMPY_SIGNATURE "${_${_PYTHON_PREFIX}_INTERPRETER_SIGNATURE}:${_${_PYTHON_PREFIX}_DEVELOPMENT_MODULE_SIGNATURE}:${${_PYTHON_PREFIX}_NumPyINCLUDE_DIR}")
|
||||
set (_${_PYTHON_PREFIX}_NUMPY_SIGNATURE "${__${_PYTHON_PREFIX}_NUMPY_SIGNATURE}" CACHE INTERNAL "")
|
||||
else()
|
||||
unset (_${_PYTHON_PREFIX}_NUMPY_SIGNATURE CACHE)
|
||||
@ -2446,8 +2570,10 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT")
|
||||
PROPERTY IMPORTED_LOCATION "${${_PYTHON_PREFIX}_COMPILER}")
|
||||
endif()
|
||||
|
||||
if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
|
||||
AND ${_PYTHON_PREFIX}_Development_FOUND)
|
||||
if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
|
||||
AND ${_PYTHON_PREFIX}_Development.Module_FOUND)
|
||||
OR ("Development.Embed" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
|
||||
AND ${_PYTHON_PREFIX}_Development.Embed_FOUND))
|
||||
|
||||
macro (__PYTHON_IMPORT_LIBRARY __name)
|
||||
if (${_PYTHON_PREFIX}_LIBRARY_RELEASE MATCHES "${CMAKE_SHARED_LIBRARY_SUFFIX}$"
|
||||
@ -2508,31 +2634,35 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
if (${_PYTHON_PREFIX}_Development.Embed_FOUND)
|
||||
__python_import_library (${_PYTHON_PREFIX}::Python)
|
||||
endif()
|
||||
|
||||
if (CMAKE_SYSTEM_NAME MATCHES "^(Windows.*|CYGWIN|MSYS)$")
|
||||
# On Windows/CYGWIN/MSYS, Python::Module is the same as Python::Python
|
||||
# but ALIAS cannot be used because the imported library is not GLOBAL.
|
||||
__python_import_library (${_PYTHON_PREFIX}::Module)
|
||||
else()
|
||||
if (NOT TARGET ${_PYTHON_PREFIX}::Module )
|
||||
add_library (${_PYTHON_PREFIX}::Module INTERFACE IMPORTED)
|
||||
endif()
|
||||
set_property (TARGET ${_PYTHON_PREFIX}::Module
|
||||
PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIRS}")
|
||||
if (${_PYTHON_PREFIX}_Development.Module_FOUND)
|
||||
if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_MODULE_ARTIFACTS)
|
||||
# On Windows/CYGWIN/MSYS, Python::Module is the same as Python::Python
|
||||
# but ALIAS cannot be used because the imported library is not GLOBAL.
|
||||
__python_import_library (${_PYTHON_PREFIX}::Module)
|
||||
else()
|
||||
if (NOT TARGET ${_PYTHON_PREFIX}::Module)
|
||||
add_library (${_PYTHON_PREFIX}::Module INTERFACE IMPORTED)
|
||||
endif()
|
||||
set_property (TARGET ${_PYTHON_PREFIX}::Module
|
||||
PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${${_PYTHON_PREFIX}_INCLUDE_DIRS}")
|
||||
|
||||
# When available, enforce shared library generation with undefined symbols
|
||||
if (APPLE)
|
||||
set_property (TARGET ${_PYTHON_PREFIX}::Module
|
||||
PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-undefined,dynamic_lookup")
|
||||
endif()
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "SunOS")
|
||||
set_property (TARGET ${_PYTHON_PREFIX}::Module
|
||||
PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-z,nodefs")
|
||||
endif()
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "AIX")
|
||||
set_property (TARGET ${_PYTHON_PREFIX}::Module
|
||||
PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-b,erok")
|
||||
# When available, enforce shared library generation with undefined symbols
|
||||
if (APPLE)
|
||||
set_property (TARGET ${_PYTHON_PREFIX}::Module
|
||||
PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-undefined,dynamic_lookup")
|
||||
endif()
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "SunOS")
|
||||
set_property (TARGET ${_PYTHON_PREFIX}::Module
|
||||
PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-z,nodefs")
|
||||
endif()
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "AIX")
|
||||
set_property (TARGET ${_PYTHON_PREFIX}::Module
|
||||
PROPERTY INTERFACE_LINK_OPTIONS "LINKER:-b,erok")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@ -2556,6 +2686,16 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT")
|
||||
else()
|
||||
set (type MODULE)
|
||||
endif()
|
||||
|
||||
if (type STREQUAL "MODULE" AND NOT TARGET ${prefix}::Module)
|
||||
message (SEND_ERROR "${prefix}_ADD_LIBRARY: dependent target '${prefix}::Module' is not defined.\n Did you miss to request COMPONENT 'Development.Module'?")
|
||||
return()
|
||||
endif()
|
||||
if (NOT type STREQUAL "MODULE" AND NOT TARGET ${prefix}::Python)
|
||||
message (SEND_ERROR "${prefix}_ADD_LIBRARY: dependent target '${prefix}::Python' is not defined.\n Did you miss to request COMPONENT 'Development.Embed'?")
|
||||
return()
|
||||
endif()
|
||||
|
||||
add_library (${name} ${type} ${PYTHON_ADD_LIBRARY_UNPARSED_ARGUMENTS})
|
||||
|
||||
get_property (type TARGET ${name} PROPERTY TYPE)
|
||||
|
@ -13,13 +13,24 @@ The following components are supported:
|
||||
* ``Interpreter``: search for Python 2 interpreter
|
||||
* ``Compiler``: search for Python 2 compiler. Only offered by IronPython.
|
||||
* ``Development``: search for development artifacts (include directories and
|
||||
libraries)
|
||||
libraries). This component includes two sub-components which can be specified
|
||||
independently:
|
||||
|
||||
* ``Development.Module``: search for artifacts for Python 2 module
|
||||
developments.
|
||||
* ``Development.Embed``: search for artifacts for Python 2 embedding
|
||||
developments.
|
||||
|
||||
* ``NumPy``: search for NumPy include directories.
|
||||
|
||||
If no ``COMPONENTS`` are specified, ``Interpreter`` is assumed.
|
||||
|
||||
If component ``Development`` is specified, it implies sub-components
|
||||
``Development.Module`` and ``Development.Embed``.
|
||||
|
||||
To ensure consistent versions between components ``Interpreter``, ``Compiler``,
|
||||
``Development`` and ``NumPy``, specify all components at the same time::
|
||||
``Development`` (or one of its sub-components) and ``NumPy``, specify all
|
||||
components at the same time::
|
||||
|
||||
find_package (Python2 COMPONENTS Interpreter Development)
|
||||
|
||||
@ -31,10 +42,11 @@ for you.
|
||||
|
||||
.. note::
|
||||
|
||||
If components ``Interpreter`` and ``Development`` are both specified, this
|
||||
module search only for interpreter with same platform architecture as the one
|
||||
defined by ``CMake`` configuration. This contraint does not apply if only
|
||||
``Interpreter`` component is specified.
|
||||
If components ``Interpreter`` and ``Development`` (or one of its
|
||||
sub-components) are both specified, this module search only for interpreter
|
||||
with same platform architecture as the one defined by ``CMake``
|
||||
configuration. This contraint does not apply if only ``Interpreter``
|
||||
component is specified.
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
@ -46,12 +58,12 @@ This module defines the following :ref:`Imported Targets <Imported Targets>`
|
||||
Python 2 interpreter. Target defined if component ``Interpreter`` is found.
|
||||
``Python2::Compiler``
|
||||
Python 2 compiler. Target defined if component ``Compiler`` is found.
|
||||
``Python2::Python``
|
||||
Python 2 library for Python embedding. Target defined if component
|
||||
``Development`` is found.
|
||||
``Python2::Module``
|
||||
Python 2 library for Python module. Target defined if component
|
||||
``Development`` is found.
|
||||
``Development.Module`` is found.
|
||||
``Python2::Python``
|
||||
Python 2 library for Python embedding. Target defined if component
|
||||
``Development.Embed`` is found.
|
||||
``Python2::NumPy``
|
||||
NumPy library for Python 2. Target defined if component ``NumPy`` is found.
|
||||
|
||||
@ -107,6 +119,10 @@ This module will set the following variables in your project
|
||||
* IronPython
|
||||
``Python2_Development_FOUND``
|
||||
System has the Python 2 development artifacts.
|
||||
``Python2_Development.Module_FOUND``
|
||||
System has the Python 2 development artifacts for Python module.
|
||||
``Python2_Development.Embed_FOUND``
|
||||
System has the Python 2 development artifacts for Python embedding.
|
||||
``Python2_INCLUDE_DIRS``
|
||||
The Python 2 include directories.
|
||||
``Python2_LIBRARIES``
|
||||
|
@ -13,13 +13,24 @@ The following components are supported:
|
||||
* ``Interpreter``: search for Python 3 interpreter
|
||||
* ``Compiler``: search for Python 3 compiler. Only offered by IronPython.
|
||||
* ``Development``: search for development artifacts (include directories and
|
||||
libraries)
|
||||
libraries). This component includes two sub-components which can be specified
|
||||
independently:
|
||||
|
||||
* ``Development.Module``: search for artifacts for Python 3 module
|
||||
developments.
|
||||
* ``Development.Embed``: search for artifacts for Python 3 embedding
|
||||
developments.
|
||||
|
||||
* ``NumPy``: search for NumPy include directories.
|
||||
|
||||
If no ``COMPONENTS`` are specified, ``Interpreter`` is assumed.
|
||||
|
||||
If component ``Development`` is specified, it implies sub-components
|
||||
``Development.Module`` and ``Development.Embed``.
|
||||
|
||||
To ensure consistent versions between components ``Interpreter``, ``Compiler``,
|
||||
``Development`` and ``NumPy``, specify all components at the same time::
|
||||
``Development`` (or one of its sub-components) and ``NumPy``, specify all
|
||||
components at the same time::
|
||||
|
||||
find_package (Python3 COMPONENTS Interpreter Development)
|
||||
|
||||
@ -31,10 +42,11 @@ for you.
|
||||
|
||||
.. note::
|
||||
|
||||
If components ``Interpreter`` and ``Development`` are both specified, this
|
||||
module search only for interpreter with same platform architecture as the one
|
||||
defined by ``CMake`` configuration. This contraint does not apply if only
|
||||
``Interpreter`` component is specified.
|
||||
If components ``Interpreter`` and ``Development`` (or one of its
|
||||
sub-components) are both specified, this module search only for interpreter
|
||||
with same platform architecture as the one defined by ``CMake``
|
||||
configuration. This contraint does not apply if only ``Interpreter``
|
||||
component is specified.
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
@ -46,12 +58,12 @@ This module defines the following :ref:`Imported Targets <Imported Targets>`
|
||||
Python 3 interpreter. Target defined if component ``Interpreter`` is found.
|
||||
``Python3::Compiler``
|
||||
Python 3 compiler. Target defined if component ``Compiler`` is found.
|
||||
``Python3::Python``
|
||||
Python 3 library for Python embedding. Target defined if component
|
||||
``Development`` is found.
|
||||
``Python3::Module``
|
||||
Python 3 library for Python module. Target defined if component
|
||||
``Development`` is found.
|
||||
``Development.Module`` is found.
|
||||
``Python3::Python``
|
||||
Python 3 library for Python embedding. Target defined if component
|
||||
``Development.Embed`` is found.
|
||||
``Python3::NumPy``
|
||||
NumPy library for Python 3. Target defined if component ``NumPy`` is found.
|
||||
|
||||
@ -116,6 +128,10 @@ This module will set the following variables in your project
|
||||
* IronPython
|
||||
``Python3_Development_FOUND``
|
||||
System has the Python 3 development artifacts.
|
||||
``Python3_Development.Module_FOUND``
|
||||
System has the Python 3 development artifacts for Python module.
|
||||
``Python3_Development.Embed_FOUND``
|
||||
System has the Python 3 development artifacts for Python embedding.
|
||||
``Python3_INCLUDE_DIRS``
|
||||
The Python 3 include directories.
|
||||
``Python3_LIBRARIES``
|
||||
|
@ -20,6 +20,17 @@ if(CMake_TEST_FindPython)
|
||||
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
|
||||
)
|
||||
|
||||
add_test(NAME FindPython.Python2.Development.Module COMMAND
|
||||
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
|
||||
--build-and-test
|
||||
"${CMake_SOURCE_DIR}/Tests/FindPython/Python2Module"
|
||||
"${CMake_BINARY_DIR}/Tests/FindPython/Python2Module"
|
||||
${build_generator_args}
|
||||
--build-project TestPython2Module
|
||||
--build-options ${build_options}
|
||||
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
|
||||
)
|
||||
|
||||
add_test(NAME FindPython.Python2Fail COMMAND
|
||||
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
|
||||
--build-and-test
|
||||
@ -54,6 +65,17 @@ if(CMake_TEST_FindPython)
|
||||
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
|
||||
)
|
||||
|
||||
add_test(NAME FindPython.Python3.Development.Module COMMAND
|
||||
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
|
||||
--build-and-test
|
||||
"${CMake_SOURCE_DIR}/Tests/FindPython/Python3Module"
|
||||
"${CMake_BINARY_DIR}/Tests/FindPython/Python3Module"
|
||||
${build_generator_args}
|
||||
--build-project TestPython3Module
|
||||
--build-options ${build_options}
|
||||
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
|
||||
)
|
||||
|
||||
add_test(NAME FindPython.Python3Fail COMMAND
|
||||
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
|
||||
--build-and-test
|
||||
@ -276,7 +298,6 @@ if(CMake_TEST_FindPython_NumPy)
|
||||
${build_generator_args}
|
||||
--build-project TestNumPyOnly
|
||||
--build-options ${build_options}
|
||||
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -8,6 +8,12 @@ find_package(Python ${Python_REQUESTED_VERSION} REQUIRED COMPONENTS Interpreter
|
||||
if (NOT Python_FOUND)
|
||||
message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}")
|
||||
endif()
|
||||
if (NOT Python_Development.Module_FOUND)
|
||||
message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}, COMPONENT 'Development.Module'")
|
||||
endif()
|
||||
if (NOT Python_Development.Embed_FOUND)
|
||||
message (FATAL_ERROR "Fail to found Python ${Python_REQUESTED_VERSION}, COMPOENENT 'Development.Embed'")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET Python::Interpreter)
|
||||
message(SEND_ERROR "Python::Interpreter not found")
|
||||
|
@ -13,6 +13,15 @@ find_package(Python2 REQUIRED COMPONENTS Interpreter Development)
|
||||
if (NOT Python2_FOUND)
|
||||
message (FATAL_ERROR "Fail to found Python 2")
|
||||
endif()
|
||||
if (NOT Python2_Development_FOUND)
|
||||
message (FATAL_ERROR "Fail to found Python 2 'Development' component")
|
||||
endif()
|
||||
if (NOT Python2_Development.Module_FOUND)
|
||||
message (FATAL_ERROR "Fail to found Python 2 'Development.Module' component")
|
||||
endif()
|
||||
if (NOT Python2_Development.Embed_FOUND)
|
||||
message (FATAL_ERROR "Fail to found Python 2 'Development.Embed' component")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET Python2::Interpreter)
|
||||
message(SEND_ERROR "Python2::Interpreter not found")
|
||||
|
@ -4,10 +4,23 @@ project(TestPython2Embedded C)
|
||||
|
||||
include(CTest)
|
||||
|
||||
find_package(Python2 REQUIRED COMPONENTS Development)
|
||||
find_package(Python2 REQUIRED COMPONENTS Development.Embed)
|
||||
if (NOT Python2_FOUND)
|
||||
message (FATAL_ERROR "Fail to found Python 2")
|
||||
endif()
|
||||
if (Python2_Development_FOUND)
|
||||
message (FATAL_ERROR "Python 2, COMPONENT 'Development' unexpectedly found")
|
||||
endif()
|
||||
if (Python2_Development.Module_FOUND)
|
||||
message (FATAL_ERROR "Python 2, COMPONENT 'Development.Module' unexpectedly found")
|
||||
endif()
|
||||
if (NOT Python2_Development.Embed_FOUND)
|
||||
message (FATAL_ERROR "Python 2, COMPONENT 'Development.Embed' not found")
|
||||
endif()
|
||||
|
||||
if(TARGET Python2::Module)
|
||||
message(SEND_ERROR "Python2::Module unexpectedly found")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET Python2::Python)
|
||||
message(SEND_ERROR "Python2::Python not found")
|
||||
|
37
Tests/FindPython/Python2Module/CMakeLists.txt
Normal file
37
Tests/FindPython/Python2Module/CMakeLists.txt
Normal file
@ -0,0 +1,37 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(TestPython2Module C)
|
||||
|
||||
include(CTest)
|
||||
|
||||
find_package(Python2 REQUIRED COMPONENTS Interpreter Development.Module)
|
||||
if (NOT Python2_FOUND)
|
||||
message (FATAL_ERROR "Fail to found Python 2")
|
||||
endif()
|
||||
if (Python2_Development_FOUND)
|
||||
message (FATAL_ERROR "Python 2, COMPONENT 'Development' unexpectedly found")
|
||||
endif()
|
||||
if (Python2_Development.Embed_FOUND)
|
||||
message (FATAL_ERROR "Python 2, COMPONENT 'Development.Embed' unexpectedly found")
|
||||
endif()
|
||||
if (NOT Python2_Development.Module_FOUND)
|
||||
message (FATAL_ERROR "Python 2, COMPONENT 'Development.Module' not found")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET Python2::Interpreter)
|
||||
message(SEND_ERROR "Python2::Interpreter not found")
|
||||
endif()
|
||||
|
||||
if(TARGET Python2::Python)
|
||||
message(SEND_ERROR "Python2::Python unexpectedly found")
|
||||
endif()
|
||||
if(NOT TARGET Python2::Module)
|
||||
message(SEND_ERROR "Python2::Module not found")
|
||||
endif()
|
||||
|
||||
Python2_add_library (spam2 MODULE ../spam.c)
|
||||
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\")")
|
@ -13,6 +13,15 @@ find_package(Python3 REQUIRED COMPONENTS Interpreter Development)
|
||||
if (NOT Python3_FOUND)
|
||||
message (FATAL_ERROR "Fail to found Python 3")
|
||||
endif()
|
||||
if (NOT Python3_Development_FOUND)
|
||||
message (FATAL_ERROR "Fail to found Python 3 'Development' component")
|
||||
endif()
|
||||
if (NOT Python3_Development.Module_FOUND)
|
||||
message (FATAL_ERROR "Fail to found Python 3 'Development.Module' component")
|
||||
endif()
|
||||
if (NOT Python3_Development.Embed_FOUND)
|
||||
message (FATAL_ERROR "Fail to found Python 3 'Development.Embed' component")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET Python3::Interpreter)
|
||||
message(SEND_ERROR "Python3::Interpreter not found")
|
||||
|
@ -4,10 +4,23 @@ project(TestPython3Embedded C)
|
||||
|
||||
include(CTest)
|
||||
|
||||
find_package(Python3 REQUIRED COMPONENTS Development)
|
||||
find_package(Python3 REQUIRED COMPONENTS Development.Embed)
|
||||
if (NOT Python3_FOUND)
|
||||
message (FATAL_ERROR "Fail to found Python 3")
|
||||
endif()
|
||||
if (Python3_Development_FOUND)
|
||||
message (FATAL_ERROR "Python 3, COMPONENT 'Development' unexpectedly found")
|
||||
endif()
|
||||
if (Python3_Development.Module_FOUND)
|
||||
message (FATAL_ERROR "Python 3, COMPONENT 'Development.Module' unexpectedly found")
|
||||
endif()
|
||||
if (NOT Python3_Development.Embed_FOUND)
|
||||
message (FATAL_ERROR "Python 3, COMPONENT 'Development.Embed' not found")
|
||||
endif()
|
||||
|
||||
if(TARGET Python3::Module)
|
||||
message(SEND_ERROR "Python3::Module unexpectedly found")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET Python3::Python)
|
||||
message(SEND_ERROR "Python3::Python not found")
|
||||
|
37
Tests/FindPython/Python3Module/CMakeLists.txt
Normal file
37
Tests/FindPython/Python3Module/CMakeLists.txt
Normal file
@ -0,0 +1,37 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(TestPython3Module C)
|
||||
|
||||
include(CTest)
|
||||
|
||||
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
|
||||
if (NOT Python3_FOUND)
|
||||
message (FATAL_ERROR "Fail to found Python 3")
|
||||
endif()
|
||||
if (Python3_Development_FOUND)
|
||||
message (FATAL_ERROR "Python 3, COMPONENT 'Development' unexpectedly found")
|
||||
endif()
|
||||
if (Python3_Development.Embed_FOUND)
|
||||
message (FATAL_ERROR "Python 3, COMPONENT 'Development.Embed' unexpectedly found")
|
||||
endif()
|
||||
if (NOT Python3_Development.Module_FOUND)
|
||||
message (FATAL_ERROR "Python 3, COMPONENT 'Development.Module' not found")
|
||||
endif()
|
||||
|
||||
if(NOT TARGET Python3::Interpreter)
|
||||
message(SEND_ERROR "Python3::Interpreter not found")
|
||||
endif()
|
||||
|
||||
if(TARGET Python3::Python)
|
||||
message(SEND_ERROR "Python3::Python unexpectedly found")
|
||||
endif()
|
||||
if(NOT TARGET Python3::Module)
|
||||
message(SEND_ERROR "Python3::Module not found")
|
||||
endif()
|
||||
|
||||
Python3_add_library (spam3 MODULE ../spam.c)
|
||||
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\")")
|
Loading…
Reference in New Issue
Block a user