[CMake] transitive linkage of OBJECT library targets

Richard Szabo sz.richard at gmail.com
Wed May 22 01:48:37 EDT 2019


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 ?.


More information about the CMake mailing list