[Cmake] ADD_DEPENDENCIES problem
Alexander Neundorf
a.neundorf-work at gmx.net
Fri May 28 04:55:43 EDT 2004
Hi,
I have the following problem:
I want to build library foo with cmake. This library foo depends on
library bar, which lives in a subdir of library foo.
Now library foo is a "foreign" library, which is built with some special
tools from a config file. When building the library bar, it starts with
only a config file, a tool reads this config files and creates all the
sources and headers and a makefile, and then make has to be started.
Library foo uses these generated headers.
I did the following:
ADD_CUSTOM_COMMAND(OUTPUT libbar/bar.h COMMAND ./build_bar DEPENDS
libbar/bar.config)
If the files already exist and I change bar/bar.config, this command is
executed again when I try to build libfoo.
But for the case that libbar/bar.h doesn't exist yet, cmake doesn't
procude a dependency from my libfoo to the file libbar/bar.h, so that
./build_bar is not executed when I try to build libfoo.
So I tried to use ADD_DEPENDENCIES()
It seems this adds a dependency to a library. The problem is, this
dependeny is added when the library is being linked, i.e. after the
objects the library consists of. So the make tries to build the objects
for libfoo (which depend on libbar/bar.h , but cmake didn't produce this
dependency sins libbar/bar.h doesn't exist yet), so the objects don't
build, and the rule to build libbar which would produce the headers would
be invoked afterwards, i.e. too late.
So I think I need a way to specify a dependency for the objects or sources
of libfoo. Is there a way to do this ?
I found an ugly workaround:
ADD_CUSTOM_TARGET(bar-target ALL
./build_bar
DEPENDS ./libbar/bar.config)
FILE(WRITE aaaadummy.c "void dummy() {}\n")
ADD_LIBRARY(aaaadummy aaaadummy.c)
ADD_DEPENDENCIES(aaaadummy ecos-target)
ADD_DEPENDENCIES(libfoo aaaadummy)
This way my libfoo depends on libaaaadummy, which depends on bar-target,
which builds libbar. Since libaaaadummy is a lib and starts with a lot of
"a"s, it becomes (usually) the first target in the all: section of the
Makefile. Kindof works, but there must be a better way.
Simply ADD_DEPENCIES(libfoo bar-target)
doesn't work, because at first the objects for libfoo are being built
(which fails), and after that bar-target is being built.
I'm using cmake 1.9 (i.e. cvs after 1.8).
Any ideas ?
Bye
Alex
--
"Sie haben neue Mails!" - Die GMX Toolbar informiert Sie beim Surfen!
Jetzt aktivieren unter http://www.gmx.net/info
More information about the Cmake
mailing list