Steve
Steve

Reputation: 41

How can I make swig_add_library (cmake) process the provided files

When using swig_add_library provided by the cmake "plugin" UseSWIG.cmake as follows

swig_add_library (mylib LANGUAGE tcl SOURCES foo.ii)

foo.ii is silently ignored. If I rename foo.ii to foo.i and then

swig_add_library (mylib LANGUAGE tcl SOURCES foo.i)

foo.i is processed as expected. How would I need to write my CMakeLists.txt so that swig_add_library process the SOURCES provided as an argument to its call.

Upvotes: 0

Views: 1650

Answers (1)

Mizux
Mizux

Reputation: 9281

I think, the extension .i for swig file is hardcoded (i.e. mandatory) in UseSwig.cmake macro.

macro(SWIG_ADD_LIBRARY name)
... 
foreach(it ${_SAM_SOURCES})
    if(${it} MATCHES "\\.i$")
      set(swig_dot_i_sources ${swig_dot_i_sources} "${it}")
    ...
endforeach()
...
foreach(it ${swig_dot_i_sources})
  SWIG_ADD_SOURCE_TO_MODULE(${name} swig_generated_source ${it})
  set(swig_generated_sources ${swig_generated_sources} "${swig_generated_source}")
  list(APPEND swig_generated_targets "${swig_gen_target}")
endforeach()

src: https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/UseSWIG.cmake#L306

Upvotes: 1

Related Questions