2013-10-15 19:17:36 +04:00
|
|
|
#.rst:
|
|
|
|
# FindPythonLibs
|
|
|
|
# --------------
|
|
|
|
#
|
|
|
|
# Find python libraries
|
|
|
|
#
|
2001-05-11 18:27:46 +04:00
|
|
|
# This module finds if Python is installed and determines where the
|
2013-10-15 19:17:36 +04:00
|
|
|
# include files and libraries are. It also determines what the name of
|
|
|
|
# the library is. This code sets the following variables:
|
|
|
|
#
|
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# PYTHONLIBS_FOUND - have the Python libs been found
|
|
|
|
# PYTHON_LIBRARIES - path to the python library
|
|
|
|
# PYTHON_INCLUDE_PATH - path to where Python.h is found (deprecated)
|
|
|
|
# PYTHON_INCLUDE_DIRS - path to where Python.h is found
|
|
|
|
# PYTHON_DEBUG_LIBRARIES - path to the debug library (deprecated)
|
|
|
|
# PYTHONLIBS_VERSION_STRING - version of the Python libs found (since CMake 2.8.8)
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# The Python_ADDITIONAL_VERSIONS variable can be used to specify a list
|
|
|
|
# of version numbers that should be taken into account when searching
|
|
|
|
# for Python. You need to set this variable before calling
|
|
|
|
# find_package(PythonLibs).
|
|
|
|
#
|
|
|
|
# If you'd like to specify the installation of Python to use, you should
|
|
|
|
# modify the following cache variables:
|
|
|
|
#
|
|
|
|
# ::
|
|
|
|
#
|
|
|
|
# PYTHON_LIBRARY - path to the python library
|
|
|
|
# PYTHON_INCLUDE_DIR - path to where Python.h is found
|
2001-05-11 18:27:46 +04:00
|
|
|
|
2009-09-28 19:45:50 +04:00
|
|
|
#=============================================================================
|
|
|
|
# Copyright 2001-2009 Kitware, Inc.
|
|
|
|
#
|
|
|
|
# Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
# see accompanying file Copyright.txt for details.
|
|
|
|
#
|
|
|
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
# See the License for more information.
|
|
|
|
#=============================================================================
|
2010-08-07 04:48:47 +04:00
|
|
|
# (To distribute this file outside of CMake, substitute the full
|
2009-09-28 19:45:50 +04:00
|
|
|
# License text for the above reference.)
|
|
|
|
|
2012-11-04 00:35:44 +04:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindFrameworks.cmake)
|
2007-07-19 17:00:51 +04:00
|
|
|
# Search for the python framework on Apple.
|
|
|
|
CMAKE_FIND_FRAMEWORKS(Python)
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_PYTHON1_VERSIONS 1.6 1.5)
|
|
|
|
set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0)
|
|
|
|
set(_PYTHON3_VERSIONS 3.3 3.2 3.1 3.0)
|
|
|
|
|
|
|
|
if(PythonLibs_FIND_VERSION)
|
2013-08-31 19:46:44 +04:00
|
|
|
if(PythonLibs_FIND_VERSION_COUNT GREATER 1)
|
|
|
|
set(_PYTHON_FIND_MAJ_MIN "${PythonLibs_FIND_VERSION_MAJOR}.${PythonLibs_FIND_VERSION_MINOR}")
|
2012-08-13 21:47:32 +04:00
|
|
|
unset(_PYTHON_FIND_OTHER_VERSIONS)
|
|
|
|
if(PythonLibs_FIND_VERSION_EXACT)
|
|
|
|
if(_PYTHON_FIND_MAJ_MIN STREQUAL PythonLibs_FIND_VERSION)
|
|
|
|
set(_PYTHON_FIND_OTHER_VERSIONS "${PythonLibs_FIND_VERSION}")
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_PYTHON_FIND_OTHER_VERSIONS "${PythonLibs_FIND_VERSION}" "${_PYTHON_FIND_MAJ_MIN}")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
else()
|
2013-08-31 19:46:44 +04:00
|
|
|
foreach(_PYTHON_V ${_PYTHON${PythonLibs_FIND_VERSION_MAJOR}_VERSIONS})
|
2012-08-13 21:47:32 +04:00
|
|
|
if(NOT _PYTHON_V VERSION_LESS _PYTHON_FIND_MAJ_MIN)
|
|
|
|
list(APPEND _PYTHON_FIND_OTHER_VERSIONS ${_PYTHON_V})
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-08-13 21:47:32 +04:00
|
|
|
unset(_PYTHON_FIND_MAJ_MIN)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2013-08-31 19:46:44 +04:00
|
|
|
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON${PythonLibs_FIND_VERSION_MAJOR}_VERSIONS})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-02-22 00:00:15 +04:00
|
|
|
|
2011-01-10 21:44:45 +03:00
|
|
|
# Set up the versions we know about, in the order we will search. Always add
|
|
|
|
# the user supplied additional versions to the front.
|
2014-02-27 06:47:20 +04:00
|
|
|
# If FindPythonInterp has already found the major and minor version,
|
|
|
|
# insert that version between the user supplied versions and the stock
|
|
|
|
# version list.
|
|
|
|
find_package(PythonInterp QUIET)
|
|
|
|
set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS})
|
|
|
|
if(DEFINED PYTHON_VERSION_MAJOR AND DEFINED PYTHON_VERSION_MINOR)
|
|
|
|
list(APPEND _Python_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
|
|
|
|
endif()
|
|
|
|
list(APPEND _Python_VERSIONS ${_PYTHON_FIND_OTHER_VERSIONS})
|
2012-02-22 00:00:15 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
unset(_PYTHON_FIND_OTHER_VERSIONS)
|
|
|
|
unset(_PYTHON1_VERSIONS)
|
|
|
|
unset(_PYTHON2_VERSIONS)
|
|
|
|
unset(_PYTHON3_VERSIONS)
|
2011-01-10 21:44:45 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
foreach(_CURRENT_VERSION ${_Python_VERSIONS})
|
|
|
|
string(REPLACE "." "" _CURRENT_VERSION_NO_DOTS ${_CURRENT_VERSION})
|
|
|
|
if(WIN32)
|
|
|
|
find_library(PYTHON_DEBUG_LIBRARY
|
2007-07-19 17:00:51 +04:00
|
|
|
NAMES python${_CURRENT_VERSION_NO_DOTS}_d python
|
|
|
|
PATHS
|
|
|
|
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug
|
2012-01-10 18:55:42 +04:00
|
|
|
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs/Debug
|
|
|
|
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
|
|
|
|
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
|
|
|
|
)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2003-12-30 00:18:18 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
find_library(PYTHON_LIBRARY
|
2012-03-28 00:24:43 +04:00
|
|
|
NAMES
|
|
|
|
python${_CURRENT_VERSION_NO_DOTS}
|
|
|
|
python${_CURRENT_VERSION}mu
|
|
|
|
python${_CURRENT_VERSION}m
|
|
|
|
python${_CURRENT_VERSION}u
|
|
|
|
python${_CURRENT_VERSION}
|
2001-11-30 18:23:00 +03:00
|
|
|
PATHS
|
2007-07-19 17:00:51 +04:00
|
|
|
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
|
2012-01-10 18:55:42 +04:00
|
|
|
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/libs
|
2007-07-19 17:00:51 +04:00
|
|
|
# Avoid finding the .dll in the PATH. We want the .lib.
|
|
|
|
NO_SYSTEM_ENVIRONMENT_PATH
|
2001-11-30 18:23:00 +03:00
|
|
|
)
|
2009-12-14 22:15:31 +03:00
|
|
|
# Look for the static library in the Python config directory
|
2012-08-13 21:47:32 +04:00
|
|
|
find_library(PYTHON_LIBRARY
|
2009-12-14 22:15:31 +03:00
|
|
|
NAMES python${_CURRENT_VERSION_NO_DOTS} python${_CURRENT_VERSION}
|
|
|
|
# Avoid finding the .dll in the PATH. We want the .lib.
|
|
|
|
NO_SYSTEM_ENVIRONMENT_PATH
|
|
|
|
# This is where the static library is usually located
|
|
|
|
PATH_SUFFIXES python${_CURRENT_VERSION}/config
|
|
|
|
)
|
2003-12-30 00:18:18 +03:00
|
|
|
|
2011-01-10 21:44:45 +03:00
|
|
|
# For backward compatibility, honour value of PYTHON_INCLUDE_PATH, if
|
2009-09-14 17:34:57 +04:00
|
|
|
# PYTHON_INCLUDE_DIR is not set.
|
2012-08-13 21:47:32 +04:00
|
|
|
if(DEFINED PYTHON_INCLUDE_PATH AND NOT DEFINED PYTHON_INCLUDE_DIR)
|
|
|
|
set(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_PATH}" CACHE PATH
|
2009-09-14 17:34:57 +04:00
|
|
|
"Path to where Python.h is found" FORCE)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2009-09-14 17:34:57 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(PYTHON_FRAMEWORK_INCLUDES)
|
|
|
|
if(Python_FRAMEWORKS AND NOT PYTHON_INCLUDE_DIR)
|
|
|
|
foreach(dir ${Python_FRAMEWORKS})
|
|
|
|
set(PYTHON_FRAMEWORK_INCLUDES ${PYTHON_FRAMEWORK_INCLUDES}
|
2007-07-19 17:00:51 +04:00
|
|
|
${dir}/Versions/${_CURRENT_VERSION}/include/python${_CURRENT_VERSION})
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
|
|
|
endif()
|
2001-05-11 18:27:46 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
find_path(PYTHON_INCLUDE_DIR
|
2007-07-19 17:00:51 +04:00
|
|
|
NAMES Python.h
|
|
|
|
PATHS
|
|
|
|
${PYTHON_FRAMEWORK_INCLUDES}
|
|
|
|
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include
|
2012-01-10 18:55:42 +04:00
|
|
|
[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_CURRENT_VERSION}\\InstallPath]/include
|
2007-07-19 17:00:51 +04:00
|
|
|
PATH_SUFFIXES
|
2012-03-28 00:24:43 +04:00
|
|
|
python${_CURRENT_VERSION}mu
|
|
|
|
python${_CURRENT_VERSION}m
|
|
|
|
python${_CURRENT_VERSION}u
|
2007-07-19 17:00:51 +04:00
|
|
|
python${_CURRENT_VERSION}
|
2001-12-04 18:27:04 +03:00
|
|
|
)
|
2009-09-14 17:34:57 +04:00
|
|
|
|
2012-03-28 00:21:06 +04:00
|
|
|
# For backward compatibility, set PYTHON_INCLUDE_PATH.
|
2012-08-13 21:47:32 +04:00
|
|
|
set(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}")
|
2011-01-10 21:44:45 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(PYTHON_INCLUDE_DIR AND EXISTS "${PYTHON_INCLUDE_DIR}/patchlevel.h")
|
|
|
|
file(STRINGS "${PYTHON_INCLUDE_DIR}/patchlevel.h" python_version_str
|
2012-02-22 00:12:16 +04:00
|
|
|
REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"")
|
2012-08-13 21:47:32 +04:00
|
|
|
string(REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"]+)\".*" "\\1"
|
2012-02-22 00:12:16 +04:00
|
|
|
PYTHONLIBS_VERSION_STRING "${python_version_str}")
|
2012-08-13 21:47:32 +04:00
|
|
|
unset(python_version_str)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2012-02-22 20:25:08 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(PYTHON_LIBRARY AND PYTHON_INCLUDE_DIR)
|
|
|
|
break()
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endforeach()
|
2007-07-19 17:00:51 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
mark_as_advanced(
|
2007-07-19 17:00:51 +04:00
|
|
|
PYTHON_DEBUG_LIBRARY
|
|
|
|
PYTHON_LIBRARY
|
2009-09-14 17:34:57 +04:00
|
|
|
PYTHON_INCLUDE_DIR
|
2007-07-19 17:00:51 +04:00
|
|
|
)
|
2002-12-27 19:14:52 +03:00
|
|
|
|
2009-09-14 17:34:57 +04:00
|
|
|
# We use PYTHON_INCLUDE_DIR, PYTHON_LIBRARY and PYTHON_DEBUG_LIBRARY for the
|
|
|
|
# cache entries because they are meant to specify the location of a single
|
|
|
|
# library. We now set the variables listed by the documentation for this
|
2003-11-20 23:41:29 +03:00
|
|
|
# module.
|
2012-08-13 21:47:32 +04:00
|
|
|
set(PYTHON_INCLUDE_DIRS "${PYTHON_INCLUDE_DIR}")
|
|
|
|
set(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}")
|
2007-07-18 21:26:02 +04:00
|
|
|
|
2012-02-22 00:40:02 +04:00
|
|
|
# These variables have been historically named in this module different from
|
|
|
|
# what SELECT_LIBRARY_CONFIGURATIONS() expects.
|
2012-08-13 21:47:32 +04:00
|
|
|
set(PYTHON_LIBRARY_DEBUG "${PYTHON_DEBUG_LIBRARY}")
|
|
|
|
set(PYTHON_LIBRARY_RELEASE "${PYTHON_LIBRARY}")
|
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
|
2012-02-22 00:40:02 +04:00
|
|
|
SELECT_LIBRARY_CONFIGURATIONS(PYTHON)
|
|
|
|
# SELECT_LIBRARY_CONFIGURATIONS() sets ${PREFIX}_FOUND if it has a library.
|
|
|
|
# Unset this, this prefix doesn't match the module prefix, they are different
|
|
|
|
# for historical reasons.
|
2012-08-13 21:47:32 +04:00
|
|
|
unset(PYTHON_FOUND)
|
2007-07-18 21:26:02 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
2012-02-22 00:12:16 +04:00
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs
|
|
|
|
REQUIRED_VARS PYTHON_LIBRARIES PYTHON_INCLUDE_DIRS
|
|
|
|
VERSION_VAR PYTHONLIBS_VERSION_STRING)
|
2007-07-19 19:47:23 +04:00
|
|
|
|
2008-02-16 02:26:37 +03:00
|
|
|
# PYTHON_ADD_MODULE(<name> src1 src2 ... srcN) is used to build modules for python.
|
2011-01-10 21:44:45 +03:00
|
|
|
# PYTHON_WRITE_MODULES_HEADER(<filename>) writes a header file you can include
|
2008-02-16 02:26:37 +03:00
|
|
|
# in your sources to initialize the static python modules
|
2012-08-13 21:47:32 +04:00
|
|
|
function(PYTHON_ADD_MODULE _NAME )
|
|
|
|
get_property(_TARGET_SUPPORTS_SHARED_LIBS
|
2010-08-13 22:49:29 +04:00
|
|
|
GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
|
2012-08-13 21:47:32 +04:00
|
|
|
option(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE)
|
|
|
|
option(PYTHON_MODULE_${_NAME}_BUILD_SHARED
|
2010-02-17 19:37:37 +03:00
|
|
|
"Add module ${_NAME} shared" ${_TARGET_SUPPORTS_SHARED_LIBS})
|
|
|
|
|
|
|
|
# Mark these options as advanced
|
2012-08-13 21:47:32 +04:00
|
|
|
mark_as_advanced(PYTHON_ENABLE_MODULE_${_NAME}
|
2010-02-17 19:37:37 +03:00
|
|
|
PYTHON_MODULE_${_NAME}_BUILD_SHARED)
|
2007-07-19 17:00:51 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(PYTHON_ENABLE_MODULE_${_NAME})
|
|
|
|
if(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
|
|
|
|
set(PY_MODULE_TYPE MODULE)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(PY_MODULE_TYPE STATIC)
|
|
|
|
set_property(GLOBAL APPEND PROPERTY PY_STATIC_MODULES_LIST ${_NAME})
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2007-07-19 17:00:51 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set_property(GLOBAL APPEND PROPERTY PY_MODULES_LIST ${_NAME})
|
|
|
|
add_library(${_NAME} ${PY_MODULE_TYPE} ${ARGN})
|
|
|
|
# target_link_libraries(${_NAME} ${PYTHON_LIBRARIES})
|
2008-02-16 02:26:37 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
|
|
|
|
set_target_properties(${_NAME} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}")
|
|
|
|
if(WIN32 AND NOT CYGWIN)
|
|
|
|
set_target_properties(${_NAME} PROPERTIES SUFFIX ".pyd")
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endif()
|
2010-09-24 23:04:24 +04:00
|
|
|
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
|
|
|
endfunction()
|
2008-02-16 02:26:37 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
function(PYTHON_WRITE_MODULES_HEADER _filename)
|
2008-02-16 02:26:37 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
get_property(PY_STATIC_MODULES_LIST GLOBAL PROPERTY PY_STATIC_MODULES_LIST)
|
2007-07-19 17:00:51 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
get_filename_component(_name "${_filename}" NAME)
|
|
|
|
string(REPLACE "." "_" _name "${_name}")
|
|
|
|
string(TOUPPER ${_name} _nameUpper)
|
|
|
|
set(_filename ${CMAKE_CURRENT_BINARY_DIR}/${_filename})
|
2007-08-02 23:48:51 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(_filenameTmp "${_filename}.in")
|
|
|
|
file(WRITE ${_filenameTmp} "/*Created by cmake, do not edit, changes will be lost*/\n")
|
|
|
|
file(APPEND ${_filenameTmp}
|
2010-02-17 19:37:37 +03:00
|
|
|
"#ifndef ${_nameUpper}
|
|
|
|
#define ${_nameUpper}
|
2007-08-02 23:48:51 +04:00
|
|
|
|
|
|
|
#include <Python.h>
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern \"C\" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
")
|
2007-07-19 17:00:51 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
foreach(_currentModule ${PY_STATIC_MODULES_LIST})
|
|
|
|
file(APPEND ${_filenameTmp} "extern void init${PYTHON_MODULE_PREFIX}${_currentModule}(void);\n\n")
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
2007-07-19 17:00:51 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
file(APPEND ${_filenameTmp}
|
2007-08-02 23:48:51 +04:00
|
|
|
"#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
")
|
|
|
|
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
foreach(_currentModule ${PY_STATIC_MODULES_LIST})
|
|
|
|
file(APPEND ${_filenameTmp} "int ${_name}_${_currentModule}(void) \n{\n static char name[]=\"${PYTHON_MODULE_PREFIX}${_currentModule}\"; return PyImport_AppendInittab(name, init${PYTHON_MODULE_PREFIX}${_currentModule});\n}\n\n")
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
2007-07-19 17:00:51 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
file(APPEND ${_filenameTmp} "void ${_name}_LoadAllPythonModules(void)\n{\n")
|
|
|
|
foreach(_currentModule ${PY_STATIC_MODULES_LIST})
|
|
|
|
file(APPEND ${_filenameTmp} " ${_name}_${_currentModule}();\n")
|
2012-08-13 21:50:14 +04:00
|
|
|
endforeach()
|
2012-08-13 21:47:32 +04:00
|
|
|
file(APPEND ${_filenameTmp} "}\n\n")
|
|
|
|
file(APPEND ${_filenameTmp} "#ifndef EXCLUDE_LOAD_ALL_FUNCTION\nvoid CMakeLoadAllPythonModules(void)\n{\n ${_name}_LoadAllPythonModules();\n}\n#endif\n\n#endif\n")
|
2011-01-10 21:44:45 +03:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
# with configure_file() cmake complains that you may not use a file created using file(WRITE) as input file for configure_file()
|
|
|
|
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_filenameTmp}" "${_filename}" OUTPUT_QUIET ERROR_QUIET)
|
2007-08-02 23:48:51 +04:00
|
|
|
|
2012-08-13 21:50:14 +04:00
|
|
|
endfunction()
|