[CMake] Re: [MODULES][UseSWIG] Dependencies automagically computed!

Tristan Carel tristan.carel at gmail.com
Mon Dec 11 15:52:59 EST 2006


On 12/9/06, Axel Roebel <Axel.Roebel at ircam.fr> wrote:
>
> Tristan Carel wrote:
> > Hi Swig lovers,
> >
> > Axel had the great idea to use the -swiglib option in order to improve
> > the module's efficiency to properly fill the prerequesites variables.
> > I guess it is the perfect example of using a tool to perform its
> > `configure' part.
> >
> > On the other hand, it's hard to maintain dependencies of the wrapper
> > generated by swig because the developper has to manually update the
> > CMakeLists.txt each time a change relative to the file inclusions in
> > the main swig file is performed. But Swig provides a couple of
> > options: -M, -MM, -MF, ...
> > which have the same behavior than gcc's: compute the dependencies for
> > us, lazy developpers!
> >
> > So I submitted a new macro in the `UseSWIG.cmake' few days ago:
> > http://www.cmake.org/Bug/bug.php?op=show&bugid=4147&pos=7
> >
> > #   SWIG_GET_WRAPPER_DEPENDENCIES(swigFile genWrapper language
> > DEST_VARIABLE) #     - Put dependencies of the wrapper genWrapper generated
> > by swig from #     swigFile in DEST_VARIABLE
> >
> > A full description (including behavior, use cases) is available on the
> > bug tracker.
> >
> > So as Axel wrote:
> > "Any comments or  volunteers to try?"
>
> Hi Tristan,
>
> do I get the idea right that you want that the wrapper will be recreated whenever any of its dependencies changed?
> That would be really nice!
>
> So I tried the usecase 1 (because usecase 2 is too involved for me ;-)
> like
>
>   SWIG_ADD_MODULE(eaSDIF perl  ${INTERFACE_SRC}  )
>   SWIG_LINK_LIBRARIES(eaSDIF ${PERL_LIBRARIES} Easdif)
>
> however it seems I don't get any dependencies besides the
> main interface file  ${INTERFACE_SRC}.
>
> I do get them if I add
>
>       DEPENDS ${SWIG_MODULE_${name}_EXTRA_DEPS}

Yes, It's exactly what I meant in my previous post when I wrote:

"[...] it's hard to maintain dependencies of the wrapper
generated by swig because the developper has to manually update the
CMakeLists.txt [...]"

I asked to CMake maintainers to add the SWIG_MODULE_${name}_EXTRA_DEPS
variable few months ago, but I didn't know that it could be done
automatically with the `swig -M' option.

I submitted a patch for `UseSWIG.cmake' in the bug tracker. You say
that the dependencies are not computed by default by the
`SWIG_ADD_SOURCE_TO_MODULE'  macro. You probably patched your
`UseSWIG.cmake' before but ... did you?

> to the ADD_CUSTOM_COMMANDS in SWIG_ADD_SOURCE_TO_MODULE.
>
> The added dependencies are pretty cool then. So I suppose you just
> forgot to actually use them?

I used them but now I'm fed up to update it each time I modify the
inclusions of the swig file.

> If you add the DEPENDS line you probably need to check for
> the case that ${SWIG_MODULE_${name}_EXTRA_DEPS}
> is empty. Otherwise DEPENDS will probably complain if the
> argument is an empty list. I have this error all the time
> for COMPILE_FLAGS, but I am not sure whether
> DEPENDS behaves similarly.

I've already used the  `SWIG_ADD_SOURCE_TO_MODULE'  without using the
`${SWIG_MODULE_${name}_EXTRA_DEPS' feature so I guess it properly
works even if the variable is empty.

CU
-- 
Tristan Carel
Music with dinner is an insult both to the cook and the violinist.


More information about the CMake mailing list