[CMake] Problem with ADD_CUSTOM_COMMAND & ARGS
Tyler Roscoe
tyler at cryptio.net
Wed Sep 16 16:51:17 EDT 2009
On Wed, Sep 16, 2009 at 04:27:48PM -0400, Eric Tellefsen wrote:
> Solaris make
My condolences :p.
> My problem has to do with the ARGS section of the custom command.
> Specifically the 'legacy' Makefile uses an argument --include-regex
> "#../../XML/Types/##" in order to remove this prefix from the generated
> HXX files, where applicable.
>
> ----------- Code which invokes macro
> SET( STUBDIR ${CMAKE_BINARY_DIR}/Stubs )
> SET( TYPE_XSD_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
> SET( TYPE_REGEX_FLAG "#../../XML/Types/##" )
>
> XSDGenCXXSources( TypesOutputFiles
> "${TYPE_REGEX_FLAG}"
> "${TYPE_XSD_DIR}"
> "${STUBDIR}"
> "${CMAKE_CURRENT_SOURCE_DIR}"
> )
>
> ----------- Macro -----------------------------
> macro ( XSDGenCXXSources OUTPUT_FILES REGEX XSD_DIR OUTPUT_DIR Working_Dir
> )
>
> SET( XSD_EXE $ENV{CODE_SYNTHESIS_HOME}/bin/xsd )
>
> ADD_CUSTOM_COMMAND(
> OUTPUT ${${OUTPUT_FILES}}
> COMMAND mkdir
> ARGS -p ${OUTPUT_DIR}
> COMMAND ${XSD_EXE}
> ARGS cxx-tree --generate-serialization --output-dir
> ${OUTPUT_DIR} --include-regex " ${REGEX} " ${XSD_DIR}/*.xsd
> COMMENT "Generating CXX files from ${XSD_DIR} and placing them
> in ${OUTPUT_DIR}"
> WORKING DIRECTORY ${Working_Dir}
> )
> endmacro ( XSDGenCXXSources )
Usually, problems like this are caused by improper quoting. First, try
the VERBATIM flag to add_custom_command.
You can inspect the command line CMake generates for your custom command
by doing make VERBOSE=1. Hopefully this will give you a clue as to what
is getting mangled.
Finally, arguments to macros occasionally do funny things since they
aren't "real" variables, but that's probably not the problem here.
tyler
More information about the CMake
mailing list