MantisBT - CMake
View Issue Details
0004147CMakeModulespublic2006-12-05 19:122016-06-10 14:30
Tristan Carel 
jschueller 
lowfeaturealways
closedmoved 
 
 
0004147: [MODULES][UseSWIG] Use swig to compute dependencies
Swig is able to generate a file (in make language) which contains the
exact dependencies of the generated wrapper.

The following patch add the macro `SWIG_GET_WRAPPER_DEPENDENCIES' to the
`UseSWIG' module:

# SWIG_GET_WRAPPER_DEPENDENCIES(swigFile genWrapper language DEST_VARIABLE)
# - Put dependencies of the wrapper genWrapper generated by swig from
# swigFile in DEST_VARIABLE

The macro uses a `EXECUTE_PROCESS' which calls swig with the option
described above. The way to compute the command line used in the
EXECUTE_PROCESS is performed like `SWIG_ADD_MODULE' does:
- use GET_DIRECTORY_PROPERTY to retrieve the INCLUDE_DIRECTORIES
- use GET_SOURCE_FILE_PROPERTY to get extra flags attached to the swig
input file.

The dirty part of the macro is the content's extraction of the generated
file which is written in `make language'
target: \
 dependence1 \
 dependence2 \
 ...
 dependenceN

I has been tested with swig 1.3.{29,30,31} under Windows / Debian
Linux in 2 use cases:

/*--------------------------------------------------.
| with code which use the `SWIG_ADD_MODULE' command |
`--------------------------------------------------*/

# ...
SWIG_ADD_MODULE(Test python module.i foo.cpp foo.h)
# ...

/*----------------------------.
| with targets made manually: |
`----------------------------*/

