CMake/Modules/FindPythonLibs.cmake

118 lines
4.7 KiB
CMake
Raw Normal View History

2001-05-11 18:27:46 +04:00
#
# This module finds if Python is installed and determines where the
# include files and libraries are. It also determines what the name of
# the library is. This code sets the following variables:
#
# PYTHON_LIBRARIES = the full path to the library found
# PYTHON_INCLUDE_PATH = the path to where Python.h can be found
# PYTHON_DEBUG_LIBRARIES = the full path to the debug library found
2001-05-11 18:27:46 +04:00
#
INCLUDE(${CMAKE_ROOT}/Modules/CMakeFindFrameworks.cmake)
IF(WIN32)
2003-11-20 23:31:40 +03:00
FIND_LIBRARY(PYTHON_DEBUG_LIBRARY
NAMES python23_d python22_d python21_d python20_d python
PATHS
2002-12-10 00:22:44 +03:00
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]/libs/Debug
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]/libs
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.2\\InstallPath]/libs/Debug
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.2\\InstallPath]/libs
2002-12-10 00:22:44 +03:00
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.1\\InstallPath]/libs/Debug
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.1\\InstallPath]/libs
2002-12-10 00:22:44 +03:00
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.0\\InstallPath]/libs/Debug
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.0\\InstallPath]/libs
2002-12-10 00:22:44 +03:00
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.6\\InstallPath]/libs/Debug
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.6\\InstallPath]/libs
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.5\\InstallPath]/libs/Debug
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.5\\InstallPath]/libs
)
ENDIF(WIN32)
2001-05-11 18:27:46 +04:00
2003-11-20 23:31:40 +03:00
FIND_LIBRARY(PYTHON_LIBRARY
NAMES python23 python2.3 python2.3.dll
python22 python2.2 python2.2.dll
python21 python2.1 python2.1.dll
python20 python2.0 python2.0.dll
python16 python1.6 python1.6.dll
python15 python1.5 python1.5.dll
2001-05-11 18:27:46 +04:00
PATHS
2002-12-10 00:22:44 +03:00
/usr/lib/python2.3/config
/usr/lib/python2.2/config
/usr/lib/python2.1/config
/usr/lib/python2.0/config
2002-12-10 00:22:44 +03:00
/usr/lib/python1.6/config
/usr/lib/python1.5/config
2002-12-10 00:22:44 +03:00
/usr/lib
2001-05-11 18:27:46 +04:00
/usr/local/lib
2002-12-10 00:22:44 +03:00
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]/libs
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.2\\InstallPath]/libs
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.1\\InstallPath]/libs
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.0\\InstallPath]/libs
2002-12-10 00:22:44 +03:00
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.6\\InstallPath]/libs
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.5\\InstallPath]/libs
2001-05-11 18:27:46 +04:00
)
# Search for the python framework on Apple.
CMAKE_FIND_FRAMEWORKS(Python)
SET(PYTHON_FRAMEWORK_INCLUDES)
IF(Python_FRAMEWORKS)
IF(NOT PYTHON_INCLUDE_PATH)
FOREACH(version 2.3 2.2 2.1 2.0 1.6 1.5)
FOREACH(dir ${Python_FRAMEWORKS})
SET(PYTHON_FRAMEWORK_INCLUDES ${PYTHON_FRAMEWORK_INCLUDES}
${dir}/Versions/${version}/include/python${version})
ENDFOREACH(dir)
ENDFOREACH(version)
ENDIF(NOT PYTHON_INCLUDE_PATH)
ENDIF(Python_FRAMEWORKS)
2001-05-11 18:27:46 +04:00
FIND_PATH(PYTHON_INCLUDE_PATH Python.h
${PYTHON_FRAMEWORK_INCLUDES}
2002-12-10 00:22:44 +03:00
/usr/include/python2.3
/usr/include/python2.2
/usr/include/python2.1
/usr/include/python2.0
2002-12-10 00:22:44 +03:00
/usr/include/python1.6
/usr/include/python1.5
2002-12-10 00:22:44 +03:00
/usr/include
2001-05-11 18:27:46 +04:00
/usr/local/include
2002-12-10 00:22:44 +03:00
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]/include
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.2\\InstallPath]/include
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.1\\InstallPath]/include
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.0\\InstallPath]/include
2002-12-10 00:22:44 +03:00
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.6\\InstallPath]/include
[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.5\\InstallPath]/include
2001-05-11 18:27:46 +04:00
)
IF (WIN32)
MARK_AS_ADVANCED(
2003-11-20 23:31:40 +03:00
PYTHON_DEBUG_LIBRARY
PYTHON_LIBRARY
PYTHON_INCLUDE_PATH
)
ENDIF(WIN32)
# Python Should be built and installed as a Framework on OSX
IF(Python_FRAMEWORKS)
# If a framework has been selected for the include path,
# make sure "-framework" is used to link it.
2003-01-04 01:36:34 +03:00
IF("${PYTHON_INCLUDE_PATH}" MATCHES "Python\\.framework")
SET(PYTHON_LIBRARY "")
SET(PYTHON_DEBUG_LIBRARY "")
ENDIF("${PYTHON_INCLUDE_PATH}" MATCHES "Python\\.framework")
IF(NOT PYTHON_LIBRARY)
SET (PYTHON_LIBRARY "-framework Python" CACHE FILEPATH "Python Framework" FORCE)
ENDIF(NOT PYTHON_LIBRARY)
IF(NOT PYTHON_DEBUG_LIBRARY)
SET (PYTHON_DEBUG_LIBRARY "-framework Python" CACHE FILEPATH "Python Framework" FORCE)
ENDIF(NOT PYTHON_DEBUG_LIBRARY)
ENDIF(Python_FRAMEWORKS)
# We use 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
# module.
SET(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}")