I\'m trying to get a file produced by an add_custom_command in one directory to be a dependency of an add_custom_command in another directory.
In the first directory (li
The cmake documentation says the following about the DEPENDS parameter:
The DEPENDS option specifies files on which the command depends. If any dependency is an OUTPUT of another custom command in the same directory (CMakeLists.txt file) CMake automatically brings the other custom command into the target in which this command is built. If DEPENDS specifies any target (created by an ADD_* command) a target-level dependency is created to make sure the target is built before any target using this custom command.
Therefore I think you will have to define a target using add_custom_target and depend on this.
The documentation for add_custom_target says:
Dependencies listed with the DEPENDS argument may reference files and outputs of custom commands created with add_custom_command() in the same directory (CMakeLists.txt file).
So you will have to use add_custom_command and add_custom_target as follows:
In the first directory generating the bc file you do
add_custom_command(OUTPUT libcore.bc ... ) # just as in your question
add_custom_target (LibCoreBC DEPENDS libcore.bc)
In the second directory you do
add_custom_command (OUT ${OBJ_FILE} DEPENDS LibCoreBC ....)