FindPythonLibs.cmake 5.3 KB

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