[cmake-commits] alex committed FindPythonLibs.cmake 1.41 1.42

cmake-commits at cmake.org cmake-commits at cmake.org
Fri Feb 15 18:26:39 EST 2008


Update of /cvsroot/CMake/CMake/Modules
In directory public:/mounts/ram/cvs-serv24016

Modified Files:
	FindPythonLibs.cmake 
Log Message:
STYLE: use global property instead of helper target to collect all python
modules from a source tree

Alex


Index: FindPythonLibs.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/FindPythonLibs.cmake,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- FindPythonLibs.cmake	17 Jan 2008 22:19:13 -0000	1.41
+++ FindPythonLibs.cmake	15 Feb 2008 23:26:37 -0000	1.42
@@ -86,17 +86,14 @@
 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 @@
       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 @@
 # 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)



More information about the Cmake-commits mailing list