<div dir="ltr">I have this same question. There doesn't seem to be a way to have these imported target see other targets. I can pull the full path out for this target, but it seems less elegant.</div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Dec 22, 2011 at 11:08 AM, Marco Corvo <span dir="ltr"><<a href="mailto:marco.corvo@pd.infn.it" target="_blank">marco.corvo@pd.infn.it</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
I have a big project which can be used in two ways: either the user checks out all the packages and makes a big "make" or he checks out only a subset and build them linking against a given release, which is installed somewhere else on his machine.<br>
<br>
In this last option the libraries "installed somewhere" are trated as "external" dependencies by the working packages. The problem I have comes out when I have a transitive dependency.<br>
To make an example, I check out two packages: package A, which builds a static library and a binary and depends on an external library B, and a package C.<br>
The cmake code to make A know where to find libB.a is the following:<br>
<br>
add_library(B STATIC IMPORTED)<br>
set_target_properties(B PROPERTIES IMPORTED_LOCATION "/path/to/external/lib/libB.a"<br>
IMPORTED_LINK_INTERFACE_<u></u>LIBRARIES "C D"<br>
)<br>
<br>
which is read inside my CMakeLists.txt with:<br>
<br>
import(MyFile.cmake)<br>
add_library(A foo.cc)<br>
add_executable(bar bar.cc)<br>
target_link_libraries(bar A B)<br>
<br>
Here's the point. My library B depends on C, which I checked out with A and so is kind of "local" to my build, in fact I have:<br>
<br>
add_directory(A)<br>
add_directory(C)<br>
<br>
in my main CMakeLists.txt, but when I build the packages I always get:<br>
<br>
No rule to make target `../../lib/libC.a', needed by `../../bin/bar'. Stop.<br>
<br>
Looking into the link.txt file generated by cmake, I see that the dependencies are correct, that is the command is:<br>
<br>
g++ .... -o bar ../../lib/libA.a /path/to/external/lib/libB.a ../../lib/libC.a /path/to/external/lib/libD.a<br>
<br>
So this is not a problem of how I declare my dependencies among packages, rather something related to the way cmake deals with the targets. What sounds strange to me is that package C is perfectly known to cmake, as I put add_directory(C) to my CMakeLists.txt. In fact libC.a is built, but always *after* bar, like cmake were not aware that C, on which bar depends, must be built before it.<br>
<br>
I suspect that cmake thinks that, since B is "external", it's up to the user to provide a rule to force the build of dependencies. Put it another way: if you have packages A and C locally and B is an "external" but depends on C, then cmake has no means to write the target libC.a that triggers the build of C before linking A with B.<br>
<br>
Is there a way, if any, to instruct cmake to write the targets so that the dependencies chain is preserved and if an external depends on an internal, the internal is built before the link stage?<br>
<br>
Thanks in advance.<br>
<br>
Marco<br>
<br>
-- <br>
Marco Corvo<br>
SuperB Experiment<br>
CNRS - Orsay<br>
c/o INFN Padova<br>
<br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/<u></u>opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/<u></u>CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/<u></u>listinfo/cmake</a><br>
</blockquote></div><br></div>