summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2008-02-15 23:26:37 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2008-02-15 23:26:37 (GMT)
commita8f493686a51e736429ffb3e11838b696f94fa99 (patch)
treef3389d2b91e67d519ca1be5f7fc544f5d56c7cfd /Modules
parentcdb193c77ac656624422daa41e6cfab25518441b (diff)
downloadCMake-a8f493686a51e736429ffb3e11838b696f94fa99.zip
CMake-a8f493686a51e736429ffb3e11838b696f94fa99.tar.gz
CMake-a8f493686a51e736429ffb3e11838b696f94fa99.tar.bz2
STYLE: use global property instead of helper target to collect all python
modules from a source tree Alex
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FindPythonLibs.cmake25
1 files changed, 13 insertions, 12 deletions
diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake
index 698b674..ab33792 100644
--- a/Modules/FindPythonLibs.cmake
+++ b/Modules/FindPythonLibs.cmake
@@ -86,17 +86,14 @@ INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PythonLibs DEFAULT_MSG PYTHON_LIBRARIES PYTHON_INCLUDE_PATH)
-GET_TARGET_PROPERTY(_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)
+# PYTHON_ADD_MODULE(<name> src1 src2 ... srcN) is used to build modules for python.
+# PYTHON_WRITE_MODULES_HEADER(<filename>) writes a header file you can include
+# in your sources to initialize the static python modules
GET_PROPERTY(_TARGET_SUPPORTS_SHARED_LIBS
GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
-MACRO(PYTHON_ADD_MODULE _NAME )
+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})
@@ -105,16 +102,20 @@ MACRO(PYTHON_ADD_MODULE _NAME )
SET(PY_MODULE_TYPE MODULE)
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)
+ SET_PROPERTY(GLOBAL APPEND PROPERTY PY_STATIC_MODULES_LIST ${_NAME})
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)
+ SET_PROPERTY(GLOBAL APPEND PROPERTY PY_MODULES_LIST ${_NAME})
ADD_LIBRARY(${_NAME} ${PY_MODULE_TYPE} ${ARGN})
# TARGET_LINK_LIBRARIES(${_NAME} ${PYTHON_LIBRARIES})
+
ENDIF(PYTHON_ENABLE_MODULE_${_NAME})
-ENDMACRO(PYTHON_ADD_MODULE)
+ENDFUNCTION(PYTHON_ADD_MODULE)
+
+FUNCTION(PYTHON_WRITE_MODULES_HEADER _filename)
+
+ GET_PROPERTY(PY_STATIC_MODULES_LIST GLOBAL PROPERTY PY_STATIC_MODULES_LIST)
-MACRO(PYTHON_WRITE_MODULES_HEADER _filename)
GET_FILENAME_COMPONENT(_name "${_filename}" NAME)
STRING(REPLACE "." "_" _name "${_name}")
STRING(TOUPPER ${_name} _name)
@@ -158,4 +159,4 @@ extern \"C\" {
# 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)
-ENDMACRO(PYTHON_WRITE_MODULES_HEADER)
+ENDFUNCTION(PYTHON_WRITE_MODULES_HEADER)