[CMake] Building ADD_CUSTOM_TARGET dependency
William A. Hoffman
billlist at nycap.rr.com
Mon Nov 14 09:37:59 EST 2005
You may want to look here:
http://public.kitware.com/Wiki/CMake_FAQ#How_can_I_generate_a_source_file_during_the_build.3F
At 09:02 AM 11/14/2005, Alex Brooks wrote:
>Hi,
>
>I've used CMake for a while now, but I can't seem to do the following kinda
>complicated task:
>[ I'm using CMake version 2.2.2 ]
>
>
>(1): ADD_CUSTOM_TARGET definition
>================================
>
>I want to generate .cfg files from .def files using the following macro:
>
>MACRO( GENERATE_FROM_DEF DEF_FILE )
> STRING( REGEX REPLACE "\\.def" ".cfg" CFG_FILE ${DEF_FILE} )
> ADD_CUSTOM_TARGET(
> ${CFG_FILE} ALL
> generatecfg ${DEF_FILE} ${CFG_FILE}
> DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${DEF_FILE} generatecfg )
>ENDMACRO( GENERATE_FROM_DEF DEF_FILE )
>
>The problem is that generatecfg is a c++ executable that has to be compiled
>first. That's why I put it as a dependency (the last term in
>ADD_CUSTOM_TARGET above).
>
>(2): generatecfg taget definition
>==========================
>
>The generatecfg target is defined as follows (in
>src/utils/liborcadefutil/orcadefutil/):
>
>INCLUDE_DIRECTORIES( ${PROJ_SOURCE_DIR}/src/utils/liborcadefutil )
>ADD_LIBRARY( OrcaDefUtil SHARED defparser.cpp componentdefinition.cpp )
>ADD_EXECUTABLE( generatecfg generatecfg.cpp )
>TARGET_LINK_LIBRARIES( generatecfg OrcaDefUtil )
>
>The important bit here is the INCLUDE_DIRECTORIES line, which is required to
>build generatecfg.cpp.
>
>(3): generatecfg use
>=================
>
>At some point (from src/components/lasermon) I call the macro:
>
>GENERATE_FROM_DEF( lasermon.def )
>
>This command relies on generatecfg. From (1), CMake knows that generatecfg
>has to be built first. So if I try to compile from the
>src/components/lasermon directory I get:
>
>$ cd src/components/lasermon
>$ make VERBOSE=1
>
><snip>
>make[3]: Entering directory `/home/users/a.brooks/cvs/orca2'
>/home/users/a.brooks/bin/g++
>src/utils/liborcadefutil/orcadefutil/generatecfg.cpp -o
>src/utils/liborcadefutil/orcadefutil/generatecfg
>src/utils/liborcadefutil/orcadefutil/generatecfg.cpp:1:35:
>orcadefutil/defparser.h: No such file or directory
><snip>
>
>The problem is that when compiling generatecfg, CMake seems to have neglected
>to add "-Isrc/utils/liborcadefutil/orcadefutil/". It should have done this
>from the "INCLUDE_DIRECTORIES( ${PROJ_SOURCE_DIR}/src/utils/liborcadefutil )"
>line in (2).
>
>Does anyone know what's happening here? I've been battling with this for a
>while...
>
>
>Thanks very much,
>
>Alex
>_______________________________________________
>CMake mailing list
>CMake at cmake.org
>http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list