[cmake-developers] [PATCH] Don't generate erroneous outputs with -noproxy.

Ben Webb ben at salilab.org
Fri Sep 4 17:33:37 EDT 2015


Generally for a module foo, SWIG generates (in Python mode)
an extension module _foo.so and a proxy Python module foo.py.
However, if -noproxy is specified, instead it builds only foo.so
(without the leading underscore). The custom command generated
by CMake correctly handles the removal of this underscore when
-noproxy is given; however, it still adds foo.py to the expected
outputs. This upsets build tools that expect foo.py to be generated
(for example, 'make' will run the SWIG command twice). Fix this
by removing foo.py from the set of extra generated files when
-noproxy is specified.
---
 Modules/UseSWIG.cmake | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake
index 96b0b35..d757f65 100644
--- a/Modules/UseSWIG.cmake
+++ b/Modules/UseSWIG.cmake
@@ -153,10 +153,12 @@ macro(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
   else()
     set(swig_outdir ${CMAKE_CURRENT_BINARY_DIR})
   endif()
-  SWIG_GET_EXTRA_OUTPUT_FILES(${SWIG_MODULE_${name}_LANGUAGE}
-    swig_extra_generated_files
-    "${swig_outdir}"
-    "${swig_source_file_fullname}")
+  if (NOT SWIG_MODULE_${name}_NOPROXY)
+    SWIG_GET_EXTRA_OUTPUT_FILES(${SWIG_MODULE_${name}_LANGUAGE}
+      swig_extra_generated_files
+      "${swig_outdir}"
+      "${swig_source_file_fullname}")
+  endif()
   set(swig_generated_file_fullname
     "${swig_outdir}/${swig_source_file_name_we}")
   # add the language into the name of the file (i.e. TCL_wrap)
-- 
2.3.2 (Apple Git-55)



More information about the cmake-developers mailing list