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

Axel Roebel Axel.Roebel at ircam.fr
Sat Dec 9 17:18:05 EST 2006


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}

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? 

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.

Cheers,

-- 
Axel Roebel
IRCAM Analysis/Synthesis Team
Phone: ++33-1-4478 4845 | Fax: ++33-1-4478 1540


More information about the CMake mailing list