[cmake-developers] An option to set LINK_INTERFACE_LIBRARIES to empty on all shared library targets?

Brad King brad.king at kitware.com
Mon Sep 26 09:46:57 EDT 2011


On 9/26/2011 7:28 AM, Stephen Kelly wrote:
> In KDE we set the LINK_INTERFACE_LIBRARIES to empty in a wrapper around
> add_library.
[snip]
> set(CMAKE_SET_LINK_INTERFACE_EMPTY ON)
>
> cause the LINK_INTERFACE to be empty for all shared library targets be
> accepted into CMake?

Sure.  I think the simplest interface is to define a variable whose value
is used as the property default for LINK_INTERFACE_LIBRARIES:

   set(CMAKE_LINK_INTERFACE_LIBRARIES "")

Look in cmTarget.cxx for the method cmTarget::SetMakefile.  There are a
bunch of calls to "SetPropertyDefault".  Just add one like

   this->SetPropertyDefault("LINK_INTERFACE_LIBRARIES", 0);

This tells CMake to use the value of the variable

   CMAKE_LINK_INTERFACE_LIBRARIES

as the default LINK_INTERFACE_LIBRARIES when the target is created.
The ",0" argument means that there is no default if the variable is
not set.

Then add appropriate documentation for the variable in cmDocumentVariables
and add a sentence to the original property documentation about how the
default is defined.

-Brad



More information about the cmake-developers mailing list