# How to make a property transitive?

**URL:** <https://discourse.cmake.org/t/how-to-make-a-property-transitive/6128>\
**Category:** Code\
**Created:** [July 22, 2022, 11:57am UTC](https://discourse.cmake.org/t/how-to-make-a-property-transitive/6128 "2022-07-22T11:57:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wwj](https://discourse.cmake.org/user_avatar/discourse.cmake.org/wwj/32/2614_2.png) [@wwj](https://discourse.cmake.org/u/wwj)\
**Post date:** [July 22, 2022, 11:57am UTC](https://discourse.cmake.org/t/how-to-make-a-property-transitive/6128/1 "2022-07-22T11:57:28Z")

</div>

I would like to make the INTERPROCEDURAL\_OPTIMIZATION property transitive, like:

```auto
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).

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [July 22, 2022, 5:10pm UTC](https://discourse.cmake.org/t/how-to-make-a-property-transitive/6128/2 "2022-07-22T17:10:42Z")

</div>

The best that is possible today is [`COMPATIBLE_INTERFACE_BOOL`](https://cmake.org/cmake/help/latest/prop_tgt/COMPATIBLE_INTERFACE_BOOL.html) (and its related properties for other types). There’s no mechanism to make arbitrary properties transitive.

---

<div class="post-metadata">

**Author:** ![wwj](https://discourse.cmake.org/user_avatar/discourse.cmake.org/wwj/32/2614_2.png) [@wwj](https://discourse.cmake.org/u/wwj)\
**Post date:** [July 25, 2022, 6:29am UTC](https://discourse.cmake.org/t/how-to-make-a-property-transitive/6128/3 "2022-07-25T06:29:54Z")

</div>

The cmake complains that INTERPROCEDURAL\_OPTIMIZATION is not a user-defined property.

So, seems like there’s no way to do.
