[CMake] Swig dependencies not being tested?

Alan W. Irwin irwin at beluga.phys.uvic.ca
Mon Dec 10 14:58:46 EST 2007


On 2007-12-10 17:08+0100 Tristan Carel wrote:

> On Dec 10, 2007 7:15 AM, Alan W. Irwin <irwin at beluga.phys.uvic.ca> wrote:
>> On 2007-12-10 05:33+0100 Christiaan Putter wrote:
>>
>>> Hi all,
>>>
>>> I know swig support isn't all that great at the moment but was wondering if
>>> someone happens to have a working Swig module for cmake that doesn't rebuild
>>> every time even without the dependencies having changed.
>>
>> I do confirm that is a problem, and I hope somebody fixes it.
>>
>
> I use the Swig module, the one provided by CMake, and it's working
> well. Swig wrappers generation and library compilation are properly
> managed (not rebuild all the time). I use it the same way than Alan
> described: only one swig file, which takes care of all inclusions, is
> provided to the macro SWIG_ADD_MODULE. To specify missing
> dependencies, I use the variable `SWIG_MODULE_<module>_EXTRA_DEPS':

One weakness of the previous PLplot implementation was the lack of
dependency on the common file, but now I am using
SWIG_MODULE_<module>_EXTRA_DEPS to provide that.  Thanks for drawing my
attention to that possibility.

However, that is a side issue from the problem that swig is always re-invoked
(for the PLplot case) which means the interface always gets rebuilt.  Here
are some more details.

CMakeLists.txt fragment:

# This is currently the include list for swig, the C wrapper and the
# the Python headers. Not particular pretty...
set(python_interface_INCLUDE_PATHS
${CMAKE_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}
${PYTHON_INCLUDE_PATH}
${CMAKE_SOURCE_DIR}/bindings/swig-support
)
include_directories(${python_interface_INCLUDE_PATHS})

set(CMAKE_SWIG_FLAGS -DPL_DOUBLE -DSWIG_PYTHON -python)

set(CMAKE_SWIG_OUTDIR ${CMAKE_CURRENT_BINARY_DIR})

set(SWIG_MODULE_plplotcmodule_EXTRA_DEPS
${CMAKE_SOURCE_DIR}/bindings/swig-support/plplotcapi.i)

# Set up swig + c wrapper.
# N.B. the python target has an underscore prepended automatically.
swig_add_module(plplotcmodule python plplotcmodule.i)

swig_link_libraries(plplotcmodule plplot${LIB_TAG} ${PYTHON_LIBRARIES})

If I rerun make, here is the (partial) verbose result showing that swig is
re-run, then the interface is rebuilt:

make -f bindings/python/CMakeFiles/_plplotcmodule.dir/build.make bindings/python/CMakeFiles/_plplotcmodule.dir/depend
make[2]: Entering directory `/home/software/plplot_cvs/HEAD/build_dir'
/usr/bin/cmake -E cmake_progress_report /home/software/plplot_cvs/HEAD/build_dir/CMakeFiles 
[  9%] Swig source
cd /home/software/plplot_cvs/HEAD/build_dir/bindings/python && /usr/bin/swig -python -DPL_DOUBLE -DSWIG_PYTHON -python -outdir /home/software/plplot_cvs/HEAD/build_dir/bindings/python -I/home/software/plplot_cvs/HEAD/plplot_cmake/include -I/home/software/plplot_cvs/HEAD/build_dir -I/home/software/plplot_cvs/HEAD/build_dir/include -I/home/software/plplot_cvs/HEAD/build_dir/bindings/python -I/usr/include/python2.4 -I/usr/lib/python2.4/site-packages/numpy/core/include/numpy -I/home/software/plplot_cvs/HEAD/plplot_cmake/bindings/swig-support -o /home/software/plplot_cvs/HEAD/build_dir/bindings/python/plplotcmodulePYTHON_wrap.c /home/software/plplot_cvs/HEAD/plplot_cmake/bindings/python/plplotcmodule.i
Scanning dependencies of target _plplotcmodule
cd /home/software/plplot_cvs/HEAD/build_dir && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/software/plplot_cvs/HEAD/plplot_cmake /home/software/plplot_cvs/HEAD/plplot_cmake/bindings/python /home/software/plplot_cvs/HEAD/build_dir /home/software/plplot_cvs/HEAD/build_dir/bindings/python /home/software/plplot_cvs/HEAD/build_dir/bindings/python/CMakeFiles/_plplotcmodule.dir/DependInfo.cmake
make[2]: Leaving directory `/home/software/plplot_cvs/HEAD/build_dir'
make -f bindings/python/CMakeFiles/_plplotcmodule.dir/build.make bindings/python/CMakeFiles/_plplotcmodule.dir/build
make[2]: Entering directory `/home/software/plplot_cvs/HEAD/build_dir'
/usr/bin/cmake -E cmake_progress_report /home/software/plplot_cvs/HEAD/build_dir/CMakeFiles 
[  9%] Building C object bindings/python/CMakeFiles/_plplotcmodule.dir/plplotcmodulePYTHON_wrap.o
/usr/bin/gcc  -D_plplotcmodule_EXPORTS   -fPIC -I/home/software/plplot_cvs/HEAD/plplot_cmake/include -I/home/software/plplot_cvs/HEAD/build_dir -I/home/software/plplot_cvs/HEAD/build_dir/include -I/home/software/plplot_cvs/HEAD/build_dir/bindings/python -I/usr/include/python2.4 -I/usr/lib/python2.4/site-packages/numpy/core/include/numpy -I/home/software/plplot_cvs/HEAD/plplot_cmake/bindings/swig-support   -DHAVE_CONFIG_H -o bindings/python/CMakeFiles/_plplotcmodule.dir/plplotcmodulePYTHON_wrap.o   -c /home/software/plplot_cvs/HEAD/build_dir/bindings/python/plplotcmodulePYTHON_wrap.c
/home/software/plplot_cvs/HEAD/build_dir/bindings/python/plplotcmodulePYTHON_wrap.c:2510:1: warning: "PySequence_Fast_GET_ITEM" redefined
In file included from /usr/include/python2.4/Python.h:123,
                  from /home/software/plplot_cvs/HEAD/build_dir/bindings/python/plplotcmodulePYTHON_wrap.c:112:
