View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0007915 | CMake | Modules | public | 2008-11-02 07:43 | 2009-10-30 11:08 | ||||
Reporter | J. Bedouet | ||||||||
Assigned To | Mathieu Malaterre | ||||||||
Priority | normal | Severity | feature | Reproducibility | N/A | ||||
Status | closed | Resolution | fixed | ||||||
Platform | OS | OS Version | |||||||
Product Version | CMake-2-6 | ||||||||
Target Version | Fixed in Version | ||||||||
Summary | 0007915: Patch proposal for UseSWIG.cmake | ||||||||
Description | I have used module UseSWIG.cmake for a long time but each time I want to generate a SWIG library for Java, I must write the same lines to include this module : - create the SWIG output directory - change prefix and suffix of the SWIG library I think these lines could be integrated in the module UseSWIG.cmake. | ||||||||
Additional Information | This patch allows to - create the directory ${swig_outdir} before running the swig command. Swig doesn't create the output directory and sends an error if it doesn't exist. - for language Java, leave default prefix (lib under Unix, no lib under windows). It respects the convention for JNI library names. - for language Java and MacOS platform, set suffix to .jnilib. It respects the convention for JNI library names. The default suffix .so doesn't work. There is no incompatibility with older versions. This patch just sets more convenient values. | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | ![]() | ||||||||
Relationships | |
Relationships |
Notes | |
(0014013) Mathieu Malaterre (developer) 2008-11-03 05:14 |
Judicael, Are you sure about those: ! IF ("${language}" STREQUAL "java") ! IF (APPLE) ! SET_TARGET_PROPERTIES (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".jnilib") ! ENDIF (APPLE) ! ELSE ("${language}" STREQUAL "java") ! SET_TARGET_PROPERTIES(${SWIG_MODULE_${name}_REAL_NAME} ! PROPERTIES PREFIX "") ! ENDIF ("${language}" STREQUAL "java") I think you got the second ELSE statement wrong. More like: ! IF ("${language}" STREQUAL "java") ! IF (APPLE) ! SET_TARGET_PROPERTIES (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".jnilib") ! ELSE (APPLE) ! SET_TARGET_PROPERTIES(${SWIG_MODULE_${name}_REAL_NAME} ! PROPERTIES PREFIX "") ! ENDIF (APPLE) ! ENDIF ("${language}" STREQUAL "java") BTW, unified diff are a *lot* readable: $ cvs di -u thank you. |
(0014014) Robert Haines (reporter) 2008-11-03 05:44 |
I've been using UseSWIG a lot recently too and have noticed a couple of things. Firstly, you are right about the java library name not being correct as a .so on MacOS but I've never come across .jnilib as an alternative. Also, .so is incorrect for Perl libraries as well on MacOS. This lead me to think that the libraries should be compiled as SHARED not MODULE which solves the problem. In Python though it must still be compiled as MODULE. When compiled as SHARED the libraries get a .dylib name on MacOS and this works. I wonder if the naming issue is just covering up the fact that on MacOS the libraries should be SHARED rather than MODULE for Java and Perl? Not sure about languages other than Java, Perl and Python. +1 for creating the ${swig_outdir} directory from me. |
(0014016) J. Bedouet (reporter) 2008-11-03 08:08 |
I'm pretty sure. It works for me under MacOS (UNIX Makefiles), Linux (UNIX Makefiles) and Windows (Visual Studio 7). Your lines don't work under Linux: prefix must be lib. See my comments below. Do you agree ? IF ("${language}" STREQUAL "java") IF (APPLE) # Under Apple, suffix must be .jnilib (or .dylib according to rhaines) SET_TARGET_PROPERTIES (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".jnilib") ENDIF (APPLE) # For language Java, I leave default module prefix # (lib under MacOs or Linux, no lib under Windows) ELSE ("${language}" STREQUAL "java") # Since I don't know how name conventions work for other languages, # I leave old behaviour, where prefix was systematically set to "". # Maybe rhaines knows about Perl and Python. SET_TARGET_PROPERTIES(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") ENDIF ("${language}" STREQUAL "java") >> BTW, unified diff are a *lot* readable Sorry about the format of my patch. I tried to make a patch which could be used by patch command. Rhaines, I agree with you about MODULE (at least for Java). I have also comments about MODULE in the mailing list. See this http://www.cmake.org/pipermail/cmake/2008-November/024978.html [^] |
(0018291) Mathieu Malaterre (developer) 2009-10-30 11:07 |
Here is my proposed changes: $ cvs di UseSWIG.cmake Index: UseSWIG.cmake =================================================================== RCS file: /cvsroot/CMake/CMake/Modules/UseSWIG.cmake,v retrieving revision 1.18 diff -u -r1.18 UseSWIG.cmake --- UseSWIG.cmake 28 Sep 2009 15:46:51 -0000 1.18 +++ UseSWIG.cmake 30 Oct 2009 15:03:51 -0000 @@ -48,6 +48,9 @@ SET(SWIG_MODULE_${name}_REAL_NAME "${name}") IF("x${SWIG_MODULE_${name}_LANGUAGE}x" MATCHES "^xPYTHONx$") + # when swig is used without the -interface it will produce in the module.py + # a 'import _modulename' statement, which implies having a corresponding + # _modulename.so (*NIX), _modulename.pyd (Win32). SET(SWIG_MODULE_${name}_REAL_NAME "_${name}") ENDIF("x${SWIG_MODULE_${name}_LANGUAGE}x" MATCHES "^xPYTHONx$") IF("x${SWIG_MODULE_${name}_LANGUAGE}x" MATCHES "^xPERLx$") @@ -117,6 +120,8 @@ # If CMAKE_SWIG_OUTDIR was specified then pass it to -outdir IF(CMAKE_SWIG_OUTDIR) SET(swig_outdir ${CMAKE_SWIG_OUTDIR}) + # it may not exist, so create it: + file(MAKE_DIRECTORY ${CMAKE_SWIG_OUTDIR}) ELSE(CMAKE_SWIG_OUTDIR) SET(swig_outdir ${CMAKE_CURRENT_BINARY_DIR}) ENDIF(CMAKE_SWIG_OUTDIR) @@ -203,8 +208,33 @@ MODULE ${swig_generated_sources} ${swig_other_sources}) - SET_TARGET_PROPERTIES(${SWIG_MODULE_${name}_REAL_NAME} - PROPERTIES PREFIX "") + STRING(TOLOWER "${language}" swig_lowercase_language) + IF ("${swig_lowercase_language}" STREQUAL "java") + IF (APPLE) + # In java you want: + # System.loadLibrary("LIBRARY"); + # then JNI will look for a library whose name is platform dependent, namely + # MacOS : libLIBRARY.jnilib + # Windows: LIBRARY.dll + # Linux : libLIBRARY.so + SET_TARGET_PROPERTIES (${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".jnilib") + ENDIF (APPLE) + ENDIF ("${swig_lowercase_language}" STREQUAL "java") + IF ("${swig_lowercase_language}" STREQUAL "python") + # this is only needed for the python case where a _modulename.so is generated + SET_TARGET_PROPERTIES(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "") + # Python extension modules on Windows must have the extension ".pyd" + # instead of ".dll" as of Python 2.5. Older python versions do support + # this suffix. + # http://docs.python.org/whatsnew/ports.html#SECTION0001510000000000000000 [^] + # <quote> + # Windows: .dll is no longer supported as a filename extension for extension modules. + # .pyd is now the only filename extension that will be searched for. + # </quote> + IF(WIN32 AND NOT CYGWIN) + SET_TARGET_PROPERTIES(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES SUFFIX ".pyd") + ENDIF(WIN32 AND NOT CYGWIN) + ENDIF ("${swig_lowercase_language}" STREQUAL "python") ENDMACRO(SWIG_ADD_MODULE) # |
(0018292) Mathieu Malaterre (developer) 2009-10-30 11:08 |
$ cvs ci -m"FIX: BUG: 0007915 Integrate portion of the patch. Also add .pyd support for python module. " UseSWIG.cmake Committer: Mathieu Malaterre <mathieu.malaterre@kitware.com> /cvsroot/CMake/CMake/Modules/UseSWIG.cmake,v <-- UseSWIG.cmake new revision: 1.19; previous revision: 1.18 |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2008-11-02 07:43 | J. Bedouet | New Issue | |
2008-11-02 07:43 | J. Bedouet | File Added: UseSWIG.cmake.patch.2.6.2 | |
2008-11-03 05:14 | Mathieu Malaterre | Note Added: 0014013 | |
2008-11-03 05:44 | Robert Haines | Note Added: 0014014 | |
2008-11-03 08:08 | J. Bedouet | Note Added: 0014016 | |
2009-01-07 14:27 | Bill Hoffman | Status | new => assigned |
2009-01-07 14:27 | Bill Hoffman | Assigned To | => Mathieu Malaterre |
2009-10-30 11:07 | Mathieu Malaterre | Note Added: 0018291 | |
2009-10-30 11:08 | Mathieu Malaterre | Note Added: 0018292 | |
2009-10-30 11:08 | Mathieu Malaterre | Status | assigned => closed |
2009-10-30 11:08 | Mathieu Malaterre | Resolution | open => fixed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |