Hi, On Thu, May 17, 2012 at 10:50 PM, David Doria <daviddo...@gmail.com> wrote:
> On Thu, May 17, 2012 at 2:18 AM, Petr Kmoch <petr.km...@gmail.com> wrote: > >> Hi David, >> >> there's a target property LINK_INTERFACE_LIBRARIES (and >> per-configuration variants) which can be used for this purpose. >> Starting with 2.8.7, target_link_libraries() also accepts >> LINK_INTERFACE_LIBRARIES as a new argument mode, setting the property >> instead of linking. >> >> Petr > > > Petr, > > I tried the following, but in both cases (target_link_libraries > and set_target_properties) I still get a linker error that it can't find > TestB(). > > cmake_minimum_required(VERSION 2.6) > PROJECT(Test) > > add_library(TestB TestB.cpp) > > # TestA depends on TestB > add_library(TestA TestA.cpp) > #target_link_libraries(TestA LINK_INTERFACE_LIBRARIES TestB) > set_target_properties(TestA PROPERTIES LINK_INTERFACE_LIBRARIES "TestB") > You forgot to link TestA to TestB here, I guess your c++ code currently does not actually expose any dependency? Thats why cmake doesn't include TestB when linking the executable. The LINK_INTERFACES_LIBRARIES only helps cmake to decide when a particular library doesn't need to be added to the linker-command for the executable. By default cmake will link the executable against the libraries specified by you and any libraries these link to - recursively. The property just allows to disable this behaviour by defining which dependent libraries a given library exposes in its public API and hence which dependent libraries an executable might need to link against in addition to the main library. Andreas
-- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake