[CMake] Adding a dependency
Wade Williams
wadesworld at mac.com
Fri Jan 23 13:11:00 EST 2009
I have a project structure that looks like this:
project
|
| - lib
| ----bin
| ----util
| --------inc
| --------src
| - app
| ----bin
| ----inc
| ----src
In short, each library in the project lives under project/lib. Built
libraries are stored in project/lib/bin. Each library subdirectory
(i.e. util) has a CMakeLists.txt to build that particular library. In
the lib folder is a CMakeLists.txt which does add_subdirectory() on
all the subdirectories. So far, so good - works like a charm.
The executable lives under project/app. The built executable is
stored in project/app/bin. There is a CMakeLists.txt in project/app
to build the application executable.
Now for the problem. How do I add the libraries as dependencies?
I can't use add_dependencies() because the app/CMakeLists.txt doesn't
know about the targets in the library directories. I suppose I could
do:
add_subdirectory(../../lib ../../lib/bin)
so it would know about those targets, but that doesn't seem the right
solution.
I can certainly use find_library() to add the built libraries to my
executable, but then my executable is not dependent upon being them
and linking will fail if make was not executed in lib first.
Now, I certainly plan to have a project/CMakeLists.txt file that does
add_subdirectory() on lib and app. Thus, if someone builds from that
top level, it should all work if I use find_library() at the
application level. However, I'd like it also to work if someone cd's
into the application directory and types "cmake . ; make".
Any thoughts?
Thanks,
Wade
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090123/8510d0bc/attachment.htm>
More information about the CMake
mailing list