[CMake] UseSWIG and -interface flag (was: Re: CMake 2.6.1 available for download)

Mathieu Malaterre mathieu.malaterre at gmail.com
Mon Aug 4 15:10:41 EDT 2008


On Mon, Aug 4, 2008 at 7:04 PM, Brad King <brad.king at kitware.com> wrote:
> Mathieu Malaterre wrote:
>>   I can reproduce my infinite dependencie problem. Every time I type
>> 'make' it redoes the swig step, using cmake 2.4.5 I cannot reproduce
>> the issue.
>>   How do I track this thing down ? Otherwise steps are simply:
>>
>> svn co https://gdcm.svn.sourceforge.net/svnroot/gdcm/trunk
>> mkdir bla
>> cd  bla
>> /tmp/cmake-2.6.1-Linux-i386/bin/cmake ../trunk
>> -DGDCM_WRAP_PYTHON:BOOL=ON -DGDCM_BUILD_SHARED_LIBS:BOOL=ON
>>
>> exit code should be '0'
>>
>> now retype 'make':
>>
>> [ 73%] Built target gdcmMSFF
>> [ 73%] Swig source
>
> I ran "make VERBOSE=1" and see this line:
>
> Deleting primary custom command output
> ".../Wrapping/Python/gdcmPYTHON_wrap.cxx" because another output
> ".../Wrapping/Python/gdcm.py" does not exist.
>
> I see that gdcm.py is located in bin instead of Wrapping/Python.  This
> means that the OUTPUT option given to ADD_CUSTOM_COMMAND for this rule
> is specifying the wrong location for the file.  It's probably a bug in
> the UseSwig.cmake file.  Perhaps you can find it from there and/or open
> a bug report.

Hi Brad,

  Indeed that was exactly it ! Thanks a bunch, I never realized there
was this very informative message in the output.

[For later reference]

 Anyway so the issue was that I use the -interface flag of swig which
is not supported in the current UseSWIG.cmake. Solution: do not use
this flag ! Instead if you really want your module to be named foobar,
simply name the .i swig input file: foobar.i. The choice of filename
is very important here !

In order to support -interface, one would need to fix the MACRO in
UseSWIG.cmake:

MACRO(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile)
  GET_SOURCE_FILE_PROPERTY(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename
    ${infile} SWIG_MODULE_NAME)
  IF(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename STREQUAL "NOTFOUND")
    GET_FILENAME_COMPONENT(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename
"${infile}" NAME_WE)
  ENDIF(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename STREQUAL "NOTFOUND")
  FOREACH(it ${SWIG_${language}_EXTRA_FILE_EXTENSION})
    SET(${outfiles} ${${outfiles}}
      "${generatedpath}/${SWIG_GET_EXTRA_OUTPUT_FILES_module_basename}.${it}")
  ENDFOREACH(it)
ENDMACRO(SWIG_GET_EXTRA_OUTPUT_FILES)


The name of the output module should not be based on the input
filename... anyway a simple fix exist, so I am not submitting a bug
report. does the useswig maintainer wants to add something ?

2cts,
-- 
Mathieu


More information about the CMake mailing list