[Cmake] Re: [Swig] ANNOUNCE: CMake 2.0.3 with SWIG support

Anton Deguet anton at cs.jhu.edu
Mon Aug 30 15:17:09 EDT 2004


Thank you for your answer.  The additional clean files works but I am
having some difficulties with the -outdir option for SWIG.  Basically,
the code I have adds a "\ " in the makefile and SWIG can not parse the
options correctly.  My code is slightly different from your examples
since I am wrapping a large number of libraries using a loop:

FOREACH(lib ${CISST_LIBS})
  IF(BUILD_${lib})
    SET(SWIG_INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/${lib}.i)
      IF(EXISTS ${SWIG_INTERFACE})
         SET_SOURCE_FILES_PROPERTIES(${SWIG_INTERFACE} PROPERTIES
CPLUSPLUS ON)
         SET_SOURCE_FILES_PROPERTIES(${SWIG_INTERFACE}
                                     PROPERTIES SWIG_FLAGS "-c++")
         SET_SOURCE_FILES_PROPERTIES(${SWIG_INTERFACE}
                                     PROPERTIES SWIG_FLAGS "-outdir
${EXECUTABLE_OUTPUT_PATH}/")
         SWIG_ADD_MODULE(${lib} python ${SWIG_INTERFACE})
         SWIG_LINK_LIBRARIES(${lib} ${Python_LIBRARIES})
        SET_DIRECTORY_PROPERTIES(PROPERTIES
                                 ADDITIONAL_MAKE_CLEAN_FILES
                                
"${ADDITIONAL_MAKE_CLEAN_FILES};${EXECUTABLE_OUTPUT_PATH}/${lib}.py")
      ENDIF(EXISTS ${SWIG_INTERFACE})
  ENDIF(BUILD_${lib})
ENDFOREACH(lib)

The Makefile generated for one SWIG execution is:

         /home/erc/bin/swig -python -outdir\
/home/stomach/anton/devel/cisst/Linux-gcc/libs/bin/ -c++
-I/home/stomach/anton/devel/cisst/libs/include
-I/home/stomach/anton/devel/cisst/Linux-gcc/libs
-I/usr/include/python2.2 -o
/home/stomach/anton/devel/cisst/Linux-gcc/libs/wrapping/cisstVector_wrap.cxx /home/stomach/anton/devel/cisst/libs/wrapping/cisstVector.i

As you can see, there is a "\ " after the -outdir option and SWIG
doesn't like it.  what did I do wrong?

Sincerely,

Anton


On Sat, 2004-08-21 at 06:02, William A. Hoffman wrote:
> Hi, 
> 
> To move the .py files, you can use the swig -outdir option.
> That can be set with the SWIG_FLAGS property, something like this:
> 
> SET_SOURCE_FILES_PROPERTIES(example.i PROPERTIES SWIG_FLAGS 
> "-outdir ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}")
> 
> (That is assuming that you are using EXECUTABLE_OUTPUT_PATH.
> 
> For the make clean, you can add that like this:
> 
>   SET_DIRECTORY_PROPERTIES(PROPERTIES
>     ADDITIONAL_MAKE_CLEAN_FILES "${ADDITIONAL_MAKE_CLEAN_FILES};myLibrary.py")
> 
> The problem is that running swig on a .i file may generate any number of .py files
> depending on the classes being wrapped.  
> 
> -Bill
> At 03:51 PM 8/20/2004, Anton Deguet wrote:
> >Hello,
> >
> >I finally updated my projects to CMake 2.0.3 and decided to use the new
> >macros introduced to simplify the SWIG wrapping.  I have one minor
> >comment/addition for the Python wrapping.   Swig generates the file
> >myLibrary.py and:
> >- This file stays in the current binary directory.  It would be nice to
> >have it moved to the directory where _myLibrary.so resides.
> >- This file is not removed when I do make clean.  
> >
> >Sincerely,
> >
> >Anton Deguet
> >
> >
> >On Wed, 2004-08-04 at 12:37, William A. Hoffman wrote:
> >> CMake is a cross platform build manager. It allows you to specify build parameters for C and C++ programs in a cross platform manner. It generates native build files such as makefiles, nmake files and visual studio projects.
> >> 
> >> The most recent release contains direct support for SWIG projects.
> >> 
> >> A simple SWIG example follows:
> >> 
> >> 
> >> PROJECT(example_python)
> >> FIND_PACKAGE(SWIG REQUIRED)
> >> INCLUDE(${SWIG_USE_FILE})
> >> FIND_PACKAGE(PythonLibs)
> >> INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
> >> INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
> >> SET_SOURCE_FILES_PROPERTIES(example.i PROPERTIES CPLUSPLUS ON)
> >> SET_SOURCE_FILES_PROPERTIES(example.i PROPERTIES SWIG_FLAGS "-includeall")
> >> SWIG_ADD_MODULE(example python example.i example.cxx)
> >> SWIG_LINK_LIBRARIES(example ${PYTHON_LIBRARIES})
> >> 
> >> The above example will create makefiles or visual studio projects
> >> that will run swig on example.i, generate the swig wrapper cxx file,
> >> and compile example.cxx into _example.so (UNIX) or _example.dll (windows).
> >> 
> >> For more information about CMake, see:
> >> www.cmake.org
> >> 
> >> 
> >> -Bill Hoffman
> >> 
> >> _______________________________________________
> >> Swig maillist  -  Swig at cs.uchicago.edu
> >> http://mailman.cs.uchicago.edu/mailman/listinfo/swig
> >-- 
> >Anton Deguet                          Systems Engineer
> >ERC CISST                     Johns Hopkins University
> >http://cisstweb.cs.jhu.edu                410 516 5261
-- 
Anton Deguet                          Systems Engineer
ERC CISST                     Johns Hopkins University
http://cisstweb.cs.jhu.edu                410 516 5261



More information about the Cmake mailing list