diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake index b3edd925d..b7c7a6909 100644 --- a/Modules/FindPythonLibs.cmake +++ b/Modules/FindPythonLibs.cmake @@ -85,6 +85,14 @@ SET(PYTHON_DEBUG_LIBRARIES "${PYTHON_DEBUG_LIBRARY}") INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs PYTHON_LIBRARIES PYTHON_INCLUDE_PATH) + +GET_TARGET_PROPERTIES(_FIND_PYTHONLIBS_ALREADY_INCLUDED __FindPythonLibsHelper TYPE) +IF(NOT _FIND_PYTHONLIBS_ALREADY_INCLUDED) + ADD_CUSTOM_TARGET(__FindPythonLibsHelper) # so if this file is included several times the next time GET_TARGET_PROPERTIES() will work + SET(PY_STATIC_MODULES_LIST "" CACHE STRING "Collect a list of all added static python modules" FORCE) + SET(PY_MODULES_LIST "" CACHE STRING "Collect a list of all added python modules" FORCE) +ENDIF(NOT _FIND_PYTHONLIBS_ALREADY_INCLUDED) + MACRO(PYTHON_ADD_MODULE _NAME ) OPTION(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE) @@ -94,10 +102,10 @@ MACRO(PYTHON_ADD_MODULE _NAME ) SET(PY_MODULE_TYPE MODULE) ELSE(PYTHON_MODULE_${_NAME}_SHARED) SET(PY_MODULE_TYPE STATIC) - SET(PY_STATIC_MODULES_LIST ${PY_STATIC_MODULES_LIST} ${_NAME}) + 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) - SET(PY_MODULES_LIST ${PY_MODULES_LIST} ${_NAME}) + 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}) # TARGET_LINK_LIBRARIES(${_NAME} ${PYTHON_LIBRARIES}) ENDIF(PYTHON_ENABLE_MODULE_${_NAME})