[CMake] Wanted: Interface link options

Anders Lindgren andlind at gmail.com
Fri Jun 13 07:42:21 EDT 2014


Hi!

I have a third party-library only available in Release flavor. When
building a Debug configuration, I need to pass the option
/NODEFAULTLIB:libcmt to the Visual Studio linker.

I have been playing around with the new target interface system. However,
I'm missing a way for a library to specify linker options, that would
transitively affect targets that use the library (just like the
INTERFACE_COMPILE_OPTIONS and INTERFACE_LINK_LIBRARIES do for compiler
options and libraries, respectively).

So, I suggest adding a INTERFACE_LINK_OPTIONS target property. That way I
would add the library using:

    add_library(the_library.lib STATIC IMPORTED)
    set_property(TARGET the_library.lib
      PROPERTY INTERFACE_LINK_OPTIONS
$<$<CONFIG:Debug>:/NODEFAULTLIB:libcmt>)

In addition, there are two properties, COMPILE_FLAGS and COMPILE_OPTIONS,
with the difference that the latter understands generator expressions. I
also suggest adding a LINK_OPTIONS along the same lines.

(Note that the INTERFACE_LINK_LIBRARIES property is designed to contain
both libraries and linker options. However, an entry is only interpreted as
an option if it starts with a "-", which is not the case for Visual Studio
options.)

Sincerely,
    Anders Lindgren
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20140613/eb8daa8e/attachment.html>


More information about the CMake mailing list