I would like to make the INTERPROCEDURAL_OPTIMIZATION property transitive, like:
add_library(A ...)
# The property that should propagate to all targets that link (directly or indirectly) to A
set_property(TARGET A PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
add_library(B ...)
add_executable(C ...)
target_link_library(B PRIVATE A) # now B's INTERPROCEDURAL_OPTIMIZATION = true
target_link_library(C PRIVATE B) # now C's INTERPROCEDURAL_OPTIMIZATION = true
Is it possible? How?
Motivation: I don’t want to enable LTO for all targets. But if I set the property for a library, because cmake currently only supports thin LTO, some targets that use the library fail to build for whatever reasons. Those targets work if I set their INTERPROCEDURAL_OPTIMIZATION=on, but it is too tedious (there are many such targets, and for me it is easy to forget this).