[CMake] UseSWIG creates module instead of shared library, which can't be dynamically loaded

Stephen Roderick kiwi.net at mac.com
Wed Aug 5 12:55:57 EDT 2009


The existing UseSWIG.cmake file creates a MODULE and not a SHARED  
library. The module is unuseable by any program trying to load dynamic  
libraries (eg wrapped Java). The attached patch fixes this problem for  
our situations. Demonstrated on both Mac OS X Leopard and Ubuntu Jaunty.

Is this a known issue? I searched what I could of the list and the  
'net, and couldn't find anything on this.
Stephen

<code>
-- UseSWIG.cmake-save	2009-03-19 16:04:20.000000000 -0400
+++ UseSWIG.cmake	2009-03-19 16:04:44.000000000 -0400
@@ -33,7 +33,7 @@
      MESSAGE(FATAL_ERROR "SWIG Error: Language \"${language}\" not  
found")
    ENDIF("x${SWIG_MODULE_${name}_LANGUAGE}x" MATCHES "^xUNKNOWNx$")

-  SET(SWIG_MODULE_${name}_REAL_NAME "${name}")
+  SET(SWIG_MODULE_${name}_REAL_NAME "lib${name}")
    IF("x${SWIG_MODULE_${name}_LANGUAGE}x" MATCHES "^xPYTHONx$")
      SET(SWIG_MODULE_${name}_REAL_NAME "_${name}")
    ENDIF("x${SWIG_MODULE_${name}_LANGUAGE}x" MATCHES "^xPYTHONx$")
@@ -187,7 +187,7 @@
    SET_DIRECTORY_PROPERTIES(PROPERTIES
      ADDITIONAL_MAKE_CLEAN_FILES "${swig_extra_clean_files};$ 
{swig_generated_sources}")
    ADD_LIBRARY(${SWIG_MODULE_${name}_REAL_NAME}
-    MODULE
+    SHARED
      ${swig_generated_sources}
      ${swig_other_sources})
    SET_TARGET_PROPERTIES(${SWIG_MODULE_${name}_REAL_NAME}
</code>



More information about the CMake mailing list