FindPythonLibs.cmake 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #
  2. # This module finds if Python is installed and determines where the
  3. # include files and libraries are. It also determines what the name of
  4. # the library is. This code sets the following variables:
  5. #
  6. # PYTHON_LIBRARIES = the full path to the library found
  7. # PYTHON_INCLUDE_PATH = the path to where Python.h can be found
  8. # PYTHON_DEBUG_LIBRARIES = the full path to the debug library found
  9. #
  10. INCLUDE(CMakeFindFrameworks)
  11. IF(WIN32)
  12. FIND_LIBRARY(PYTHON_DEBUG_LIBRARY
  13. NAMES python23_d python22_d python21_d python20_d python
  14. PATHS
  15. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]/libs/Debug
  16. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]/libs
  17. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.2\\InstallPath]/libs/Debug
  18. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.2\\InstallPath]/libs
  19. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.1\\InstallPath]/libs/Debug
  20. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.1\\InstallPath]/libs
  21. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.0\\InstallPath]/libs/Debug
  22. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.0\\InstallPath]/libs
  23. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.6\\InstallPath]/libs/Debug
  24. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.6\\InstallPath]/libs
  25. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.5\\InstallPath]/libs/Debug
  26. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.5\\InstallPath]/libs
  27. )
  28. ENDIF(WIN32)
  29. FIND_LIBRARY(PYTHON_LIBRARY
  30. NAMES python23 python2.3 python2.3.dll
  31. python22 python2.2 python2.2.dll
  32. python21 python2.1 python2.1.dll
  33. python20 python2.0 python2.0.dll
  34. python16 python1.6 python1.6.dll
  35. python15 python1.5 python1.5.dll
  36. PATHS
  37. /usr/lib/python2.3/config
  38. /usr/lib/python2.2/config
  39. /usr/lib/python2.1/config
  40. /usr/lib/python2.0/config
  41. /usr/lib/python1.6/config
  42. /usr/lib/python1.5/config
  43. /usr/lib
  44. /usr/local/lib
  45. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]/libs
  46. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.2\\InstallPath]/libs
  47. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.1\\InstallPath]/libs
  48. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.0\\InstallPath]/libs
  49. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.6\\InstallPath]/libs
  50. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.5\\InstallPath]/libs
  51. )
  52. # Search for the python framework on Apple.
  53. CMAKE_FIND_FRAMEWORKS(Python)
  54. SET(PYTHON_FRAMEWORK_INCLUDES)
  55. IF(Python_FRAMEWORKS)
  56. IF(NOT PYTHON_INCLUDE_PATH)
  57. FOREACH(version 2.3 2.2 2.1 2.0 1.6 1.5)
  58. FOREACH(dir ${Python_FRAMEWORKS})
  59. SET(PYTHON_FRAMEWORK_INCLUDES ${PYTHON_FRAMEWORK_INCLUDES}
  60. ${dir}/Versions/${version}/include/python${version})
  61. ENDFOREACH(dir)
  62. ENDFOREACH(version)
  63. ENDIF(NOT PYTHON_INCLUDE_PATH)
  64. ENDIF(Python_FRAMEWORKS)
  65. FIND_PATH(PYTHON_INCLUDE_PATH Python.h
  66. ${PYTHON_FRAMEWORK_INCLUDES}
  67. /usr/include/python2.3
  68. /usr/include/python2.2
  69. /usr/include/python2.1
  70. /usr/include/python2.0
  71. /usr/include/python1.6
  72. /usr/include/python1.5
  73. /usr/include
  74. /usr/local/include
  75. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.3\\InstallPath]/include
  76. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.2\\InstallPath]/include
  77. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.1\\InstallPath]/include
  78. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\2.0\\InstallPath]/include
  79. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.6\\InstallPath]/include
  80. [HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\1.5\\InstallPath]/include
  81. )
  82. IF (WIN32)
  83. MARK_AS_ADVANCED(
  84. PYTHON_DEBUG_LIBRARY
  85. PYTHON_LIBRARY
  86. PYTHON_INCLUDE_PATH
  87. )
  88. ENDIF(WIN32)
  89. # Python Should be built and installed as a Framework on OSX
  90. IF(Python_FRAMEWORKS)
  91. # If a framework has been selected for the include path,
  92. # make sure "-framework" is used to link it.
  93. IF("${PYTHON_INCLUDE_PATH}" MATCHES "Python\\.framework")
  94. SET(PYTHON_LIBRARY "")
  95. SET(PYTHON_DEBUG_LIBRARY "")
  96. ENDIF("${PYTHON_INCLUDE_PATH}" MATCHES "Python\\.framework")
  97. IF(NOT PYTHON_LIBRARY)
  98. SET (PYTHON_LIBRARY "-framework Python" CACHE FILEPATH "Python Framework" FORCE)
  99. ENDIF(NOT PYTHON_LIBRARY)
  100. IF(NOT PYTHON_DEBUG_LIBRARY)
  101. SET (PYTHON_DEBUG_LIBRARY "-framework Python" CACHE FILEPATH "Python Framework" FORCE)
  102. ENDIF(NOT PYTHON_DEBUG_LIBRARY)
  103. ENDIF(Python_FRAMEWORKS)
  104. # We use PYTHON_LIBRARY and PYTHON_DEBUG_LIBRARY for the cache entries
  105. # because they are meant to specify the location of a single library.
  106. # We now set the variables listed by the documentation for this
  107. # module.
  108. SET(PYTHON_LIBRARIES "${PYTHON_LIBRARY}")
  109. SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}")