diff options
author | Marcus D. Hanwell <marcus.hanwell@kitware.com> | 2011-01-10 18:44:45 (GMT) |
---|---|---|
committer | Marcus D. Hanwell <marcus.hanwell@kitware.com> | 2011-01-10 18:44:45 (GMT) |
commit | 2d3594b1bbd48d0dc7a071a6806c75c89341e1c5 (patch) | |
tree | 62c365528aaef3e2cb73d22b1c57abe2d349e1d7 /Modules/FindPythonLibs.cmake | |
parent | 6754b26bf0bb69ad6d65249bf4122dbbda446922 (diff) | |
download | CMake-2d3594b1bbd48d0dc7a071a6806c75c89341e1c5.zip CMake-2d3594b1bbd48d0dc7a071a6806c75c89341e1c5.tar.gz CMake-2d3594b1bbd48d0dc7a071a6806c75c89341e1c5.tar.bz2 |
Python additional version support, bug #10279.
Introduced an additional variable, Python_ADDITIONAL_VERSIONS, to both
FindPythonLibs and FindPythonInterp. Changed FindPythonInterp to loop
over versions rather than hardcoding all versions (more like libs).
Diffstat (limited to 'Modules/FindPythonLibs.cmake')
-rw-r--r-- | Modules/FindPythonLibs.cmake | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 10e9241..6e5f6ef 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -3,12 +3,12 @@ # 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 -# +# 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 +# Python_ADDITIONAL_VERSIONS - list of additional Python versions to search for #============================================================================= # Copyright 2001-2009 Kitware, Inc. @@ -27,7 +27,13 @@ INCLUDE(CMakeFindFrameworks) # Search for the python framework on Apple. CMAKE_FIND_FRAMEWORKS(Python) -FOREACH(_CURRENT_VERSION 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5) +# Set up the versions we know about, in the order we will search. Always add +# the user supplied additional versions to the front. +set(_Python_VERSIONS + ${Python_ADDITIONAL_VERSIONS} + 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5) + +FOREACH(_CURRENT_VERSION ${_Python_VERSIONS}) STRING(REPLACE "." "" _CURRENT_VERSION_NO_DOTS ${_CURRENT_VERSION}) IF(WIN32) FIND_LIBRARY(PYTHON_DEBUG_LIBRARY @@ -53,7 +59,7 @@ FOREACH(_CURRENT_VERSION 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5) PATH_SUFFIXES python${_CURRENT_VERSION}/config ) - # For backward compatibility, honour value of PYTHON_INCLUDE_PATH, if + # For backward compatibility, honour value of PYTHON_INCLUDE_PATH, if # PYTHON_INCLUDE_DIR is not set. IF(DEFINED PYTHON_INCLUDE_PATH AND NOT DEFINED PYTHON_INCLUDE_DIR) SET(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_PATH}" CACHE PATH @@ -78,9 +84,9 @@ FOREACH(_CURRENT_VERSION 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5) ) # For backward compatibility, set PYTHON_INCLUDE_PATH, but make it internal. - SET(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}" CACHE INTERNAL + SET(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}" CACHE INTERNAL "Path to where Python.h is found (deprecated)") - + ENDFOREACH(_CURRENT_VERSION) MARK_AS_ADVANCED( @@ -103,7 +109,7 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs DEFAULT_MSG PYTHON_LIBRARIES PYTHON # PYTHON_ADD_MODULE(<name> src1 src2 ... srcN) is used to build modules for python. -# PYTHON_WRITE_MODULES_HEADER(<filename>) writes a header file you can include +# PYTHON_WRITE_MODULES_HEADER(<filename>) writes a header file you can include # in your sources to initialize the static python modules FUNCTION(PYTHON_ADD_MODULE _NAME ) GET_PROPERTY(_TARGET_SUPPORTS_SHARED_LIBS @@ -148,7 +154,7 @@ FUNCTION(PYTHON_WRITE_MODULES_HEADER _filename) SET(_filenameTmp "${_filename}.in") FILE(WRITE ${_filenameTmp} "/*Created by cmake, do not edit, changes will be lost*/\n") - FILE(APPEND ${_filenameTmp} + FILE(APPEND ${_filenameTmp} "#ifndef ${_nameUpper} #define ${_nameUpper} @@ -164,7 +170,7 @@ extern \"C\" { FILE(APPEND ${_filenameTmp} "extern void init${PYTHON_MODULE_PREFIX}${_currentModule}(void);\n\n") ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST}) - FILE(APPEND ${_filenameTmp} + FILE(APPEND ${_filenameTmp} "#ifdef __cplusplus } #endif /* __cplusplus */ @@ -182,7 +188,7 @@ extern \"C\" { ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST}) 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") - + # 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) |