[CMake] macro within a custom command

Brandon J. Van Every bvanevery at gmail.com
Fri May 19 03:53:22 EDT 2006


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)

and then put this inside of a custom command so I don't have to type the 
same boring thing for every single custom command.

ADD_CUSTOM_COMMAND(
  OUTPUT ${Chicken_BINARY_DIR}/batch-driver.c
  MAIN_DEPENDENCY batch-driver.scm
  DEPENDS parameters.scm
  COMMAND SIMPLE_SCM_TO_C(batch-driver)
)

But MACRO doesn't actually work that way.  It insists on being 
constructed out of commands.  So I write:

MACRO(SIMPLE_SCM_TO_C root)
  EXECUTE_PROCESS(${VALID_CHICKEN} ${Chicken_SOURCE_DIR}/${root}.scm 
-output-file ${Chicken_BINARY_DIR}/${root}.c ${CHICKEN_FLAGS})
ENDMACRO(SIMPLE_SCM_TO_C)

I try to use it in the ADD_CUSTOM_COMMAND as above, but on the line 
containing COMMAND, I get, <<Parse error. Function missing ending ")".  
Instead found left paren with text "(".>>  As far as I can tell, nothing 
is actually mismatched.  Rather, it appears that a MACRO simply cannot 
be used on a COMMAND line.

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.  ADD_FILE_DEPENDENCIES is 
useless for that purpose.  So I wanted to use a text macro to preserve 
what little is left of my sanity, so that I don't have to cut 'n' paste 
the same stupid rules 100 times, and have people make gratuitous 
mistakes over time with 'em.


Cheers,
Brandon Van Every



More information about the CMake mailing list