On Wed, 2019-07-03 at 18:55 +0530, vinay kumar Kotegowder wrote:
>  I want to build lib2 static library with pre-built lib1 static
> library.
>  Does this work?
> 
>  add_library(lib1 STATIC lib1.c)
>  add_library(lib2 STATIC lib2.c)
>  target_link_libraries(lib2 INTERFACE lib1)

Yes, this will work.

>  Also, Kyle said linking against lib2 will link against both lib1 and
> lib2. Is there a static way of checking the relation between lib1 and
>  lib2 ? Separately and after using INTERFACE option with lib1 and
> lib2.

Asking "does lib1 link against lib2" has long been a requested feature
of CMake, but unfortunately, the existence of generator expressions
precludes this hypothetical feature. Because target_link_libraries()
supports generator expressions, which means the linking could change
based on the configuration (Debug, Release, etc.), we don't actually
know if lib1 links against lib2 until generate time, at which point
it's too late to do anything in configure time.

Kyle
-- 

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:
https://cmake.org/mailman/listinfo/cmake

Reply via email to