[Cmake-commits] CMake branch, next, updated. v3.0.0-rc4-2486-g75a5f65

Brad King brad.king at kitware.com
Mon Apr 21 09:24:28 EDT 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  75a5f65072c0b0a038c714eebf2d2d7a58e9ebed (commit)
       via  2c96192f4c09bc9784ac7c483118a818cbf2701e (commit)
       via  e147c5c5558fbb1a6a704173a9a7c71848893ab0 (commit)
      from  4ac46cbf929f392629d5a40d858815d8b0433687 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=75a5f65072c0b0a038c714eebf2d2d7a58e9ebed
commit 75a5f65072c0b0a038c714eebf2d2d7a58e9ebed
Merge: 4ac46cb 2c96192
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Apr 21 09:24:27 2014 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Apr 21 09:24:27 2014 -0400

    Merge topic 'UseSWIG-guess_module_name' into next
    
    2c96192f UseSWIG: Revise and format documentation
    e147c5c5 UseSWIG: Detect module name from interface file (#10080)


http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2c96192f4c09bc9784ac7c483118a818cbf2701e
commit 2c96192f4c09bc9784ac7c483118a818cbf2701e
Author:     Julien Schueller <schueller at phimeca.com>
AuthorDate: Thu Apr 3 08:28:10 2014 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Apr 21 09:23:41 2014 -0400

    UseSWIG: Revise and format documentation
    
    Also add some documentation of SWIG_MODULE_NAME.

diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake
index b694c40..060b44c 100644
--- a/Modules/UseSWIG.cmake
+++ b/Modules/UseSWIG.cmake
@@ -2,9 +2,7 @@
 # UseSWIG
 # -------
 #
-# SWIG module for CMake
-#
-# Defines the following macros:
+# Defines the following macros for use with SWIG:
 #
 # ::
 #
@@ -13,20 +11,38 @@
 #    SWIG_LINK_LIBRARIES(name [ libraries ])
 #      - Link libraries to swig module
 #
-# All other macros are for internal use only.  To get the actual name of
-# the swig module, use: ${SWIG_MODULE_${name}_REAL_NAME}.  Set Source
-# files properties such as CPLUSPLUS and SWIG_FLAGS to specify special
-# behavior of SWIG.  Also global CMAKE_SWIG_FLAGS can be used to add
-# special flags to all swig calls.  Another special variable is
-# CMAKE_SWIG_OUTDIR, it allows one to specify where to write all the
-# swig generated module (swig -outdir option) The name-specific variable
-# SWIG_MODULE_<name>_EXTRA_DEPS may be used to specify extra
-# dependencies for the generated modules.  If the source file generated
-# by swig need some special flag you can use::
+# Source files properties on module files can be set before the invocation
+# of the SWIG_ADD_MODULE macro to specify special behavior of SWIG.
 #
-#   set_source_files_properties( ${swig_generated_file_fullname}
-#         PROPERTIES COMPILE_FLAGS "-bla")
-
+# The source file property CPLUSPLUS calls SWIG in c++ mode, e.g.::
+#
+#    set_property(SOURCE mymod.i PROPERTY CPLUSPLUS ON)
+#    swig_add_module(mymod python mymod.i)
+#
+# The source file property SWIG_FLAGS adds custom flags to the SWIG executable.
+#
+# The source-file property SWIG_MODULE_NAME have to be provided to specify the actual
+# import name of the module in the target language if it cannot be scanned automatically
+# from source or different from the module file basename.::
+#
+#    set_property(SOURCE mymod.i PROPERTY SWIG_MODULE_NAME mymod_realname)
+#
+# To get the name of the swig module target library, use: ${SWIG_MODULE_${name}_REAL_NAME}.
+#
+# Also some variables can be set to specify special behavior of SWIG.
+#
+# CMAKE_SWIG_FLAGS can be used to add special flags to all swig calls.
+#
+# Another special variable is CMAKE_SWIG_OUTDIR, it allows one to specify
+# where to write all the swig generated module (swig -outdir option)
+#
+# The name-specific variable SWIG_MODULE_<name>_EXTRA_DEPS may be used to specify extra
+# dependencies for the generated modules.
+#
+# If the source file generated by swig need some special flag you can use::
+#
+#    set_source_files_properties( ${swig_generated_file_fullname}
+#                                 PROPERTIES COMPILE_FLAGS "-bla")
 
 #=============================================================================
 # Copyright 2004-2009 Kitware, Inc.

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e147c5c5558fbb1a6a704173a9a7c71848893ab0
commit e147c5c5558fbb1a6a704173a9a7c71848893ab0
Author:     Julien Schueller <schueller at phimeca.com>
AuthorDate: Tue Apr 1 12:12:52 2014 +0200
Commit:     Brad King <brad.king at kitware.com>
CommitDate: Mon Apr 21 09:22:57 2014 -0400

    UseSWIG: Detect module name from interface file (#10080)
    
    If no SWIG_MODULE_NAME is specified explicitly and the .i file exists,
    scan it for the module name declaration.

diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake
index 11ca205..b694c40 100644
--- a/Modules/UseSWIG.cmake
+++ b/Modules/UseSWIG.cmake
@@ -86,7 +86,30 @@ macro(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile)
   get_source_file_property(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename
     ${infile} SWIG_MODULE_NAME)
   if(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename STREQUAL "NOTFOUND")
-    get_filename_component(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${infile}" NAME_WE)
+
+    # try to get module name from "%module foo" syntax
+    if ( EXISTS ${infile} )
+      file ( STRINGS ${infile} _MODULE_NAME REGEX "[ ]*%module[ ]*[a-zA-Z0-9_]+.*" )
+    endif ()
+    if ( _MODULE_NAME )
+      string ( REGEX REPLACE "[ ]*%module[ ]*([a-zA-Z0-9_]+).*" "\\1" _MODULE_NAME "${_MODULE_NAME}" )
+      set(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${_MODULE_NAME}")
+
+    else ()
+      # try to get module name from "%module (options=...) foo" syntax
+      if ( EXISTS ${infile} )
+        file ( STRINGS ${infile} _MODULE_NAME REGEX "[ ]*%module[ ]*\\(.*\\)[ ]*[a-zA-Z0-9_]+.*" )
+      endif ()
+      if ( _MODULE_NAME )
+        string ( REGEX REPLACE "[ ]*%module[ ]*\\(.*\\)[ ]*([a-zA-Z0-9_]+).*" "\\1" _MODULE_NAME "${_MODULE_NAME}" )
+        set(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${_MODULE_NAME}")
+
+      else ()
+        # fallback to file basename
+        get_filename_component(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename ${infile} NAME_WE)
+      endif ()
+    endif ()
+
   endif()
   foreach(it ${SWIG_${language}_EXTRA_FILE_EXTENSION})
     set(${outfiles} ${${outfiles}}

-----------------------------------------------------------------------

Summary of changes:


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list