[CMake] Re: ADD_CUSTOM_TARGET not behaving as advertized?

Brad King brad.king at kitware.com
Wed Aug 3 13:40:24 EDT 2005


Chris Green wrote:
>     ADD_DEPENDENCIES ( hook
>       ${CMAKE_BINARY_DIR}/${script_name}
>       )

Read the documentation for ADD_DEPENDENCIES.  It is meant for use only 
between top-level targets (added with ADD_LIBRARY, ADD_EXECUTABLE, or 
ADD_CUSTOM_TARGET).  You need to build a list of custom command outputs 
and then list them when adding the target:

SET(SCRIPT_OUTPUT_LIST)

FOREACH ( script ${ARGV} )
   ...
   SET(SCRIPT_OUTPUT_LIST ${SCRIPT_OUTPUT_LIST}
       ${CMAKE_BINARY_DIR}/${script_name})
   ADD_CUSTOM_COMMAND (
     OUTPUT ${CMAKE_BINARY_DIR}/${script_name}
     ...
     )
ENDFOREACH ( script ${ARGV} )

# Driver target to depend on all the custom command outputs
# and force them to build.
ADD_CUSTOM_TARGET(hook ALL DEPENDS ${SCRIPT_OUTPUT_LIST})

-Brad


More information about the CMake mailing list