[cmake-developers] TargetLinkLibraries on OBJECT-libraries
Patrick Boettcher
patrick.boettcher at posteo.de
Tue May 16 05:16:41 EDT 2017
Hi,
I'd like to use target_link_libraries() on an OBJECT-library for the
following reason:
I'm creating an OBJECT-library which has quite some requirement
regarding include-dirs, compile-options and -definitions. Which is why
my CMakeLists.txt currently looks somehow like this: (runtime is an
interface-library)
add_library(runtime-main OBJECT runtime.cpp)
target_include_directories(runtime-main
PRIVATE
$<TARGET_PROPERTY:runtime,INTERFACE_INCLUDE_DIRECTORIES>)
target_compile_features(vsora-runtime-main
PRIVATE
$<TARGET_PROPERTY:runtime,INTERFACE_COMPILE_FEATURES>)
target_compile_options(vsora-runtime-main
PRIVATE
$<TARGET_PROPERTY:runtime,INTERFACE_COMPILE_OPTIONS>)
target_compile_definitions(vsora-runtime-main
PRIVATE
$<TARGET_PROPERTY:runtime,INTERFACE_COMPILE_DEFINITIONS>)
I think the last 4 commands could be factored in a simple call to
target_link_libraries(runtime-main INTERFACE runtime)
(INTERFACE would have to be used even when the to be linked
library is not an INTERFACE library)
or
target_link_libraries(runtime-main PRIVATE runtime)
or
target_link_libraries(runtime-main OBJECT runtime)
I started looking into the code, except removing the check in
cmTargetLinkLibraries.cpp I didn't do much. And this does not make it
work.
Before continuing I'd like to know whether this is a good idea to work
on or if there are good arguments to never allow "linking" an
object-library to get compile information from other libraries?
best regards,
--
Patrick.
More information about the cmake-developers
mailing list