[CMake] Dependencies to generated C header files in another CMake
project
Stefan Granqvist
grankis at msn.com
Fri Dec 10 00:49:45 EST 2004
Hi,
I have the situation where one CMake project generates a couple of header
files, placing the resulting header files in ${PROJECT_BINARY_DIR} for the
project. The files are generated using one ADD_CUSTOM_COMMAND for each
header files to generate. In addition I also have a corresponding
ADD_CUSTOM_TARGET with a dummy target which depends on the generated header
file. My experiences is that the custom target is needed to make the
generated file to be produced also when if there is no other target in the
project using the generated file. Let us call this project P1.
I also have another CMake project (here called P2) that would also like to
use the generated header files from the P1. But I have failed to setup a
dependency in P2 that uses P1 to build the generated files. It would be very
nice if I could build P2 using make without having to build P1 manually,
prior to P2.
Both these projects are subdirectories in a CMake "main" CMake project (P0).
However, I would like to have the possibility to go directly to P2 (after
using CMake to generate the make files) and run "make" without first have
run make from P0's make file and thereby rely on the subdirectory order.
Similar inter-project dependencies seem to works when I have a dependency
between an executable in one project and a library in anther project.
However when using generated files and custom targets, it seems impossible
to get the same dependency to work. I think I have tried everything that is
described in the CMake book... I have tried using ADD_DEPENDENCIES between
targets in the two projects. I have also tried to use
SET_SOURCE_FILE_PROPERTIES both using GENERATED on the generated header
files, and the OBJECT_DEPENDS property. I also tested to add a dependency
from a target in P2 to the link library that P1 produces. In this case, P1
is forced to be created before the target in P2 is linked, but the generated
file might be produced too late, since a header file in P2 needs the
generated header file in P1.
The only solution I can think of is to change P1 to generate the file in a
fix location, and add the same rule in P2 (using ADD_CUSTOM_COMMAND) that
will produce the same generated file at the same location. This will
probably work, but the beauty of the inter-project dependencies from
built-in CMake targets is gone...
Does anyone have any advice how to solve this problem? Any comments are
welcome. I am using CMake version 2.0.3 on cygwin/x86 and Solaris/Sparc
hosts.
Best Regards
Stefan
_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now!
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
More information about the CMake
mailing list