[CMake] What is the preferred method of establishing the dependence of a custom command on an executable target?

Bill Hoffman bill.hoffman at kitware.com
Mon Apr 9 16:08:50 EDT 2007


Alan W. Irwin wrote:
>
> Also, as part of the investigation I found that preparing the header 
> in one
> subdirectory with the custom command and putting that header in the 
> source
> list of a library built in a different subdirectory does not work.  The
> library build in the separate subdirectory has no idea that the header is
> generated, and therefore errors out with a missing file message.  I
> therefore stuck with my original method which was to use 
> ADD_DEPENDENCIES to
> make the library depend on the custom target, and that seems to work 
> fine.
One thing to watch out for is make -j N builds where N > 1.   Currently, 
you have to
hack around a problem in CMake to get that to work in a situation like this.
You have to create a custom_target that creates the .h file.   Then use
add_dependencies to make sure that custom target is build before the
other targets that depend on it.   The problem only shows up when building
static libraries.

-Bill




More information about the CMake mailing list