[CMake] CUSTOM COMMAND triggered several times

Arnaud Devalkeneer adevalkeneer at gmail.com
Tue Aug 18 06:47:24 EDT 2009


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.


More information about the CMake mailing list