[CMake] Importing a static library, then adding dependencies. Should the dependencies be transitive? They aren't for me!

2016-01-26 Thread Johnson, Matt (GE Healthcare)
I'm using the Visual Studio 2013 generator and cmake 3.4.3.
Example:
add_library(NS::a_lib STATIC IMPORTED)
set_target_properties(NS::a_lib PROPERTIES IMPORTED_LOCATION ${a_lib_location})
set_target_properties(NS::a_lib PROPERTIES INTERFACE_LINK_LIBRARIES 
"/path/to/a/another_lib.lib")
set_target_properties(NS::a_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES 
"an/include/dir")

add_library(NS::b_lib STATIC IMPORTED)
set_target_properties(NS::b_lib PROPERTIES IMPORTED_LOCATION ${b_lib_location})
add_dependencies(NS::b_lib NS::a_lib)

add_executable(test_exe main.cpp)
target_link_libraries(test_exe NS::b_lib) #I expect to pull in all of A's stuff 
too.  Howver, it doesn't for me.

Assume I have two libraries, A and B.  A has some libraries that it links to.  
B depends on A.  I add import targets for both A and B.  I use add_dependencies 
to signal the B->A dependency.  When I use target_link_libraries for an 
executable and only list B, should it auto pull in A and A's dependencies?  For 
me, all I get is B.  I don't get any of its dependencies.  Nor do I get A's 
include directories.  Am I doing something wrong or misunderstanding the usage 
of these functions?

I've done a lot of googling and searching the mailing list.  I do see a couple 
of bugs that revolved around this, but all of them seem to indicate that they 
are fixed and this is supported.  Am I wrong?  Do I have to manually set the 
INTERFACE_LINK_LIBRARIES of B?

Thanks for your help!
Matt
  
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake


Re: [CMake] Importing a static library, then adding dependencies. Should the dependencies be transitive? They aren't for me!

2016-01-26 Thread Nils Gladitz

On 26.01.2016 21:25, Johnson, Matt (GE Healthcare) wrote:

I'm using the Visual Studio 2013 generator and cmake 3.4.3.
Example:
add_library(NS::a_lib STATIC IMPORTED)
set_target_properties(NS::a_lib PROPERTIES IMPORTED_LOCATION ${a_lib_location})
set_target_properties(NS::a_lib PROPERTIES INTERFACE_LINK_LIBRARIES 
"/path/to/a/another_lib.lib")
set_target_properties(NS::a_lib PROPERTIES INTERFACE_INCLUDE_DIRECTORIES 
"an/include/dir")

add_library(NS::b_lib STATIC IMPORTED)
set_target_properties(NS::b_lib PROPERTIES IMPORTED_LOCATION ${b_lib_location})
add_dependencies(NS::b_lib NS::a_lib)

add_executable(test_exe main.cpp)
target_link_libraries(test_exe NS::b_lib) #I expect to pull in all of A's stuff 
too.  Howver, it doesn't for me.

Assume I have two libraries, A and B.  A has some libraries that it links to.  B 
depends on A.  I add import targets for both A and B.  I use add_dependencies to 
signal the B->A dependency.  When I use target_link_libraries for an executable 
and only list B, should it auto pull in A and A's dependencies?  For me, all I get 
is B.  I don't get any of its dependencies.  Nor do I get A's include directories. 
 Am I doing something wrong or misunderstanding the usage of these functions?

I've done a lot of googling and searching the mailing list.  I do see a couple 
of bugs that revolved around this, but all of them seem to indicate that they 
are fixed and this is supported.  Am I wrong?  Do I have to manually set the 
INTERFACE_LINK_LIBRARIES of B?


Yes you have to set INTERFACE_LINK_LIBRARIES.
add_dependencies() is for order (not link) dependencies.

Nils

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake