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