FindPythonLibs.cmake 5.4 KB

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