[CMake] Dependency build order problem
Trevor Kellaway
tkellaway at asl-electronics.co.uk
Sat Jan 5 07:57:24 EST 2008
Hi,
I have an issue where I need to force the order some libraries are built
in prior to building the application. Here is a simplified example (also
attached) showing the issue (the real problem is building multiple unit
test EXEs and running them under a nightly build using CTest):
Library "e" consists of the following, with "e_auto.h" being auto
generated:
e_auto.h
e.h
e.c
Library "d" depends on the "e_auto.h" file:
Includes "e_auto.h"
d.h
d.c
The application uses libraries "d.a" and "e.a".
There are multiple CMakeLists in a tree:
./source/d/CMakeLists.txt
./source/e/CMakeLists.txt
./source/app/CMakeLists.txt
./source/CMakeLists.txt
The build is being perform in ./build with the command 'CMake -G"MinGW
Makefiles" ..\source'
I can't find a way to tell CMake that library "d" depends on a
side-effect of library "e" being built first.
An obvious workaround is to change the order of the ADD_SUBDIRECTORY in
the top level CMakeLists.txt, changing:
ADD_SUBDIRECTORY (d ${CMAKE_BINARY_DIR}/tmp/d)
ADD_SUBDIRECTORY (e ${CMAKE_BINARY_DIR}/tmp/e)
ADD_SUBDIRECTORY (app ${CMAKE_BINARY_DIR}/tmp/app)
to
ADD_SUBDIRECTORY (e ${CMAKE_BINARY_DIR}/tmp/e)
ADD_SUBDIRECTORY (d ${CMAKE_BINARY_DIR}/tmp/d)
ADD_SUBDIRECTORY (app ${CMAKE_BINARY_DIR}/tmp/app)
This is fine for this simple example, but my real world example is
building multiple unit test exe files and the interdependence of them
defeats attempts to control the build order via ADD_SUBDIRECTORY (they
are built out of order).
Of course if I manually force the "e" library target to be built prior
to the "all" target this also works:
make e all
However, I can't use this approach as the build is being performed by
CTest and I can't control (or can I?) the build order on the command
line for a continuous and nightly build.
What is the right way to force this style of dependency?
If I force a dependency for "d.c" on "e_auto.h":
SET_SOURCE_FILES_PROPERTIES (d.c PROPERTIES OBJECT_DEPENDS
${CMAKE_BINARY_DIR}/e_auto.h)
The when I make I get:
*** No rule to make target `e_auto.h'
As it can't locate the ADD_CUSTOM_COMMAND in e's CMakeLists.txt from d's
CMakeLists.txt (running from the top-level CMakeLists.txt).
Any help greatly appreciated.
- Trevor
-------------- next part --------------
A non-text attachment was scrubbed...
Name: source.zip
Type: application/x-zip-compressed
Size: 2411 bytes
Desc: source.zip
Url : http://public.kitware.com/pipermail/cmake/attachments/20080105/591960d9/source.bin
More information about the CMake
mailing list