MantisBT - CMake
View Issue Details
0011563CMakeModulespublic2010-12-02 14:522011-03-28 12:10
Mikael Lund 
Mathieu Malaterre 
normaltrivialalways
closedno change required 
macdarwin10.6
CMake 2.8.3 
 
0011563: ability to parse *.h files as *.i interface files
Rather than writing separate SWIG interface files (*.i), swig commands are often included directly in C/C++ header files. I.e.

/*---- test.h files -----*/
#ifdef SWIG
%module faunus
%{
#include "test.h"
%}

class someclass {
  ...
};
/*----- end of header file -----*/

The cmake UseSWIG module, however, allows only passing of *.i files (other file extentions are filtered out and not passed on to swig). I suggest to allow for *.h files as well. This can be done with a simple patch - see below. This should be fine as one would (as far as I can tell) not add header files for other reasons than this.
$ diff UseSWIG.cmake UseSWIG.cmake.bak

197c197
< IF(${it} MATCHES ".*\\.(i|h)$")
---
> IF(${it} MATCHES ".*\\.i$")
199c199
< ELSE(${it} MATCHES ".*\\.(i|h)$")
---
> ELSE(${it} MATCHES ".*\\.i$")
201c201
< ENDIF(${it} MATCHES ".*\\.(i|h)$")
---
> ENDIF(${it} MATCHES ".*\\.i$")
No tags attached.
Issue History
2010-12-02 14:52Mikael LundNew Issue
2010-12-03 07:27Mathieu MalaterreNote Added: 0023690
2010-12-15 12:23David ColeAssigned To => Mathieu Malaterre
2010-12-15 12:23David ColeStatusnew => assigned
2010-12-16 17:44Mikael LundNote Added: 0024222
2011-03-28 12:10Mathieu MalaterreStatusassigned => closed
2011-03-28 12:10Mathieu MalaterreResolutionopen => no change required

Notes
(0023690)
Mathieu Malaterre   
2010-12-03 07:27   
Hi,

AFAIK your proposed patch will break backward compatibility.

Why not directly use:

SWIG_ADD_SOURCE_TO_MODULE(faunus output_generated_file_to_cleanup test.h)

just after the SWIG_ADD_MODULE.

Thx
(0024222)
Mikael Lund   
2010-12-16 17:44   
Thanks. I've solved the issue by simply creating a single .i where I import all the .h files.
Best, Mikael