cmake: remove $<LINK_ONLY:...> expressions from INTERFACE_LINK_LIBRARIES

When torrent-rasterbar is built a static library, CMake supplies link
dependencies inside the LINK_ONLY generator expressions. But pkg-config
does not support such operational mode, and thus we can safely replace
those expressions with the library names. Closes #3354.
This commit is contained in:
Eugene Shalygin 2018-10-15 23:10:37 +02:00 committed by Arvid Norberg
parent 3b32c90dde
commit 911e4a892b
1 changed files with 7 additions and 4 deletions

View File

@ -49,12 +49,15 @@ function(_get_target_property_merging_configs _var_name _target_name _propert_na
endif()
endforeach()
endif()
# HACK for static libraries cmake populates link dependencies as $<LINK_ONLY:lib_name>.
# pkg-config does not support special handling for static libraries and as such we will remove
# that generator expression
string(REPLACE "$<LINK_ONLY:" "$<1:" vals "${vals}")
# HACK file(GENERATE), which we use for expanding generator expressions, is BUILD_INTERFACE,
# but we need INSTALL_INTERFACE here. As such, let us inter-change them.
# but we need INSTALL_INTERFACE here.
# See https://gitlab.kitware.com/cmake/cmake/issues/17984
string(REPLACE "$<BUILD_INTERFACE:" "$<TMP_INTERFACE:" vals "${vals}")
string(REPLACE "$<INSTALL_INTERFACE:" "@CMAKE_INSTALL_PREFIX@/$<BUILD_INTERFACE:" vals "${vals}")
string(REPLACE "$<TMP_INTERFACE:" "$<INSTALL_INTERFACE:" vals "${vals}")
string(REPLACE "$<BUILD_INTERFACE:" "$<0:" vals "${vals}")
string(REPLACE "$<INSTALL_INTERFACE:" "@CMAKE_INSTALL_PREFIX@/$<1:" vals "${vals}")
set(${_var_name} "${vals}" PARENT_SCOPE)
endfunction()