[CMake] Swig dependencies again

William A. Hoffman billlist at nycap.rr.com
Thu Aug 17 21:47:09 EDT 2006


At 04:47 PM 8/17/2006, James Bigler wrote:
>I'm trying to implement the stuff found in
>
>http://www.cmake.org/Bug/bug.php?op=show&bugid=1731
>http://www.cmake.org/Bug/bug.php?op=show&bugid=2172
>http://www.cmake.org/pipermail/cmake/2005-August/007102.html
>http://www.itk.org/cgi-bin/viewcvs.cgi/Wrapping/CSwig/CMakeLists.txt?rev=1.55&root=Insight&view=auto
>
>Here's the general idea:
>
>Basically the custom command runs the first time because the output is
>not present.  The custom command generates its output AND a list of
>dependencies.  The list is dumped via copy-if-different to a file that
>is read by CMake.  This causes CMake to re-run and include the list of
>dependencies in the DEPENDS argument of the custom command.
>
>I can't seem to figure out how this is working in this giant file.
>
>CSWIG_CREATE_PYTHON_CXX_FILE seems to build the dependency file from swig:
>
>=====================================================================
>MACRO(CSWIG_CREATE_PYTHON_CXX_FILE Bin MasterIdx InputIdx InputXml OutputTclCxx Library LibraryIndexFiles)
>   SET(CINDEX)
>   FOREACH(MIDX ${MasterIdx})
>     SET(CINDEX ${CINDEX} -Cindex "${MIDX}")
>   ENDFOREACH(MIDX)
>   IF("${InputXml}" MATCHES "${ITK_CSWIG_PYTHON_NO_EXCEPTION_REGEX}")
>     SET(ITK_SWG_FILE "")
>   ELSE("${InputXml}" MATCHES "${ITK_CSWIG_PYTHON_NO_EXCEPTION_REGEX}")
>     SET(ITK_SWG_FILE "-l${ITK_TOP}/Wrapping/CSwig/itk.swg")
>   ENDIF("${InputXml}" MATCHES "${ITK_CSWIG_PYTHON_NO_EXCEPTION_REGEX}")
>   ADD_CUSTOM_COMMAND(
>     COMMENT "${OutputTclCxx} from "
>     SOURCE ${Bin}/${InputIdx}
>     COMMAND ${CSWIG}
>     ARGS ${ITK_SWG_FILE}
>          -I${ITK_SWIG_DEFAULT_LIB}
>          -I${ITK_SWIG_DEFAULT_LIB}/python
>          -noruntime ${CINDEX} ${IGNORE_WARNINGS} -depend ${Bin}/${InputXml}.depend
>          -outdir "${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}"
>          -o ${Bin}/${OutputTclCxx} -python -c++ ${Bin}/${InputXml}
>     TARGET ${Library}
>     OUTPUTS ${Bin}/${OutputTclCxx}
>     DEPENDS ${LibraryIndexFiles}  ${ITK_TOP}/Wrapping/CSwig/itk.swg ${ITK_TOP}/Wrapping/CSwig/itk.swg ${Bin}/${InputXml} ${CSWIG} )
>ENDMACRO(CSWIG_CREATE_PYTHON_CXX_FILE)
>====================================================================
>
>However, I don't see how the dependency file is pulled into CMake.
>
>Where is the copy-if-different in this example file?
>
>I'm so very confused and frustrated.  Perhaps someone could give me a simple example where dependency files are generated and pulled in, please.

The example you are showing here uses CableSwig, a modified version of swig.
This options creates a depend file:
>-depend ${Bin}/${InputXml}.depend

Later on in the cmake code that file is optionally included.

MACRO(GCCXML_CREATE_XML_FILE Source Bin Input Output Library)
# if the make program is not an IDE then include
# the depend file in a way that will make cmake 
# re-run if it changes
   SET(CABLE_SWIG_DEPEND)
   SET(CABLE_SWIG_DEPEND_REGENERATE)
   IF(${CMAKE_MAKE_PROGRAM} MATCHES "make")
     IF(EXISTS ${Bin}/${Output}.depend)
     ELSE(EXISTS ${Bin}/${Output}.depend)
       CONFIGURE_FILE(
         ${ITK_SOURCE_DIR}/Wrapping/CSwig/empty.depend.in
         ${Bin}/${Output}.depend @ONLY IMMEDIATE)
     ENDIF(EXISTS ${Bin}/${Output}.depend)
     INCLUDE(${Bin}/${Output}.depend)
   ELSE(${CMAKE_MAKE_PROGRAM} MATCHES "make")

-Bill




More information about the CMake mailing list