~ubuntu-branches/ubuntu/trusty/avogadro/trusty-proposed

« back to all changes in this revision

Viewing changes to cmake/modules/FindPythonLibs.cmake

  • Committer: Bazaar Package Importer
  • Author(s): Rohan Garg
  • Date: 2011-05-20 18:55:49 UTC
  • mfrom: (3.2.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110520185549-berzu8h9f9330xji
Tags: 1.0.3-1ubuntu1
* Merge from debian, remaining changes (LP: #787458, #784267)
  - Disable builds for ARM as build dependency on libOpenGL and 
    libQtOpenGL

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
# include files and libraries are. It also determines what the name of
4
4
# the library is. This code sets the following variables:
5
5
#
6
 
#  PYTHONLIBS_FOUND       - have the Python libs been found
7
 
#  PYTHON_LIBRARIES       - path to the python library
8
 
#  PYTHON_INCLUDE_PATH    - path to where Python.h is found (deprecated)
9
 
#  PYTHON_INCLUDE_DIRS    - path to where Python.h is found
10
 
#  PYTHON_DEBUG_LIBRARIES - path to the debug library
11
 
#
 
6
#  PYTHONLIBS_FOUND           - have the Python libs been found
 
7
#  PYTHON_LIBRARIES           - path to the python library
 
8
#  PYTHON_INCLUDE_PATH        - path to where Python.h is found (deprecated)
 
9
#  PYTHON_INCLUDE_DIRS        - path to where Python.h is found
 
10
#  PYTHON_DEBUG_LIBRARIES     - path to the debug library
 
11
#  Python_ADDITIONAL_VERSIONS - list of additional Python versions to search for
12
12
 
13
13
#=============================================================================
14
14
# Copyright 2001-2009 Kitware, Inc.
20
20
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21
21
# See the License for more information.
22
22
#=============================================================================
23
 
# (To distributed this file outside of CMake, substitute the full
 
23
# (To distribute this file outside of CMake, substitute the full
24
24
#  License text for the above reference.)
25
25
 
26
26
INCLUDE(CMakeFindFrameworks)
27
27
# Search for the python framework on Apple.
28
28
CMAKE_FIND_FRAMEWORKS(Python)
29
29
 
30
 
FOREACH(_CURRENT_VERSION 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5)
 
30
# Set up the versions we know about, in the order we will search. Always add
 
31
# the user supplied additional versions to the front.
 
32
set(_Python_VERSIONS
 
33
  ${Python_ADDITIONAL_VERSIONS}
 
34
  2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5)
 
35
 
 
36
FOREACH(_CURRENT_VERSION ${_Python_VERSIONS})
31
37
  STRING(REPLACE "." "" _CURRENT_VERSION_NO_DOTS ${_CURRENT_VERSION})
32
38
  IF(WIN32)
33
39
    FIND_LIBRARY(PYTHON_DEBUG_LIBRARY
53
59
    PATH_SUFFIXES python${_CURRENT_VERSION}/config
54
60
  )
55
61
 
56
 
  # For backward compatibility, honour value of PYTHON_INCLUDE_PATH, if 
 
62
  # For backward compatibility, honour value of PYTHON_INCLUDE_PATH, if
57
63
  # PYTHON_INCLUDE_DIR is not set.
58
64
  IF(DEFINED PYTHON_INCLUDE_PATH AND NOT DEFINED PYTHON_INCLUDE_DIR)
59
65
    SET(PYTHON_INCLUDE_DIR "${PYTHON_INCLUDE_PATH}" CACHE PATH
78
84
  )
79
85
 
80
86
  # For backward compatibility, set PYTHON_INCLUDE_PATH, but make it internal.
81
 
  SET(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}" CACHE INTERNAL 
 
87
  SET(PYTHON_INCLUDE_PATH "${PYTHON_INCLUDE_DIR}" CACHE INTERNAL
82
88
    "Path to where Python.h is found (deprecated)")
83
 
  
 
89
 
84
90
ENDFOREACH(_CURRENT_VERSION)
85
91
 
86
92
MARK_AS_ADVANCED(
103
109
 
104
110
 
105
111
# PYTHON_ADD_MODULE(<name> src1 src2 ... srcN) is used to build modules for python.
106
 
# PYTHON_WRITE_MODULES_HEADER(<filename>) writes a header file you can include 
 
112
# PYTHON_WRITE_MODULES_HEADER(<filename>) writes a header file you can include
107
113
# in your sources to initialize the static python modules
108
 
 
109
 
GET_PROPERTY(_TARGET_SUPPORTS_SHARED_LIBS
110
 
  GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
111
 
 
112
114
FUNCTION(PYTHON_ADD_MODULE _NAME )
 
115
  GET_PROPERTY(_TARGET_SUPPORTS_SHARED_LIBS
 
116
    GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
113
117
  OPTION(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE)
114
118
  OPTION(PYTHON_MODULE_${_NAME}_BUILD_SHARED
115
119
    "Add module ${_NAME} shared" ${_TARGET_SUPPORTS_SHARED_LIBS})
130
134
    ADD_LIBRARY(${_NAME} ${PY_MODULE_TYPE} ${ARGN})
131
135
#    TARGET_LINK_LIBRARIES(${_NAME} ${PYTHON_LIBRARIES})
132
136
 
 
137
    IF(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
 
138
      SET_TARGET_PROPERTIES(${_NAME} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}")
 
139
      IF(WIN32 AND NOT CYGWIN)
 
140
        SET_TARGET_PROPERTIES(${_NAME} PROPERTIES SUFFIX ".pyd")
 
141
      ENDIF(WIN32 AND NOT CYGWIN)
 
142
    ENDIF(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
 
143
 
133
144
  ENDIF(PYTHON_ENABLE_MODULE_${_NAME})
134
145
ENDFUNCTION(PYTHON_ADD_MODULE)
135
146
 
140
151
  GET_FILENAME_COMPONENT(_name "${_filename}" NAME)
141
152
  STRING(REPLACE "." "_" _name "${_name}")
142
153
  STRING(TOUPPER ${_name} _nameUpper)
 
154
  SET(_filename ${CMAKE_CURRENT_BINARY_DIR}/${_filename})
143
155
 
144
156
  SET(_filenameTmp "${_filename}.in")
145
157
  FILE(WRITE ${_filenameTmp} "/*Created by cmake, do not edit, changes will be lost*/\n")
146
 
  FILE(APPEND ${_filenameTmp} 
 
158
  FILE(APPEND ${_filenameTmp}
147
159
"#ifndef ${_nameUpper}
148
160
#define ${_nameUpper}
149
161
 
159
171
    FILE(APPEND ${_filenameTmp} "extern void init${PYTHON_MODULE_PREFIX}${_currentModule}(void);\n\n")
160
172
  ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
161
173
 
162
 
  FILE(APPEND ${_filenameTmp} 
 
174
  FILE(APPEND ${_filenameTmp}
163
175
"#ifdef __cplusplus
164
176
}
165
177
#endif /* __cplusplus */
177
189
  ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
178
190
  FILE(APPEND ${_filenameTmp} "}\n\n")
179
191
  FILE(APPEND ${_filenameTmp} "#ifndef EXCLUDE_LOAD_ALL_FUNCTION\nvoid CMakeLoadAllPythonModules(void)\n{\n  ${_name}_LoadAllPythonModules();\n}\n#endif\n\n#endif\n")
180
 
  
 
192
 
181
193
# with CONFIGURE_FILE() cmake complains that you may not use a file created using FILE(WRITE) as input file for CONFIGURE_FILE()
182
194
  EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_filenameTmp}" "${_filename}" OUTPUT_QUIET ERROR_QUIET)
183
195