[CMake] Confusion over INTERFACE vs STATIC|SHARED IMPORTED vs INTERFACE IMPORTED
Ted Middleton
middleton.ted at gmail.com
Tue Jul 5 18:17:45 EDT 2016
I'm looking at the documentation for add_library(), and I'm really confused
about the distinction between add_library(foo INTERFACE) vs add_library(foo
INTERFACE IMPORTED) vs add_library(foo <SHARED|STATIC> IMPORTED).
Correct me if I'm wrong (and I probably am), but add_library(foo INTERFACE)
is for propagating properties like INTERFACE_INCLUDE_DIRECTORIES to other
targets using target_link_libraries(), so that header-only libraries can be
consumed by other targets conveniently. My understanding of this is that
setting INTERFACE_LINK_LIBRARIES on a target like this would be an error?
And add_library(foo SHARED IMPORTED) would be to create a target object for
a pre-existing library (like a platform lib or something) for which cmake
is not supposed to try to create an actual "call the compiler and
linkeditor or archiver" build rule. This still boils down to mostly
propagating properties, no? Except now some of those properties can be
things like INTERFACE_LINK_LIBRARIES?
So can anyone tell me what add_library(foo INTERFACE IMPORTED) is? The
documentation says,
"An INTERFACE Imported Target may also be created with this signature. An
IMPORTED library target references a library defined outside the project.
The target name has scope in the directory in which it is created and
below, but the GLOBAL option extends visibility. It may be referenced like
any target built within the project. IMPORTED libraries are useful for
convenient reference from commands like target_link_libraries()."
That description is what I thought add_library(foo <SHARED|STATIC>
IMPORTED) was for?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160705/ece276db/attachment.html>
More information about the CMake
mailing list