# ...
SWIG_GET_WRAPPER_DEPENDENCIES(module.i module_wrap.cpp python module_deps)
ADD_CUSTOM_COMMAND(OUTPUT module_wrap.cpp
 COMMAND ${SWIG_EXECUTABLE} ARGS [...] -o module_wrap.cpp module.i
  MAIN_DEPENDENCY module.i
  DEPENDS ${module_deps}
SET_SOURCE_FILE_PROPERTIES(module_wrap.cpp PROPERTIES GENERATED TRUE)
# ...

thx
--
Tristan
No tags attached.
related to 0012307closed  regression in 2.8.5 rc2: UseSWIG.cmake broken 
patch UseSWIG.cmake.patch (3,771) 1969-12-31 19:00
https://public.kitware.com/Bug/file/764/UseSWIG.cmake.patch
? UseSWIG.cmake.diff.RC2 (3,714) 1969-12-31 19:00
https://public.kitware.com/Bug/file/768/UseSWIG.cmake.diff.RC2
? UseSWIG.cmake.diff.RC3 (3,750) 1969-12-31 19:00
https://public.kitware.com/Bug/file/774/UseSWIG.cmake.diff.RC3
? UseSWIG.cmake.diff.RC4 (3,770) 1969-12-31 19:00
https://public.kitware.com/Bug/file/775/UseSWIG.cmake.diff.RC4
Issue History
2008-10-09 13:09Bill HoffmanNote Added: 0013798
2009-10-30 11:55Mathieu MalaterreAssigned ToBill Hoffman => Mathieu Malaterre
2011-03-28 12:20Mathieu MalaterreNote Added: 0025934
2011-03-28 12:20Mathieu MalaterreStatusassigned => closed
2011-03-28 12:20Mathieu MalaterreResolutionopen => fixed
2011-06-26 08:38David ColeRelationship addedrelated to 0012307
2011-06-26 08:39David ColeNote Added: 0026976
2011-06-27 13:06Brad KingNote Added: 0026991
2011-06-27 13:06Brad KingStatusclosed => feedback
2011-06-27 13:06Brad KingResolutionfixed => reopened
2011-06-27 13:40Brad KingNote Added: 0026994
2015-06-26 11:00FlorianMNote Added: 0038989
2015-06-26 11:01FlorianMNote Edited: 0038989bug_revision_view_page.php?bugnote_id=38989#r1810
2015-06-26 11:06Brad KingAssigned ToMathieu Malaterre => jschueller
2015-06-26 11:06Brad KingStatusfeedback => assigned
2015-06-26 11:06Brad KingResolutionreopened => open
2015-06-26 11:10Brad KingNote Added: 0038991
2015-07-01 11:48Cameron ChristensenNote Added: 0039007
2016-06-10 14:27Kitware RobotNote Added: 0041335
2016-06-10 14:27Kitware RobotStatusassigned => resolved
2016-06-10 14:27Kitware RobotResolutionopen => moved
2016-06-10 14:30Kitware RobotStatusresolved => closed

Notes
(0005904)
Tristan Carel   
2006-12-07 11:34   
Please consider the RC2.
Thank you
(0005951)
Tristan Carel   
2006-12-12 10:34   
RC3 changes with RC2:
- Fix typo SWIG -> SWIG_EXECUTABLE
- EXECUTE_PROCESS considers the variable CMAKE_SWIG_FLAGS (is used by the SWIG_ADD_MODULE macro)

Thanks to Axel Roebel!
(0005952)
Tristan Carel   
2006-12-12 11:47   
RC4 changes with RC3:
Fix typo in the MESSAGE(SEND_ERROR ...)
(0013798)
Bill Hoffman   
2008-10-09 13:09   
Do you want to maintain this module?

http://www.cmake.org/Wiki/CMake:Module_Maintainers [^]
(0025934)
Mathieu Malaterre   
2011-03-28 12:20   
$ git push stage HEAD
Counting objects: 7, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 1.21 KiB, done.
Total 4 (delta 3), reused 0 (delta 0)
To git@cmake.org:stage/cmake.git
 * [new branch] HEAD -> fixbug_0004147
(0026976)
David Cole   
2011-06-26 08:39   
Looks like the fix for this bug is the cause of 0012307
(0026991)
Brad King   
2011-06-27 13:06   
Due to issue 0012307 I'm re-opening this issue and reverting its fix for the 2.8.5 release:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2377d7a2 [^]

Now the interested parties can take the necessary time to find a solution to the regression.
(0026994)
Brad King   
2011-06-27 13:40   
New revert commit with better message:

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fc045318 [^]
(0038989)
FlorianM   
2015-06-26 11:00   
(edited on: 2015-06-26 11:01)
This is a useful feature and I like to advocate to add it again.

Just adding -ignoremissing SWIG option should solve the problems discussed in 0012307:

EXECUTE_PROCESS(
    COMMAND ${SWIG_EXECUTABLE}
    -MM -MF ${swig_getdeps_depsfile} ${swig_getdeps_extra_flags}
    -ignoremissing ${CMAKE_SWIG_FLAGS} -${language}
    -o ${genWrapper} ${swig_getdeps_include_dirs} ${swigFile}
    RESULT_VARIABLE swig_getdeps_result
    ERROR_VARIABLE swig_getdeps_error
    OUTPUT_STRIP_TRAILING_WHITESPACE)

(0038991)
Brad King   
2015-06-26 11:10   
Re 0004147:0038989: If you are interested in working on the feature, please read CONTRIBUTING.rst at the top of our source tree. Also see:

 http://www.cmake.org/Wiki/CMake:Module_Maintainers [^]
(0039007)
Cameron Christensen   
2015-07-01 11:48   
I'm working on this issue as well, and we're talking about it over here: http://stackoverflow.com/questions/31007635/is-there-a-way-for-cmake-to-utilize-dependencies-generated-by-swig-mm?noredirect=1#comment50300252_31007635 [^]

I have reapplied the original patch from Mathieu and added the -ignoremissing suggestion from Florian. In my real life project it appears that generated files, whose presence is now ignored by swig -MM, still cause a problem on the cmake side. I need to investigate this more by adding a generated file to my example case from the stackoverflow question.

The current changes are available in the swig-dependencies branch here: https://github.com/cchriste/cmake [^]

I do not wish to become a module maintainer at this time, only to resolve this issue.
(0041335)
Kitware Robot   
2016-06-10 14:27   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.