/usr/include/python2.4/abstract.h:1007:1: warning: this is the location of the previous definition
Linking C shared module _plplotcmodule.so
cd /home/software/plplot_cvs/HEAD/build_dir/bindings/python && /usr/bin/cmake -P CMakeFiles/_plplotcmodule.dir/cmake_clean_target.cmake
cd /home/software/plplot_cvs/HEAD/build_dir/bindings/python && /usr/bin/cmake -E cmake_link_script CMakeFiles/_plplotcmodule.dir/link.txt --verbose=1
/usr/bin/gcc  -fPIC    -shared -Wl,-soname,_plplotcmodule.so -o _plplotcmodule.so "CMakeFiles/_plplotcmodule.dir/plplotcmodulePYTHON_wrap.o" -L/home/software/plplot_cvs/HEAD/build_dir/src -L/home/software/plplot_cvs/HEAD/build_dir/lib/csa -L/home/software/plplot_cvs/HEAD/build_dir/lib/nn -L/usr/lib/python2.4/config -lplplotd -lpython2.4 -lltdl -ldl -lcsirocsa -lm -lcsironn -lqhull -lfreetype -Wl,-rpath,/home/software/plplot_cvs/HEAD/build_dir/src:/home/software/plplot_cvs/HEAD/build_dir/lib/csa:/home/software/plplot_cvs/HEAD/build_dir/lib/nn:/usr/lib/python2.4/config 
make[2]: Leaving directory `/home/software/plplot_cvs/HEAD/build_dir'
/usr/bin/cmake -E cmake_progress_report /home/software/plplot_cvs/HEAD/build_dir/CMakeFiles 
[  9%] Built target _plplotcmodule

I get the same gratuitous rebuild behaviour for our Java interface as well.

Tristan, since you do not encounter this problem, are you doing something
qualitatively different than above in your CMakeLists.txt file?

In particular do you set either/both of CMAKE_SWIG_FLAGS and
CMAKE_SWIG_OUTDIR?  There might be some issue in the dependency logic when
those variables are set which causes the gratuitous rebuild.

I am using cmake 2.4.7 from Debian testing and in particular the
UseSWIG.cmake module from that version.  I do use the CMake cvs version of
FindSWIG.cmake to help me find the swig executable, but that should have
little to do with the logic in UseSWIG.cmake module which is controlling
dependencies.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list