I have a project in which the output of one custom command is used as the input to another, but in a different directory. So for example:
Directory lib/CMakeLists.txt
contains:
add_custom_command(
OUTPUT libfoo.xx
COMMAND <command to build libfoo.xx>
)
add_custom_target(libfoo DEPENDS libfoo.xx)
Directory test/CMakeLists.txt
contains:
add_custom_command(OUTPUT test.yy
COMMAND <command to build test.yy>
DEPENDS "${PROJECT_BINARY_DIR}/lib/libfoo.xx"
)
So I need to make sure that libfoo is build before test.yy. The docs say that the DEPENDS clause of add_custom_command() can only have file-level dependencies. Let's try that and see what happens:
No rule to make target 'lib/libfoo.xx', needed by 'test/test.yy'. Stop.
If on the other hand, I attempt to create a target-level dependency by saying DEPENDS libfoo
, then the error changes to:
No rule to make target 'libfoo', needed by 'test/test.yy'. Stop.
So it seems neither file-level or target-level dependencies will work here. Is there any way to have the output from one custom command be the input to another custom command, in a different directory?