[CMake] Making swig wrapper depend on the involved headers

Clinton Stimpson clinton at elemtech.com
Wed Dec 19 16:22:58 EST 2012


On Wednesday, December 19, 2012 01:18:47 PM Daniel Russel wrote:
> I'm using the shipped UseSWIG package to add a swig module to my project
> (cmake 2.8). For those that don't know, swig works by running the swig
> command on an input file (a .i) and then building the files that it
> produces. The input file tells swig to scan certain header files and the
> output file depends on the contents of the header files. As a result, when
> one of the headers changes, swig needs to be rerun. However, this does not
> occur and I can't figure out a way to manually add the needed dependencies
> to cmake either (I've tried various things with setting source DEPENDENCY
> property and the ADD_DEPENDENCIES command passing in the dependencies). Any
> suggestions? Thanks. --


You can manually add dependencies like this

SET(SWIG_MODULE_foo_EXTRA_DEPS 
  ${foo_SOURCE_DIR}/foo.h
)

...

SWIG_ADD_MODULE(foo python foo.i)

-- 
Clinton Stimpson
Elemental Technologies, Inc
Computational Simulation Software, LLC
www.csimsoft.com


More information about the CMake mailing list