summaryrefslogtreecommitdiffstats
path: root/Modules/FindPythonLibs.cmake
diff options
context:
space:
mode:
authorMarcus Hanwell <marcus.hanwell@kitware.com>2010-02-17 16:37:37 (GMT)
committerMarcus Hanwell <marcus.hanwell@kitware.com>2010-02-17 16:37:37 (GMT)
commitf7a3db6403b49525da22e8da0dc4a5b9dc08f0e4 (patch)
treead0ddcab5b6e5813d332b6a5fd71107aeb053ac7 /Modules/FindPythonLibs.cmake
parent8d87d12ce67aea8bf9dbbdb605e3487c736d0ac6 (diff)
downloadCMake-f7a3db6403b49525da22e8da0dc4a5b9dc08f0e4.zip
CMake-f7a3db6403b49525da22e8da0dc4a5b9dc08f0e4.tar.gz
CMake-f7a3db6403b49525da22e8da0dc4a5b9dc08f0e4.tar.bz2
Applied patch from Pat Marion - modules header macro.
This modifies the behavior of PYTHON_WRITE_MODULES_HEADER, should be backwards compatible. Also marked a couple of the variables generated by adding Python modules as advanced.
Diffstat (limited to 'Modules/FindPythonLibs.cmake')
-rw-r--r--Modules/FindPythonLibs.cmake18
1 files changed, 12 insertions, 6 deletions
diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake
index 4d3429d..951e48c 100644
--- a/Modules/FindPythonLibs.cmake
+++ b/Modules/FindPythonLibs.cmake
@@ -111,7 +111,12 @@ GET_PROPERTY(_TARGET_SUPPORTS_SHARED_LIBS
FUNCTION(PYTHON_ADD_MODULE _NAME )
OPTION(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE)
- OPTION(PYTHON_MODULE_${_NAME}_BUILD_SHARED "Add module ${_NAME} shared" ${_TARGET_SUPPORTS_SHARED_LIBS})
+ OPTION(PYTHON_MODULE_${_NAME}_BUILD_SHARED
+ "Add module ${_NAME} shared" ${_TARGET_SUPPORTS_SHARED_LIBS})
+
+ # Mark these options as advanced
+ MARK_AS_ADVANCED(PYTHON_ENABLE_MODULE_${_NAME}
+ PYTHON_MODULE_${_NAME}_BUILD_SHARED)
IF(PYTHON_ENABLE_MODULE_${_NAME})
IF(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
@@ -134,13 +139,13 @@ FUNCTION(PYTHON_WRITE_MODULES_HEADER _filename)
GET_FILENAME_COMPONENT(_name "${_filename}" NAME)
STRING(REPLACE "." "_" _name "${_name}")
- STRING(TOUPPER ${_name} _name)
+ STRING(TOUPPER ${_name} _nameUpper)
SET(_filenameTmp "${_filename}.in")
FILE(WRITE ${_filenameTmp} "/*Created by cmake, do not edit, changes will be lost*/\n")
FILE(APPEND ${_filenameTmp}
-"#ifndef ${_name}
-#define ${_name}
+"#ifndef ${_nameUpper}
+#define ${_nameUpper}
#include <Python.h>
@@ -166,11 +171,12 @@ extern \"C\" {
FILE(APPEND ${_filenameTmp} "int CMakeLoadPythonModule_${_currentModule}(void) \n{\n static char name[]=\"${PYTHON_MODULE_PREFIX}${_currentModule}\"; return PyImport_AppendInittab(name, init${PYTHON_MODULE_PREFIX}${_currentModule});\n}\n\n")
ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
- FILE(APPEND ${_filenameTmp} "#ifndef EXCLUDE_LOAD_ALL_FUNCTION\nvoid CMakeLoadAllPythonModules(void)\n{\n")
+ FILE(APPEND ${_filenameTmp} "void ${_name}_LoadAllPythonModules(void)\n{\n")
FOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
FILE(APPEND ${_filenameTmp} " CMakeLoadPythonModule_${_currentModule}();\n")
ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST})
- FILE(APPEND ${_filenameTmp} "}\n#endif\n\n#endif\n")
+ FILE(APPEND ${_filenameTmp} "}\n\n")
+ FILE(APPEND ${_filenameTmp} "#ifndef EXCLUDE_LOAD_ALL_FUNCTION\nvoid CMakeLoadAllPythonModules(void)\n{\n ${_name}_LoadAllPythonModules();\n}\n#endif\n\n#endif\n")
# with CONFIGURE_FILE() cmake complains that you may not use a file created using FILE(WRITE) as input file for CONFIGURE_FILE()
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_filenameTmp}" "${_filename}" OUTPUT_QUIET ERROR_QUIET)