[CMake] macro within a custom command

Brad King brad.king at kitware.com
Fri May 19 09:46:34 EDT 2006


Brandon J. Van Every wrote:
> What I really want is a simple text substitution macro, of the form:
> 
> MACRO(SIMPLE_SCM_TO_C root)
>  ${VALID_CHICKEN} ${Chicken_SOURCE_DIR}/${root}.scm -output-file 
> ${Chicken_BINARY_DIR}/${root}.c ${CHICKEN_FLAGS})
> ENDMACRO(SIMPLE_SCM_TO_C)
[snip]
> If there's no way to perform a simple text substitution on a custom 
> build rule's COMMAND line, then that's really really irritating.  I 
> already had to expand out all my build rules into explicit 
> ADD_CUSTOM_COMMAND statements, because only DEPENDS works on 
> source-file-to-source-file dependencies.

Try using FOREACH:

FOREACH(root batch-driver ...)
   ADD_CUSTOM_COMMAND(
    OUTPUT ${Chicken_BINARY_DIR}/${root}.c
    MAIN_DEPENDENCY ${root}.scm
    DEPENDS parameters.scm
    COMMAND ${VALID_CHICKEN} ${Chicken_SOURCE_DIR}/${root}.scm 
-output-file ${Chicken_BINARY_DIR}/${root}.c ${CHICKEN_FLAGS}
   )
ENDFOREACH(root)

 > ADD_FILE_DEPENDENCIES is useless for that purpose.

The ADD_FILE_DEPENDENCIES macro has a horrible name and was not well 
documented or intentionally added to the release.  It is meant only for 
the deprecated OBJECT_DEPENDS target property.  Please ignore its 
existence.  I'm going to try to get it removed completely in 2.4.3 since 
it was not in the 2.2 release.

-Brad


More information about the CMake mailing list