# How do I enable IPO for Release build type only?

**URL:** <https://discourse.cmake.org/t/how-do-i-enable-ipo-for-release-build-type-only/7360>\
**Category:** Code\
**Created:** [January 29, 2023, 5:16pm UTC](https://discourse.cmake.org/t/how-do-i-enable-ipo-for-release-build-type-only/7360 "2023-01-29T17:16:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dundargoc](https://discourse.cmake.org/user_avatar/discourse.cmake.org/dundargoc/32/1923_2.png) [@dundargoc](https://discourse.cmake.org/u/dundargoc)\
**Post date:** [January 29, 2023, 5:16pm UTC](https://discourse.cmake.org/t/how-do-i-enable-ipo-for-release-build-type-only/7360/1 "2023-01-29T17:16:51Z")

</div>

In my project I have the following code to enable link time optimization on non-debug builds.

```auto
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED)
if(IPO_SUPPORTED AND (NOT CMAKE_BUILD_TYPE MATCHES Debug))
  set_target_properties(nvim PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

```

I wanted to rewrite this so that it worked for multi-config generators as well. But as I understand it generator expressions doesn’t work with target properties. How can I write this so that it supports both single and multi config generators?

---

<div class="post-metadata">

**Author:** ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)\
**Post date:** [January 29, 2023, 7:47pm UTC](https://discourse.cmake.org/t/how-do-i-enable-ipo-for-release-build-type-only/7360/2 "2023-01-29T19:47:01Z")

</div>

Perhaps this helps: [project\_options/Optimization.cmake at main · aminya/project\_options · GitHub](https://github.com/aminya/project_options/blob/main/src/Optimization.cmake)

---

<div class="post-metadata">

**Author:** ![dundargoc](https://discourse.cmake.org/user_avatar/discourse.cmake.org/dundargoc/32/1923_2.png) [@dundargoc](https://discourse.cmake.org/u/dundargoc)\
**Post date:** [January 29, 2023, 9:32pm UTC](https://discourse.cmake.org/t/how-do-i-enable-ipo-for-release-build-type-only/7360/3 "2023-01-29T21:32:23Z")

</div>

Hmm, I don’t think this’ll work for multi-config generators though since it relies on `CMAKE_BUILD_TYPE`?

---

<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:** [January 30, 2023, 3:44am UTC](https://discourse.cmake.org/t/how-do-i-enable-ipo-for-release-build-type-only/7360/4 "2023-01-30T03:44:33Z")

</div>

There is [`INTERPROCEDURAL_OPTIMIZATION_<CONFIG>`](https://cmake.org/cmake/help/latest/prop_tgt/INTERPROCEDURAL_OPTIMIZATION_CONFIG.html).

---

<div class="post-metadata">

**Author:** ![dundargoc](https://discourse.cmake.org/user_avatar/discourse.cmake.org/dundargoc/32/1923_2.png) [@dundargoc](https://discourse.cmake.org/u/dundargoc)\
**Post date:** [January 30, 2023, 9:05am UTC](https://discourse.cmake.org/t/how-do-i-enable-ipo-for-release-build-type-only/7360/5 "2023-01-30T09:05:57Z")

</div>

Oh wow, missed that completely. OK, thank you!
