From 7e9eed0230cf2ba8b86bcf76e1c78bb23fa8b82e Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Wed, 25 Jul 2007 15:08:37 -0400 Subject: COMP: same as in VTK, build modules by default as shared if the platform supports this, don't include shared modules in the generated header Alex --- Modules/FindPythonLibs.cmake | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index 4dff4db..029d0fd 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -93,17 +93,19 @@ IF(NOT _FIND_PYTHONLIBS_ALREADY_INCLUDED) SET(PY_MODULES_LIST "" CACHE STRING "Collect a list of all added python modules" FORCE) ENDIF(NOT _FIND_PYTHONLIBS_ALREADY_INCLUDED) +GET_PROPERTY(_TARGET_SUPPORTS_SHARED_LIBS GLOBAL TARGET_SUPPORTS_SHARED_LIBS) + MACRO(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}) IF(PYTHON_ENABLE_MODULE_${_NAME}) - OPTION(PYTHON_MODULE_${_NAME}_SHARED "Add module ${_NAME} shared" FALSE) - IF(PYTHON_MODULE_${_NAME}_SHARED) + IF(PYTHON_MODULE_${_NAME}_BUILD_SHARED) SET(PY_MODULE_TYPE MODULE) - ELSE(PYTHON_MODULE_${_NAME}_SHARED) + ELSE(PYTHON_MODULE_${_NAME}_BUILD_SHARED) SET(PY_MODULE_TYPE STATIC) SET(PY_STATIC_MODULES_LIST ${PY_STATIC_MODULES_LIST} ${_NAME} CACHE STRING "Collect a list of all added static python modules" FORCE) - ENDIF(PYTHON_MODULE_${_NAME}_SHARED) + ENDIF(PYTHON_MODULE_${_NAME}_BUILD_SHARED) SET(PY_MODULES_LIST ${PY_MODULES_LIST} ${_NAME} CACHE STRING "Collect a list of all added python modules" FORCE) ADD_LIBRARY(${_NAME} ${PY_MODULE_TYPE} ${ARGN}) @@ -120,13 +122,13 @@ MACRO(PYTHON_WRITE_MODULES_HEADER _filename) FILE(APPEND ${_filename} "#define ${_name}\n\n") FILE(APPEND ${_filename} "#include \n\n") - FOREACH(_currentModule ${PY_MODULES_LIST}) + FOREACH(_currentModule ${PY_STATIC_MODULES_LIST}) FILE(APPEND ${_filename} "extern void init${_currentModule}(void);\n\n") - ENDFOREACH(_currentModule ${PY_MODULES_LIST}) + ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST}) - FOREACH(_currentModule ${PY_MODULES_LIST}) + FOREACH(_currentModule ${PY_STATIC_MODULES_LIST}) FILE(APPEND ${_filename} "int CMakeLoadPythonModule_${_currentModule}(void) \n{\n return PyImport_AppendInittab(\"${_currentModule}\", init${_currentModule});\n}\n\n") - ENDFOREACH(_currentModule ${PY_MODULES_LIST}) + ENDFOREACH(_currentModule ${PY_STATIC_MODULES_LIST}) FILE(APPEND ${_filename} "#ifndef EXCLUDE_LOAD_ALL_FUNCTION\nvoid CMakeLoadAllPythonModules(void)\n{\n") FOREACH(_currentModule ${PY_STATIC_MODULES_LIST}) -- cgit v0.12