MantisBT - CMake
View Issue Details
0014859CMakeCMakepublic2014-04-01 17:532014-04-03 02:17
Felix Schwitzer 
jschueller 
normalminoralways
closedno change required 
Linux
 
 
0014859: UseSWIG rebuilds source even when the the dependencies have not changed (again)
This reopens 0010080, as I'm not the original reporter and therefore can't
reopen the bug.

The fix provided in http://cmake.org/gitweb?p=stage/cmake.git;a=commitdiff;h=63ebb1 [^]
does not solve the problem of recompiling the python-module again and again, if
the module name is passed via

  set_source_files_properties(
    ${_interfacefile} PROPERTIES
    CPLUSPLUS ON
    SWIG_FLAGS "-DMODULENAME=${_modulename}")

The original, reverted, change
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f0111deb [^]
worked for me.
See attached example
I build the bindings almost always for different script languages, iterating
over the languages and passing a modified modulname appropriate to the
selected language in the way mentioned above. A cmake fragment would look
like

set(_iffile "ltt.i")
set(_languages "ruby" "python")
foreach(_lang ${_languages})
  if(_lang STREQUAL "ruby")
    set(_modulename "rltt")
    set(_libs ${RUBY_LIBRARY})
  elseif(_lang STREQUAL "python")
    set(_modulename "pyltt")
    set(_libs ${PYTHON_LIBRARY})
  endif()
  set_source_files_properties(
    ${_iffile} PROPERTIES
    CPLUSPLUS ON
    SWIG_FLAGS "-DMODULENAME=${_modulename}")
  swig_add_module(${_modulename} ${_lang} ${_iffile})
  swig_link_libraries(${_modulename} ltt ${_libs})
endforeach()
No tags attached.
related to 0010080closed jschueller UseSWIG rebuilds source even when the the dependencies have not changed 
zip ltt.zip (2,211) 2014-04-01 17:53
https://public.kitware.com/Bug/file/5119/ltt.zip
Issue History
2014-04-01 17:53Felix SchwitzerNew Issue
2014-04-01 17:53Felix SchwitzerFile Added: ltt.zip
2014-04-02 05:42jschuellerNote Added: 0035615
2014-04-02 05:46jschuellerNote Edited: 0035615bug_revision_view_page.php?bugnote_id=35615#r1434
2014-04-02 06:08jschuellerAssigned To => jschueller
2014-04-02 06:08jschuellerStatusnew => assigned
2014-04-02 09:03Brad KingRelationship addedrelated to 0010080
2014-04-02 17:55Felix SchwitzerNote Added: 0035629
2014-04-03 02:17jschuellerStatusassigned => closed
2014-04-03 02:17jschuellerResolutionopen => no change required

Notes
(0035615)
jschueller   
2014-04-02 05:42   
(edited on: 2014-04-02 05:46)
Hi,

I don't understand how this could work in your example against any patches as you do not set the SWIG_MODULE_NAME property.

I just tested it against both patches successfully if I insert this line before swig_add_module:
set_source_files_properties(${_iffile} PROPERTIES SWIG_MODULE_NAME ${_modulename})



J.

(0035629)
Felix Schwitzer   
2014-04-02 17:55   
OK,

I checked the example again and it works on ubuntu saucy, as I pass
the module name to swig via the SWIG_FLAG "-DMODULENAME=${_modulename}"
and the interface file defines the name via
   %module MODULENAME

Saying 'it works' means that the wrapper library is generated for both,
ruby and python, but when re-running make/ninja, the wrapper file for python
(and only for python) will be regenerated and recompiled even if there are
no changes in any of the source files.

But you are right, I overlooked the possibility to pass the module name via
SWIG_MODULE_NAME property, as there is almost no documentation for the
UseSWIG-module.

If I do so, both, cmake from the master-branch and from
stage/UseSWIG-guess_module_name works fine.

Therefore please close this issue, at it can be considered an user error.
Sorry about the noise.