[CMake] transitive linkage of OBJECT library targets

Robert Maynard robert.maynard at kitware.com
Wed May 22 08:25:01 EDT 2019


This is a known limitation of the current design. Only directly linked
object library objects are propagated.

For more details on why see: https://gitlab.kitware.com/cmake/cmake/issues/18090

On Wed, May 22, 2019 at 1:48 AM Richard Szabo <sz.richard at gmail.com> wrote:
>
> Hi cmakers
>
> I'm trying to get the following example working:
> ```
> cmake_minimum_required(VERSION 3.14)
> project(test_object_lib_nesting)
>
> set(CMAKE_CXX_STANDARD 14)
>
> add_library(first_object_lib OBJECT first.cpp)
>
> add_library(second_object_lib OBJECT second.cpp)
>
> target_link_libraries(second_object_lib first_object_lib)
>
> add_executable(test_object_lib_nesting main.cpp)
>
> target_link_libraries(test_object_lib_nesting second_object_lib)
> ```
>
> The problem I have that the linker command line will have only the
> second.cpp.o for linking the first.cpp.o will not be added as link
> object to the exe. Causing missing symbols on exe linkage.
>
> How to transitively resolve and link "nested" Object library targets ?.
> --
>
> 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:
> https://cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list