[CMake] Configuration dependent link

Stephan Menzel stephan.menzel at gmail.com
Wed Nov 11 10:13:21 EST 2015


I have investigated further into this and still have no solution, but a
hint, which anyone may be able to confirm.

It appears like I was led astray by a number of bugs in
target_link_libraries() which I was mistaking for intentional behavior and
so I started to re-create the behavior manually. Which was wrong in the
first place.

So it boils down to the following:

I create an imported lib

add_library(my::imp SHARED IMPORTED GLOBAL)

and import libraries and dlls like so (for all 3 configurations):

set_property(TARGET my::imp APPEND PROPERTY IMPORTED_LOCATION_DEBUG
some_debug.dll)
set_property(TARGET my::imp APPEND PROPERTY INTERFACE_LINK_LIBRARIES_DEBUG
some_debug.lib)

and then link my own target to the imported:

target_link_libraries(mylib PUBLIC myimp)

When I do this without any .lib files being present in there, it will add
an (implicit ?)  link dependency to "my::imp-NOTFOUND.obj" - rather than
nothing at all - which will choke the linker. I have tried all possible
combinations of properties, not using the config specifics, using the
INTERFACE_ prefixed rather than IMPORTED_ prefixed but that doesn't seem to
make much difference. I have however reason to believe that it does work
with at least one lib present. Unfortunately with boost far down as base
dependency I cannot set libs unless risk of interference with boost's
autolink feature. Turning it off and linking myself yielded a different
error.
It then adds something causing the linker to not find ".obj". This is
however invisible in the MSVCs properties dialog. So I rather go with
autolink on, as this at least gives me a visible faulty entry.

Maybe this sheds some light on this. Still hope someone has a hint where I
could look for ways of removing the faulty obj entry.

Thanks,

Stephan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151111/cfd212f4/attachment.html>


More information about the CMake mailing list