[CMake] swig
Brad King
brad.king at kitware.com
Mon Aug 22 09:29:34 EDT 2005
Peter Brown wrote:
> How can I add the dependencies manually to a swig target? I have:
Hmmm...it looks like there is no way to do it using the
Modules/UseSWIG.cmake module that comes with CMake. Look at the file
and you'll see this custom command:
ADD_CUSTOM_COMMAND(
OUTPUT "${swig_generated_file_fullname}"
COMMAND "${SWIG_EXECUTABLE}"
ARGS "-${SWIG_MODULE_${name}_SWIG_LANGUAGE_FLAG}"
${swig_source_file_flags}
${CMAKE_SWIG_FLAGS}
${swig_special_flags}
${swig_extra_flags}
${swig_include_dirs}
-o "${swig_generated_file_fullname}"
"${swig_source_file_fullname}"
MAIN_DEPENDENCY "${swig_source_file_fullname}"
COMMENT "Swig source")
In order to add dependencies there needs to be a line like
DEPENDS ${swig_extra_depends}
after the MAIN_DEPENDENCY line. Unfortunately it doesn't look like the
interface to those SWIG macros was designed to enable extra dependencies
so even if you add the line there is no easy way to specify the value of
swig_extra_depends for each source file. You can submit a feature
request here:
http://www.cmake.org/Bug
but meanwhile you'll have to copy UseSWIG.cmake into your project and
add dependency support yourself. To get automatic dependencies you'll
have to hack something like what I described here:
http://www.cmake.org/pipermail/cmake/2005-August/007102.html
> ADD_DEPENDENCIES(target
> file1.h
> file2.h
> ...
> )
>
> If I choose as target "module_nameRUBY_wrap.cxx", cmake complains,
> that there is no such target. If I choose "module_name", it doesn't
> complain, but won't check for the dependencies.
ADD_DEPENDENCIES is only for top-level targets added with ADD_LIBRARY,
ADD_EXECUTABLE, and ADD_CUSTOM_TARGET. The next release of CMake
includes documentation for ADD_DEPENDENCIES that makes this much more clear.
-Brad
More information about the CMake
mailing list