[CMake] difference between LINK_INTERFACE_LIBRARIES and INTERFACE_LINK_LIBRARIES

Leif Walsh leif.walsh at gmail.com
Thu Mar 6 00:38:40 EST 2014


Based on --help-property I can't really tease them apart.  It looks like
LINK_INTERFACE_LIBRARIES is old and INTERFACE_LINK_LIBRARIES is new, but I
can't really figure out what the change is.

In my project, I have a hierarchy of static libraries connected by
TARGET_LINK_LIBRARIES(... LINK_PUBLIC ...) and I can get to this
information with LINK_INTERFACE_LIBRARIES on linux, but on OSX it appears
to not be there with LINK_INTERFACE_LIBRARIES, but INTERFACE_LINK_LIBRARIES
does work.  I would like to understand the difference and version support
before I start using it.

1. Which versions support INTERFACE_LINK_LIBRARIES?
2. What are the differences between them?
3. There also seems to be a difference (for ADD_LIBRARY) between
LINK_PUBLIC/LINK_PRIVATE and (what I believe are newer) PUBLIC/PRIVATE, but
what are the differences here?

For example, I've used the below CMakeLists.txt and gotten the below
output.  Clearly there is some difference ($<LINK_ONLY:a>), but what does
it mean?

CMakeLists.txt:

"""
project(test)

add_library(a STATIC a)
add_library(b STATIC b)
target_link_libraries(b a)
add_library(c STATIC c)
target_link_libraries(c LINK_PRIVATE a)
add_library(d STATIC d)
target_link_libraries(d LINK_PUBLIC a)
add_library(e STATIC e)
target_link_libraries(e PRIVATE a)
add_library(f STATIC f)
target_link_libraries(f PUBLIC a)

foreach (lib a b c d e f)
  get_property(lil TARGET ${lib} PROPERTY LINK_INTERFACE_LIBRARIES)
  get_property(ill TARGET ${lib} PROPERTY INTERFACE_LINK_LIBRARIES)
  message(STATUS "${lib}: LINK_INTERFACE_LIBRARIES = \"${lil}\"
INTERFACE_LINK_LIBRARIES = \"${ill}\"")
endforeach ()
"""

output:

"""
-- a: LINK_INTERFACE_LIBRARIES = "" INTERFACE_LINK_LIBRARIES = ""
-- b: LINK_INTERFACE_LIBRARIES = "" INTERFACE_LINK_LIBRARIES = "a"
-- c: LINK_INTERFACE_LIBRARIES = "" INTERFACE_LINK_LIBRARIES =
"$<LINK_ONLY:a>"
-- d: LINK_INTERFACE_LIBRARIES = "a" INTERFACE_LINK_LIBRARIES = "a"
-- e: LINK_INTERFACE_LIBRARIES = "" INTERFACE_LINK_LIBRARIES =
"$<LINK_ONLY:a>"
-- f: LINK_INTERFACE_LIBRARIES = "a" INTERFACE_LINK_LIBRARIES = "a"
"""

-- 
Cheers,
Leif
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140306/90e9d3ea/attachment.html>


More information about the CMake mailing list