[cmake-developers] CMake 3.12: transitive OBJECT library failing

Levi Morrison morrison.levi at gmail.com
Thu Jul 19 00:34:57 EDT 2018


I have an issue in CMake 3.12 with using transitive OBJECT
libraries.The basic skeleton is:

cmake_minimum_required(VERSION 3.12)
project(objectlib LANGUAGES CXX)

add_library(box OBJECT box.cc box.hh)
add_library(make_box OBJECT make_box.cc make_box.hh)
target_link_libraries(make_box PUBLIC box)

add_executable(main main.cc)
target_link_libraries(main PUBLIC make_box)

Note that `main` depends on `make_box`, not `box`, which should be
transitive (correct?). The full files can be seen in this gist:
https://gist.github.com/morrisonlevi/b1508531b1464921664ca06c0fd889bb

The issue is that when building`main` it does not include `box.o` in
the link line.

Given how new this feature is, I'm not sure if it's an issue with my
expectations or with CMake. The issue happens in debug builds and goes
away in release mode, presumably because the compiler inlines it.


More information about the cmake-developers mailing list