[CMake] Object targets and link libraries
Daniel Wirtz
daniel.wirtz at simtech.uni-stuttgart.de
Wed Sep 9 09:02:11 EDT 2015
Hey all,
i've been wondering why CMake (3.3.+) yells at me if i want to add link
libraries to an OBJECT target.
Consider the scenario
find_package(package_with_bar_target)
add_library(foo OBJECT ${foo_src})
# Would like to write
# target_link_libraries(foo bar)
# But have to use
target_include_directories(foo PRIVATE $<TARGET_PROPERTY:bar,INTERFACE_INCLUDE_DIRECTORIES>)
I know that intuitively "link library" is something different than
"include directory". but one of the nice things
of cmake is that it automatically sorts out everything for you when you
specify link libraries.
if there are more bar-dependent properties that need to be set in order
to successfully compile foo (e.g. compile flags),
i have to literally re-write all the nice internal cmake logic to
establish the compile environment of bar for foo.
what's the plan with that? or are there any other (less involved)
solutions? i need the objects of foo inside a larger
target and want to avoid having a separate library being build that
needs extra linking.
cheers!
--
Dr. Daniel Wirtz
Dipl. Math. Dipl. Inf.
SRC SimTech
Pfaffenwaldring 5a
+49 711 685 60044
More information about the CMake
mailing list