I’m working on a cross-compilation project with a top-level
CMakeLists.txt file generating
Makefiles. Some of the cross-compiled source code is generated by a host-based code generation tool; since that tool needs a different toolchain, the top-level
ExternalProject_Add() to invoke the code generator subdirectory’s
BUILD_ALWAYS set to
TRUE. The code generation targets depend on the code generator target, so during the initial build the code generator is built, and then the code is generated, and then the whole shebang is compiled into the final result. (To be clear: there’s no downloading involved; all of the external project code is local.)
If I change the source of the code generator then the code generator executable will be properly rebuilt on the next
make. Problem: the dependent code generation targets will NOT be rebuilt. There seems to be no way with an
ExternalProject_Add() target to indicate when/if any dependencies of the target should be rebuilt.
For instance, if my code generator target were configured using
Add_Custom_Command(), then I’d use its
OUTPUT keyword to specify the resulting executable file. I’d then create a convenience target using
DEPENDS keyword referenced the
OUTPUT file. I’d then have the code generation targets depend on this convenience target. But, that won’t work for
Is there a way to configure an
ExternalProject_Add()-based target so that dependent targets will be automatically rebuilt when the main target’s output changes?
P.S. This is similar to the following post: Generate dependency on external projects .However, in my case nothing is being downloaded, and the concern is not the rebuilding of the code generator when its source changes (that works), but the rebuilding of the code generation targets when the code generator changes (that doesn’t).