[CMake] ADD_CUSTOM_COMMAND split on multiple lines
Tyler Roscoe
tyler at cryptio.net
Wed Jun 23 11:22:47 EDT 2010
On Wed, Jun 23, 2010 at 03:58:59PM +0200, Aeschbacher, Fabrice wrote:
> Is there any way to split a custom command on multiple lines (for readability), e.g:
>
> ADD_CUSTOM_COMMAND(
> OUTPUT .patched
> COMMAND for patch in ${ARGV}; do \
> echo "applying $patch; \
> patch -p1 < $patch \
> done
> COMMAND touch .patched
> VERBATIM
> )
Should be possible. I don't think you want to escape your newlines, but
you might need to quote the entire COMMAND string.
> If not, is there any way to run a (cmake) function/macro, e.g:
>
> MACRO(mymacro)
> ...
> ENDMACRO()
>
> ADD_CUSTOM_COMMAND(
> OUTPUT .patched
> COMMAND mymacro()
> COMMAND touch .patched
> VERBATIM
> )
This doesn't make sense because mymacro is available at configure time
but your custom command will run at build time.
One way to do what you want is to put the definition and call of
mymacro() in a script, then run that script at build time with "COMMAND
${CMAKE_COMMAND} -P mymacro.cmake".
tyler
More information about the CMake
mailing list