I have a lot of custom CMake commands, so I end up with a lot of repetition of this pattern in build scripts, e.g.
set(PREREQ ${CMAKE_CURRENT_SOURCE_DIR}/foo.txt ${CMAKE_CURRENT_SOURCE_DIR}/bar.txt)
add_custom_command(
OUTPUT baz.txt
COMMAND cat ${PREREQ} > baz.txt
DEPENDS ${PREREQ}
)
add_custom_target(a ALL DEPENDS baz.txt)
Are there equivalents of GNU Make automatic variables in CMake ($@
, $<
, etc) so I can avoid specifying inputs/outputs twice (dependencies, output, and command)?
How else can I DRY it up?