FindPythonLibs.cmake 5.1 KB

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