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
This commit is contained in:
parent
9c2d6f98d7
commit
7e9eed0230
|
@ -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 <Python.h>\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})
|
||||
|
|
Loading…
Reference in New Issue