[CMake] CMake + SWIG
Hallo everybody, may I have two more simple questions about CMake and SWIG module? The first is connected to the setting of SWIG parameters - when I create wrapper for Java, I need to set -package to SWIG. It is impossible to set is as: SET_SOURCE_FILES_PROPERTIES( ErisJava.i PROPERTIES SWIG_FLAGS "-package my_package" ) as it is replaced by "-package\ my_package" in the call of SWIG. Moreover, it overwrites all previous definitions of "PROPERTIES SWIG_FLAGS". There is possibility of using: SET(CMAKE_SWIG_FLAGS "-package my_package") but if I understand it well, it swithes this parameter globally, for all swig calls (also when wrapping e.g. python). So, how to deal with this? Is there another way or is the second way correct? == The second question is about "cmake -E copy" command. I have notices that the use of wildcards is not possible in this command (event not documented?) - I need to copy all generated Java wrappign classes, but I cannot use the command "cmake -E copy source_dir/*.java destin_dir". I have solved it by "cmake -E chdir dir comand", but I have completely lost the platform independence. I want kindly to ask you, if it would be possible to add support for wildcards in the "cmake -E copy" command (or mabye to the others as well?) - it will extend the abilities of the cmake while still be platform independent. Or can it be solved in another way? I use CMake 2.2-1-beta (compiled by gentoo distro). Thank you very much for your help. Dan --- P.S. I am really sorry for the previous post, I forget to fill the subject :-( ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
[CMake] CMake SWIG module
Hi, I'd like to become the new maintainer of the swig module in cmake. I have not heard back from Tristan Carel. I have updated my name on : http://www.cmake.org/Wiki/CMake:Module_Maintainers Thank you, -- Mathieu ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
[CMake] cmake swig R
Dear all, Anybody has a template file (CMakeLists.txt) to use swig create R wrapper and compile a c++ library for R package? (The c++ library includes several subdirecotories). Thank you, Shenghua Li ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] CMake + SWIG
Daniel Tihelka wrote: > Hallo everybody, > > may I have two more simple questions about CMake and SWIG module? > > The first is connected to the setting of SWIG parameters - when I create > wrapper for Java, I need to set -package to SWIG. > > It is impossible to set is as: > > SET_SOURCE_FILES_PROPERTIES( ErisJava.i PROPERTIES SWIG_FLAGS "-package > my_package" ) > > as it is replaced by "-package\ my_package" in the call of SWIG. Moreover, it > overwrites all previous definitions of "PROPERTIES SWIG_FLAGS". You can use GET_SOURCE_FILE_PROPERTY to get the old value and then append. Add the two options with a semicolon to separate them: ... SWIG_FLAGS "-package;my_package" ... to make sure they are passed as separate arguments. Basically the property contains a CMake list of options, and CMake lists are semicolon separated strings. > There is possibility of using: > > SET(CMAKE_SWIG_FLAGS "-package my_package") > > but if I understand it well, it swithes this parameter globally, for all swig > calls (also when wrapping e.g. python). So, how to deal with this? Is there > another way or is the second way correct? You can set this variable before each call to SWIG_ADD_MODULE and unset it afterwards. > The second question is about "cmake -E copy" command. I have notices that the > use of wildcards is not possible in this command (event not documented?) - I > need to copy all generated Java wrappign classes, but I cannot use the > command "cmake -E copy source_dir/*.java destin_dir". I have solved it by > "cmake -E chdir dir comand", but I have completely lost the platform > independence. > > I want kindly to ask you, if it would be possible to add support for > wildcards in the "cmake -E copy" command (or mabye to the others as well?) - > it will extend the abilities of the cmake while still be platform > independent. Or can it be solved in another way? You can use "cmake -P myscript.cmake" to run a CMake script in place of this command. The script could use FILE(GLOB) and CONFIGURE_FILE(... COPY_ONLY) to copy the files. -Brad ___ CMake mailing list CMake@cmake.org http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] CMake SWIG module
Hi Mathieu, I have been off the line for a while because of the network security policy of my new client and my new internet provider who needs almost a month to activate a line :/ Anyway I don't have much time to allocate to maintain the swig module anymore. Some issues are still pending, I am glad you are the one who will blow their head clean off :) Regards -- Tristan Carel Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for - in order to get to the job you need to pay for the clothes and the car, and the house you leave vacant all day so you can afford to live in it. On Sat, Oct 3, 2009 at 16:09, Mathieu Malaterre wrote: > Hi, > > I'd like to become the new maintainer of the swig module in cmake. I > have not heard back from Tristan Carel. > I have updated my name on : > http://www.cmake.org/Wiki/CMake:Module_Maintainers > > Thank you, > -- > Mathieu > ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
[CMake] CMake + SWIG => Java JNI problems
Hello everyone, I'm having trouble mixing cmake and swig to make a java JNI module. It looks roughly: IF(DEFINED SWIG_JAVA) FIND_PACKAGE(JNI REQUIRED) include_directories(${JNI_INCLUDE_DIRS}) SET(CMAKE_SWIG_OUTDIR ${ROOT_DIR}/swig/generated/java/libtcod) SWIG_ADD_MODULE(libtcod-java java libtcod.i) SWIG_LINK_LIBRARIES(libtcod-java ${JNI_LIBRARIES} ${LIBTCOD_NAME}) ENDIF() With ${LIBTCOD_NAME} being the name of the library this JNI is trying to wrap (libtcod-VS.dll). It builds fine, and my entire build produces: libtcod-VS.dll (the main library) libtcod-java.dll (the swig generated library) A bunch of .java files files I build into a .jar The problem is when I try to load it in java, I get UnsatisfiedLinkError errors. The error is related to symbols exported from libtcod-VS.dll. It seems that java JNI wants both the SWIG symbols and the base library symbols in the same library. What I can't seem to do is to do that. I've tried adding the cpp files for the library into the SWIG_ADD_MODULE list to build into libtcod-java.dll, however that won't link. The base library uses this line: set_property(TARGET ${LIBTCOD_NAME} PROPERTY COMPILE_DEFINITIONS LIBTCOD_EXPORTS) to setup the headers correctly for linking. However, since the swig project name is abstracted via SWIG_ADD_MODULE and SWIG_LINK_LIBRARIES, I don't know how I can set this. Any suggestions? My {python,ruby,csharp,lua} wrappers don't have this problem, since they seem perfectly happy to have my swig symbols in a different file as the base symbols. Thanks, Chris Hamons ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] CMake + SWIG => Java JNI problems
Anybody want to take a stab at this? Maybe point me to the e-mail address of somebody who could help. I've read what documentation exists and poked around the source code to no avail. Google gives no helpful answers. Thanks, --Chris On Sun, Mar 21, 2010 at 11:20 PM, Chris Hamons wrote: > Hello everyone, > I'm having trouble mixing cmake and swig to make a > java JNI module. It looks roughly: > > IF(DEFINED SWIG_JAVA) > FIND_PACKAGE(JNI REQUIRED) > include_directories(${JNI_INCLUDE_DIRS}) > SET(CMAKE_SWIG_OUTDIR ${ROOT_DIR}/swig/generated/java/libtcod) > SWIG_ADD_MODULE(libtcod-java java libtcod.i) > SWIG_LINK_LIBRARIES(libtcod-java ${JNI_LIBRARIES} > ${LIBTCOD_NAME}) > ENDIF() > > With ${LIBTCOD_NAME} being the name of the library this JNI is trying > to wrap (libtcod-VS.dll). > > It builds fine, and my entire build produces: > libtcod-VS.dll (the main library) > libtcod-java.dll (the swig generated library) > A bunch of .java files files I build into a .jar > > The problem is when I try to load it in java, I get > UnsatisfiedLinkError errors. The error is related to symbols exported > from libtcod-VS.dll. It seems that java JNI wants both the SWIG > symbols and the base library symbols in the same library. > > What I can't seem to do is to do that. I've tried adding the cpp files > for the library into the SWIG_ADD_MODULE list to build into > libtcod-java.dll, however that won't link. The base library uses this > line: > > set_property(TARGET ${LIBTCOD_NAME} PROPERTY COMPILE_DEFINITIONS > LIBTCOD_EXPORTS) > > to setup the headers correctly for linking. However, since the swig > project name is abstracted via SWIG_ADD_MODULE and > SWIG_LINK_LIBRARIES, I don't know how I can set this. > > Any suggestions? My {python,ruby,csharp,lua} wrappers don't have this > problem, since they seem perfectly happy to have my swig symbols in a > different file as the base symbols. > > Thanks, > Chris Hamons > ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] CMAKE + SWIG + more wrapped languages
Great, this is a good idea, thank you very much! I have tried to create wrap/python/ModulePy.i including the original wrap/Module.i only, and when it was called as .../python $ swig -c++ -python -I../ Module.py everything seemed to be OK (well, I did not try to compile it, I just saw the module.p and Module_wrap.cxx generated). So even if "tricky", it seems to work. However, there is still the issue with "-I../" flag set to the SWIG through CMake list files: the setting of: SET_SOURCE_FILES_PROPERTIES( Module.i PROPERTIES SWIG_FLAGS "-I../") does not work. The -I../ does not appear in the SWIG call. This call is copied from "http://www.cmake.org/Wiki/CMake_FAQ#How_do_I_use_CMake_to_generate_SWIG_wrapper_libraries.3F";. I have also tried to use CMAKE_SWIG_FLAGS instead of SWIG_FLAGS, but the behavior is the same. Unfortunately, there is not much written about the "Mastering CMake" book, which I have. Do you know anything about it? Thank you very much, regards Dan BTW: the "dependency issue" means that CMake dos not check changes in .i files (or the change of date), in order to call SWIG to generate new wrapper classes? On Monday 24 July 2006 13:47, ANTON DEGUET wrote: > Daniel, > > I figured out a solution which is more a trick than anything else. > Basically, I created an empty .i file as a stub for each language. For > example, you have Module.i and you could add ModulePython.i which contains: > %include "Module.i". I then use CMake with these stubs. > > This works but I then run into a long known issue with the CMake SWIG > macro, i.e. the dependencies don't handle files included by SWIG using the > %include. I believe there is a ticket opened for this issue. > > Anton > > > - Original Message - > From: Daniel Tihelka <[EMAIL PROTECTED]> > Date: Monday, July 24, 2006 4:47 am > Subject: [CMake] Fwd: CMAKE + SWIG + more wrapped languages > > > Hallo everybody. > > > > May I ask you for a help with SWIG module in CMake? I need to > > create more > > wrapping libraries from one set of .i SWIG files. To use SWIG from > > CMake is > > really trivial for one wrapped language, but I need to create more > > wrappersin one step, as illustrated below: > > > > I have directory structure like this: > > > > wrap > > > > +-- Module.i > > +-- *.i (other SWIG interface files included by Module.i) > > > > +-- python > > +--perl > > +-- java > > > > The "wrap/CMakeLists.txt" looks simple: > > > > SUBDIRS(python perl java) > > > > > > And for example "wrap/python/CMakeLists.txt" looks like (the > > CMakeLists will > > look similarly for "perl" and "java" packages): > > > > # Find and include required packages > > FIND_PACKAGE( SWIG REQUIRED ) > > FIND_PACKAGE( PythonLibs REQUIRED ) > > INCLUDE( ${SWIG_USE_FILE} ) > > > > # Set include python path > > INCLUDE_DIRECTORIES( ${PYTHON_INCLUDE_PATH} ) > > > > # Generated file is C++, tell it to SWIG > > SET_SOURCE_FILES_PROPERTIES( Module.i PROPERTIES CPLUSPLUS ON ) > > > > # ! Tell to SWIG that .i files are one directory up ! > > SET_SOURCE_FILES_PROPERTIES( Module.i PROPERTIES SWIG_FLAGS "-I../") > > > > # Create wrapper > > SWIG_ADD_MODULE( module python Module.i ) > > SWIG_LINK_LIBRARIES( module python2.4 ) > > > > # Copy the generated files as post-build step > > ADD_CUSTOM_COMMAND( TARGET ${SWIG_MODULE_module_REAL_NAME} > >POST_BUILD > >COMMAND ${CMAKE_COMMAND} > >ARGS -E copy > > ${CMAKE_CURRENT_BINARY_DIR}/*.py${CMAKE_CURRENT_SOURCE_DIR} ) > > # > > ADD_CUSTOM_COMMAND( TARGET${SWIG_MODULE_module_REAL_NAME} > >POST_BUILD > >COMMAND ${CMAKE_COMMAND} > >ARGS -E copy > > ${CMAKE_CURRENT_BINARY_DIR}/*.so${CMAKE_CURRENT_SOURCE_DIR} ) > > > > > > > > > > However, when the build process is started, it finishes by error: > > > > make[5]: Entering directory `/home//build//wrap/python' > > make[5]: *** No rule to make target > > `/home//wrap/python/Module.i', needed by > > `/home//build//wrap/python/Module_wrap.c'. Stop. > > > > > > When I looked at ".../build/python/Makefile", there is target: > > > > /home//build//wrap/python/Module_wrap.c: > > /home//wrap/python/Module.i @echo "Building Swig > > source /home//build/wrap/python/Module_wrap.c..." > > /usr/bin/swig -python -I/usr/include/python2.4 -o > > /home//build//wrap/python/Module_wrap.c > > /home//wrap/python/Module.i > > However, there is no "-I../" switch specified by > > "SET_SOURCE_FILES_PROPERTIES( Module.i PROPERTIES SWIG_FLAGS "- > > I../")". Moreover, there is absolute path to the "Module.i" which > > is, however, wrong. > > When I tries to call SWIG directly, but only with Module.i it was > > OK - the > > -I sw
Re: [CMake] CMAKE + SWIG + more wrapped languages
I am sorry - the previous mail was wrong. The directives: SET_SOURCE_FILES_PROPERTIES( ErisPython.i PROPERTIES CPLUSPLUS ON ) SET_SOURCE_FILES_PROPERTIES( ErisPython.i PROPERTIES SWIG_FLAGS "-I../") seems to work fine. The "-I../" flag is set in the SWIG call. I had to miss something. I am sorry again, and thank you very much for your help! Dan On Monday 24 July 2006 14:22, Daniel Tihelka wrote: > Great, this is a good idea, thank you very much! > > I have tried to create wrap/python/ModulePy.i including the original > wrap/Module.i only, and when it was called as > > .../python $ swig -c++ -python -I../ Module.py > > everything seemed to be OK (well, I did not try to compile it, I just saw > the module.p and Module_wrap.cxx generated). So even if "tricky", it seems > to work. > > However, there is still the issue with "-I../" flag set to the SWIG through > CMake list files: the setting of: > > SET_SOURCE_FILES_PROPERTIES( Module.i PROPERTIES SWIG_FLAGS "-I../") > > does not work. The -I../ does not appear in the SWIG call. This call is > copied from > "http://www.cmake.org/Wiki/CMake_FAQ#How_do_I_use_CMake_to_generate_SWIG_wr >apper_libraries.3F". I have also tried to use CMAKE_SWIG_FLAGS instead of > SWIG_FLAGS, but the behavior is the same. Unfortunately, there is not much > written about the "Mastering CMake" book, which I have. > > Do you know anything about it? > > Thank you very much, > regards > Dan > > > BTW: the "dependency issue" means that CMake dos not check changes in .i > files (or the change of date), in order to call SWIG to generate new > wrapper classes? > > On Monday 24 July 2006 13:47, ANTON DEGUET wrote: > > Daniel, > > > > I figured out a solution which is more a trick than anything else. > > Basically, I created an empty .i file as a stub for each language. For > > example, you have Module.i and you could add ModulePython.i which > > contains: %include "Module.i". I then use CMake with these stubs. > > > > This works but I then run into a long known issue with the CMake SWIG > > macro, i.e. the dependencies don't handle files included by SWIG using > > the %include. I believe there is a ticket opened for this issue. > > > > Anton > > > > > > - Original Message - > > From: Daniel Tihelka <[EMAIL PROTECTED]> > > Date: Monday, July 24, 2006 4:47 am > > Subject: [CMake] Fwd: CMAKE + SWIG + more wrapped languages > > > > > Hallo everybody. > > > > > > May I ask you for a help with SWIG module in CMake? I need to > > > create more > > > wrapping libraries from one set of .i SWIG files. To use SWIG from > > > CMake is > > > really trivial for one wrapped language, but I need to create more > > > wrappersin one step, as illustrated below: > > > > > > I have directory structure like this: > > > > > > wrap > > > > > > +-- Module.i > > > +-- *.i (other SWIG interface files included by Module.i) > > > > > > +-- python > > > +-- perl > > > +-- java > > > > > > The "wrap/CMakeLists.txt" looks simple: > > > > > > SUBDIRS(python perl java) > > > > > > > > > And for example "wrap/python/CMakeLists.txt" looks like (the > > > CMakeLists will > > > look similarly for "perl" and "java" packages): > > > > > > # Find and include required packages > > > FIND_PACKAGE( SWIG REQUIRED ) > > > FIND_PACKAGE( PythonLibs REQUIRED ) > > > INCLUDE( ${SWIG_USE_FILE} ) > > > > > > # Set include python path > > > INCLUDE_DIRECTORIES( ${PYTHON_INCLUDE_PATH} ) > > > > > > # Generated file is C++, tell it to SWIG > > > SET_SOURCE_FILES_PROPERTIES( Module.i PROPERTIES CPLUSPLUS ON ) > > > > > > # ! Tell to SWIG that .i files are one directory up ! > > > SET_SOURCE_FILES_PROPERTIES( Module.i PROPERTIES SWIG_FLAGS "-I../") > > > > > > # Create wrapper > > > SWIG_ADD_MODULE( module python Module.i ) > > > SWIG_LINK_LIBRARIES( module python2.4 ) > > > > > > # Copy the generated files as post-build step > > > ADD_CUSTOM_COMMAND( TARGET ${SWIG_MODULE_module_REAL_NAME} > > >POST_BUILD > > >COMMAND ${CMAKE_COMMAND} > > >ARGS -E copy > > > ${CMAKE_CURRENT_BINARY_DIR}/*.py${CMAKE_CURRENT_SOURCE_DIR} ) > > > # > > > ADD_CUSTOM_COMMAND( TARGET${SWIG_MODULE_module_REAL_NAME} > > >POST_BUILD > > >COMMAND ${CMAKE_COMMAND} > > >ARGS -E copy > > > ${CMAKE_CURRENT_BINARY_DIR}/*.so${CMAKE_CURRENT_SOURCE_DIR} ) > > > > > > > > > > > > > > > However, when the build process is started, it finishes by error: > > > > > > make[5]: Entering directory `/home//build//wrap/python' > > > make[5]: *** No rule to make target > > > `/home//wrap/python/Module.i', needed by > > > `/home//build//wrap/python/Module_wrap.c'. Stop. > > > > > > > > > When I looked at ".../build/python/Makefile", there is target: > > > > > > /home//build//wr
[CMake] CMake SWIG support for nested python modules
Hello, I am the developer of PyTrilinos, the python interface to Trilinos and I have hit upon some unexpected behavior. I am trying to wrap the interface to NOX, which utilizes nested namespaces. I shadow this structure in python by utilizing nested modules. For example, a subset of the NOX namespace structure is given by NOX Abstract StatusTest Solver Epetra Interface My goal, which I had previously achieved under an autotools/distutils hybrid build system, is to generate the following directory structure: NOX/__init__.py Abstract.py StatusTest.py Solver.py Epetra/__init__.py Interface.py To do this, I have the following swig interface files: NOX.__init__.i NOX.Abstract.i NOX.StatusTest.i NOX.Solver.i NOX.Epetra.__init__.i NOX.Epetra.Interface.i The problem I am running into seems to be associated with the "." characters in the swig interface filenames. I get several invocations of the swig executable working on NOX.__init__.i that produce NOXPYTHON_wrap.cxx. Is there a way around this behavior? Thanks ** Bill Spotz ** ** Sandia National Laboratories Voice: (505)845-0170 ** ** P.O. Box 5800 Fax: (505)284-0154 ** ** Albuquerque, NM 87185-0370Email: wfsp...@sandia.gov ** ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] CMake SWIG support for nested python modules
Bill Spotz wrote: Hello, I am the developer of PyTrilinos, the python interface to Trilinos and I have hit upon some unexpected behavior. I am trying to wrap the interface to NOX, which utilizes nested namespaces. I shadow this structure in python by utilizing nested modules. For example, a subset of the NOX namespace structure is given by NOX Abstract StatusTest Solver Epetra Interface My goal, which I had previously achieved under an autotools/distutils hybrid build system, is to generate the following directory structure: NOX/__init__.py Abstract.py StatusTest.py Solver.py Epetra/__init__.py Interface.py To do this, I have the following swig interface files: NOX.__init__.i NOX.Abstract.i NOX.StatusTest.i NOX.Solver.i NOX.Epetra.__init__.i NOX.Epetra.Interface.i The problem I am running into seems to be associated with the "." characters in the swig interface filenames. I get several invocations of the swig executable working on NOX.__init__.i that produce NOXPYTHON_wrap.cxx. Is there a way around this behavior? I assume you are using the macro's for swig found in UseSWIG.cmake? You might have to create the custom commands by hand. Information about that can be found here: http://www.vtk.org/Wiki/CMake_FAQ#How_can_I_generate_a_source_file_during_the_build.3F It is just a matter of using the correct swig invocation in the custom command to create the files where you want them. Can post a small example of what you are trying right now? -Bill ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] CMake SWIG support for nested python modules
So I was able to solve my problem of duplicate python target names generated from SWIG interface files: PyTrilinos/NOX/___init__.so PyTrilinos/NOX/Epetra/___init__.so by overhauling UseSWIG.cmake to take advantage of the OUTPUT_NAME property of the SET_TARGET_PROPERTIES() function. My problem now is that SWIG modules whose NAME and OUTPUT_NAME are different are always built, even if they don't need to be. Is there a way to get dependencies to work in this situation? Thanks On Apr 3, 2009, at 11:53 AM, Spotz, William F wrote: Bill, Thanks for the help. Once I realized I needed to do INCLUDE(UseSWIG) instead of INCLUDE(${SWIG_USE_FILE}) in order to include my local copy, I made some good progress. Now I am facing the problem of duplicate swig module names. Here is (partially) what my resulting python package directory hierarchy should look like: PyTrilinos/ NOX/ __init__.py ___init__.so Abstract.py _Abstract.so Solver.py _Solver.so StatusTest.py _StatusTest.so Epetra/ __init__.py ___init__.so Interface.py _Interface.so The problem is the multiple __init__ module names. Here is what I am currently trying, knowing full well it will fail: # Python module PyTrilinos.NOX SET(CMAKE_SWIG_OUTDIR PyTrilinos/NOX) SET_SOURCE_FILES_PROPERTIES(NOX.__init__.i PROPERTIES CPLUSPLUS ON) SWIG_ADD_MODULE(__init__ python NOX.__init__.i) SET_TARGET_PROPERTIES(${SWIG_MODULE___init___REAL_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY PyTrilinos/NOX) # Python module PyTrilinos.NOX.Epetra SET(CMAKE_SWIG_OUTDIR PyTrilinos/NOX/Epetra) SET_SOURCE_FILES_PROPERTIES(NOX.Epetra.__init__.i PROPERTIES CPLUSPLUS ON) SWIG_ADD_MODULE(__init__ python NOX.Epetra.__init__.i) # Repeat module name! SET_TARGET_PROPERTIES(${SWIG_MODULE___init___REAL_NAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY PyTrilinos/NOX/Epetra) Any ideas how to approach this? (I was thinking it would be nice to allow SWIG_ADD_MODULE to take, for example, NOX/__init__ or NOX/Epetra/__init__ as its first argument. But then SWIG_MODULE__REAL_NAME is not a valid variable name. In the latter case, we could substitute "_" for "/", but the UseSWIG module would have to know how to handle that.) Thanks On Apr 2, 2009, at 2:55 PM, Bill Hoffman wrote: I'm guessing there is a parsing of the swig interface filename which splits on the first "." it finds rather than the last. Yup, that is the problem... MACRO(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile) ... GET_FILENAME_COMPONENT(swig_source_file_path "${infile}" PATH) GET_FILENAME_COMPONENT(swig_source_file_name_we "${infile}" NAME_WE) /** * Return file name without extension of a full filename (i.e. without path). * Warning: it considers the longest extension (for example: .tar.gz) */ kwsys_stl::string SystemTools::GetFilenameWithoutExtension(const kwsys_stl::string& filename) { So, how to fix it You could copy the UseSwig.cmake into Trilinos and modify it. I guess we could change the code to use a regex replace and exchange the .i for empty. GET_FILENAME_COMPONENT(swig_source_file_name_we "${infile}" NAME_WE) with STRING(REGEX REPLACE "(.*)\\.i$" "\\1" swig_source_file_name_we $ {infile}) -Bill ** Bill Spotz ** ** Sandia National Laboratories Voice: (505)845-0170 ** ** P.O. Box 5800 Fax: (505)284-0154 ** ** Albuquerque, NM 87185-0370Email: wfsp...@sandia.gov ** ** Bill Spotz ** ** Sandia National Laboratories Voice: (505)845-0170 ** ** P.O. Box 5800 Fax: (505)284-0154 ** ** Albuquerque, NM 87185-0370Email: wfsp...@sandia.gov ** ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] CMake SWIG support for nested python modules
Bill Spotz wrote: So I was able to solve my problem of duplicate python target names generated from SWIG interface files: PyTrilinos/NOX/___init__.so PyTrilinos/NOX/Epetra/___init__.so by overhauling UseSWIG.cmake to take advantage of the OUTPUT_NAME property of the SET_TARGET_PROPERTIES() function. My problem now is that SWIG modules whose NAME and OUTPUT_NAME are different are always built, even if they don't need to be. Is there a way to get dependencies to work in this situation? Can you provide a simple example that shows the problem? -Bill ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
[CMake] [Cmake/SWIG/JAVA/WINDOWS] add "-Wl,--kill-at" flag
Hi everybody, I use CMake to wrap a c++ library in Java with swig. When I use linux OS it works very well, but when I use windows OS there is a problem. Indeed, the compilation works fine but the dll has not the correct method/fonction inside. After several researches on the web I find I must use the flag "-Wl,--kill-at" when I create the dll. But I do not find the equivalent flag on cmake, I try: CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS CMAKE_SHARED_LIBRARY_CXX_FLAGS CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP CMAKE_SHARED_LIBRARY_LINK_STATIC_CXX_FLAGS CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_CXX_FLAGS Does somebody know a solution? Thanks Benjamin JEANTY-RUARD ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] [Cmake/SWIG/JAVA/WINDOWS] add "-Wl,--kill-at" flag
Are you sure you don't just need an: extern "C" { } block around a function implemented in a C++ file...? On Thu, Aug 4, 2011 at 7:30 AM, Benjamin Ruard wrote: > Hi everybody, > I use CMake to wrap a c++ library in Java with swig. When I use linux OS > it works very well, but when I use windows OS there is a problem. > Indeed, the compilation works fine but the dll has not the correct > method/fonction inside. After several researches on the web I find I > must use the flag "-Wl,--kill-at" when I create the dll. But I do not > find the equivalent flag on cmake, I try: > > CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS > CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS > CMAKE_SHARED_LIBRARY_CXX_FLAGS > CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS > CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG > CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP > CMAKE_SHARED_LIBRARY_LINK_STATIC_CXX_FLAGS > CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_CXX_FLAGS > > Does somebody know a solution? > > Thanks > > Benjamin JEANTY-RUARD > > ___ > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake > ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
Re: [CMake] [Cmake/SWIG/JAVA/WINDOWS] add "-Wl,--kill-at" flag
Thanks for your answer, but The block: extern "C" { ... } already exists. Regards. Benjamin JEANTY-RUARD Le jeudi 04 août 2011 à 08:40 -0400, David Cole a écrit : > Are you sure you don't just need an: > > extern "C" { > } > > block around a function implemented in a C++ file...? > > > On Thu, Aug 4, 2011 at 7:30 AM, Benjamin Ruard wrote: > > Hi everybody, > > I use CMake to wrap a c++ library in Java with swig. When I use linux OS > > it works very well, but when I use windows OS there is a problem. > > Indeed, the compilation works fine but the dll has not the correct > > method/fonction inside. After several researches on the web I find I > > must use the flag "-Wl,--kill-at" when I create the dll. But I do not > > find the equivalent flag on cmake, I try: > > > > CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS > > CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS > > CMAKE_SHARED_LIBRARY_CXX_FLAGS > > CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS > > CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG > > CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG_SEP > > CMAKE_SHARED_LIBRARY_LINK_STATIC_CXX_FLAGS > > CMAKE_SHARED_LIBRARY_LINK_DYNAMIC_CXX_FLAGS > > > > Does somebody know a solution? > > > > Thanks > > > > Benjamin JEANTY-RUARD > > > > ___ > > Powered by www.kitware.com > > > > Visit other Kitware open-source projects at > > http://www.kitware.com/opensource/opensource.html > > > > Please keep messages on-topic and check the CMake FAQ at: > > http://www.cmake.org/Wiki/CMake_FAQ > > > > Follow this link to subscribe/unsubscribe: > > http://www.cmake.org/mailman/listinfo/cmake > > ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake