FindPythonLibs.cmake 5.0 KB

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