[CMake] Fwd: CMAKE + SWIG + more wrapped languages

2006-07-24 Thread Daniel Tihelka

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 wrappers
in 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 switch seems to ensure the right path.

I have also tried to set relative paths during CMake configuration, but it
leaded to other errors during the build.

Could someone give me a hint how to solve this problem? Did I choose the
 right approach, or should it be solved in different way? Or how to instruct
 CMake not to use the whole path to .i file (neither absolute, nor relative)?
 Any help will really be appreciated.

Thank you very much,
Dan

___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Fwd: CMAKE + SWIG + more wrapped languages

2006-07-24 Thread ANTON DEGUET
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 switch seems to ensure the right path.
 
 I have also tried to set relative paths during CMake 
 configuration, but it
 leaded to other errors during the build.
 
 Could someone give me a hint how to solve this problem? Did I 
 choose the
 right approach, or should it be solved in different way? Or how to 
 instruct CMake not to use the whole path to .i file (neither 
 absolute, nor relative)?
 Any help will really be appreciated.
 
 Thank you very much,
 Dan
 
 ___
 CMake mailing list
 CMake@cmake.org
 http://www.cmake.org/mailman/listinfo/cmake
 
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Fwd: CMAKE + SWIG + more wrapped languages

2006-07-24 Thread James Bigler

ANTON DEGUET wrote:

Daniel,

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.


Yes, this is quite annoying.  I've been looking at trying to implement the work 
around described in this ticket.


http://public.kitware.com/Bug/bug.php?op=showbugid=1731

This is the source code for the hack, but you will have to dig it out.  I'm 
still trying to decipher the relevant code and make a simple macro that does 
what I think it should.  I'll post that code as soon as I get something working, 
unless someone else has some


http://www.itk.org/cgi-bin/viewcvs.cgi/Wrapping/CSwig/CMakeLists.txt?rev=1.55root=Insightview=auto

James
___
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake