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

Axel Roebel Axel.Roebel at ircam.fr
Tue Dec 12 08:40:14 EST 2006


I have some more observations :

1)
the error message SWIG_GET_WRAPPER_DEPENDENCIES
uses ${SWIG} instead of ${SWIG_EXECUTABLE}

MESSAGE(SEND_ERROR "Command \"${SWIG} -MM -MF ${swig_getdeps_depsfile} 
${swig_getdeps_extra_flags} -${language} -o ${genWrapper} $\
{swig_getdeps_include_dirs} ${swigFile}\" failed with output:
\n${swig_getdeps_error}")
 
2)
The command line used to find the dependencies
does not use the same flags as the command line used to 
compile the files:

In the latter you have

      ${swig_source_file_flags}
      ${CMAKE_SWIG_FLAGS}
      ${swig_special_flags}
      ${swig_extra_flags}
      ${swig_include_dirs}

while in the former you only use
 
${swig_getdeps_extra_flags} -${language}
 
in some of my projects I use  ${CMAKE_SWIG_FLAGS} 
to pass include directories which fails with an error
during dependency generation because some of the 
include files are not found. While you may argue that
I should use the INCLUDE_DIRECTORIES command  I preferred 
 ${CMAKE_SWIG_FLAGS} because that would prevent 
the c++ compiler from searching in the project common
swig include directories.

Without knowing the swig wrapper generator extremely well, I wonder
whether having different flags in these two stages
is not asking for a lot of trouble.

Cheers, 


On Monday 11 December 2006 21:52, Tristan Carel wrote:
> 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

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


More information about the CMake mailing list