Need help about forcing dependancy

Alexander Neundorf neundorf at kde.org
Tue Mar 21 19:00:10 CET 2006


On Tuesday 21 March 2006 15:55, Laurent Montel wrote:
> Hi,
> I have this code:
> set(COMBINEDHEADERSICAL
>    ${CMAKE_SOURCE_DIR}/libkcal/libical/src/libical/icalversion.h
>    ${CMAKE_SOURCE_DIR}/libkcal/libical/src/libical/icaltime.h
>    ${CMAKE_SOURCE_DIR}/libkcal/libical/src/libical/icalduration.h
>    ${CMAKE_SOURCE_DIR}/libkcal/libical/src/libical/icalperiod.h
>    ${CMAKE_SOURCE_DIR}/libkcal/libical/src/libical/icalenums.h
>    ${CMAKE_SOURCE_DIR}/libkcal/libical/src/libical/icaltypes.h
>    ${CMAKE_SOURCE_DIR}/libkcal/libical/src/libical/icalrecur.h
>    ${CMAKE_SOURCE_DIR}/libkcal/libical/src/libical/icalattach.h
>    ${CMAKE_SOURCE_DIR}/libkcal/libical/src/libical/icalderivedvalue.h
> ...
> }
>
> icalderivedvalue.h is a generated file generated by a custom command
> add_custom_command(OUTPUT
> ${CMAKE_SOURCE_DIR}/libkcal/libical/src/libical/icalderivedvalue.h COMMAND
> ${PERL_EXECUTABLE} ARGS -I${ICALSCRIPTS} ${ICALSCRIPTS}/mkderivedvalues.pl
> -i ${CMAKE_SOURCE_DIR}/libkcal/libical/src/libical/icalderivedvalue.h.in -h
> ${CMAKE_SOURCE_DIR}/libkcal/libical/design-data/value-types.csv >
> ${CMAKE_SOURCE_DIR}/libkcal/libical/src/libical/icalderivedvalue.h  
> DEPENDS ${VALUEDEPS} )
>
> (this macro works fine it's not a problem)
>
> But I am a macro which will create a ical.h file
>
> macro(CREATE_ICAL_FILE _out_FILE)
>     FILE(WRITE ${_out_FILE} "#ifdef __cplusplus\n")
>     FILE(APPEND ${_out_FILE} "extern \"C\" {\n")
>     FILE(APPEND ${_out_FILE} "#endif\n")
>     FILE(APPEND ${_out_FILE} "/*\n")
>     FILE(APPEND ${_out_FILE} " $$''Id''$$\n")
>     FILE(APPEND ${_out_FILE} "*/\n")
>
>     foreach (_current_FILE ${COMBINEDHEADERSICAL})
>         FILE(READ ${_current_FILE} _contents)
>         STRING(REGEX REPLACE "#include.*\"ical" "" _contents "${_contents}"
> ) STRING(REGEX REPLACE "#include.*\"config" "" _contents
> "${_contents}" )
>         STRING(REGEX REPLACE "#include.*\"pvl.h\"" "" _contents
> "${_contents}" )
>         STRING(REGEX REPLACE "\$$(Id|Locker): .+\$$" "" _contents
> "${_contents}" )
>         FILE(APPEND ${_out_FILE} "${_contents}")
>     endforeach (_current_FILE ${COMBINEDHEADERSICAL})
>
>     FILE(APPEND ${_out_FILE} "\n")
>     FILE(APPEND ${_out_FILE} "#ifdef __cplusplus\n")
>     FILE(APPEND ${_out_FILE} "}\n")
>     FILE(APPEND ${_out_FILE} "#endif\n")
> endmacro(CREATE_ICAL_FILE)
>
>
> But cmake doesn't like it.
> Because it doesn't know file
> (icalderivedvalue.h is not generated before to go to CREATE_ICAL_FILE
> macro)
>
> How force to call first custom_command which generate icalderivedvalue.h
> before to go to macro ?
>
> For me I want :
> -> generate icalderivedvalue.h
> -> after go to macro
>
> => I don't know how to define a dependancy "first custom_command, second
> macro.

This must be done differently.
The command is executed during the build, calling a macro gets executed during 
cmake time, so you can't add a dependency to it.

Instead you probably need an additional custom command, which has as output 
the ical.h file, and which calls cmake with a cmake script file, as it is 
done in KDE4Macros.cmake with kde4uic.cmake.

Bye
Alex
-- 
Work: alexander.neundorf AT jenoptik.com - http://www.jenoptik-los.de
Home: neundorf AT kde.org                - http://www.kde.org
      alex AT neundorf.net               - http://www.neundorf.net


More information about the Kde-buildsystem mailing list