[CMake] CUSTOM COMMAND triggered several times

Alexander Neundorf a.neundorf-work at gmx.net
Fri Sep 4 14:05:02 EDT 2009


On Tuesday 18 August 2009, Arnaud Devalkeneer wrote:
> Hi,
>
> I have a strange behaviour with add_custom_comand with its output form.
> This command is called two or three times, even the file dependency has not
> been changed and the output exists.
>
> I wrote :
>
> ADD_CUSTOM_COMMAND(
>     OUTPUT ${${PROJECT_NAME}_WOK_GENERATED_INCLUDE}
>     COMMAND woktcl ARGS ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.tcl
>     DEPENDS ${${PROJECT_NAME}_CDLS}
>     COMMENT "Generating ${PROJECT_NAME} include files from CDLs"
>   )
>
> ADD_LIBRARY(${PROJECT_NAME} SHARED
>             ${${PROJECT_NAME}_SRCS}
>             ${${PROJECT_NAME}_WOK_GENERATED_INCLUDE}
>
> The problem is :
> when I update a cdl file involved in the list ${${PROJECT_NAME}_CDLS}, the
> custom command is triggered several times.
> And when I re-do a make, this is triggered again regardless the fact that I
> do not change the cdl file again.
>
> So I wonder what the easiest way is in cmake to trigger ONCE a command if
> cmake detects that a list of OUTPUT does not exists and/or detects a change
> in the DEPEND list.
> And to be sure that otherwise the custom command is not called.
>
> >From documentation I had understood that this can be achieved by the way I
>
> am using, but something goes wrong.
>
> Is there anything I could try?

In doubt, make sure that ${${PROJECT_NAME}_WOK_GENERATED_INCLUDE} and all 
files in ${${PROJECT_NAME}_CDLS} are full absolute paths. Maybe 
${${PROJECT_NAME}_WOK_GENERATED_INCLUDE} is a relative path ?

Alex


More information about the CMake mailing list