[CMake] Object targets and link libraries

Jakob van Bethlehem jsvanbethlehem at gmail.com
Sun Sep 13 06:30:33 EDT 2015


Hej,

Did you notice this one?
https://public.kitware.com/Bug/bug_relationship_graph.php?bug_id=14778&graph=relation <https://public.kitware.com/Bug/bug_relationship_graph.php?bug_id=14778&graph=relation>

Also, since you’re asking about a ‘why’, you could check out this thread:
http://public.kitware.com/pipermail/cmake-developers/2015-February/024518.html <http://public.kitware.com/pipermail/cmake-developers/2015-February/024518.html>

The less involved option would be to do exactly what you mention you don’t want. You don’t mention why you don’t want to create a separate library though, which may be of importance to guess a different solution.

Sincerely, Jakob

> On 09 Sep 2015, at 15:02, Daniel Wirtz <daniel.wirtz at simtech.uni-stuttgart.de> wrote:
> 
> 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
> 
> -- 
> 
> Powered by www.kitware.com
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> 
> Kitware offers various services to support the CMake community. For more information on each offering, please visit:
> 
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150913/2095fb32/attachment.html>


More information about the CMake mailing list