# how to get current build type for a multi-config generator ?

**URL:** https://discourse.cmake.org/t/how-to-get-current-build-type-for-a-multi-config-generator/3638
**Category:** Code
**Created:** [June 28, 2021, 2:37am UTC](https://discourse.cmake.org/t/how-to-get-current-build-type-for-a-multi-config-generator/3638 "2021-06-28T02:37:02Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![quanzhuo](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/q/13edae/32.png) [@quanzhuo](https://discourse.cmake.org/u/quanzhuo)
#### Post date: [June 28, 2021, 2:37am UTC](https://discourse.cmake.org/t/how-to-get-current-build-type-for-a-multi-config-generator/3638/1 "2021-06-28T02:37:02Z")

</div>

Hi, All:

I need to set a variable only under debug build. I can archive this in a single config generator by check CMAKE\_BUILD\_TYPE.

```
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
    set(CPACK_RPM_DEBUGINFO_PACKAGE ON)
endif()

```

but how to do the same thing for a multi-config generator ?

Thank you.

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [June 28, 2021, 8:03am UTC](https://discourse.cmake.org/t/how-to-get-current-build-type-for-a-multi-config-generator/3638/2 "2021-06-28T08:03:13Z")

</div>

In general, you can’t do the same thing for multi-config generators because the build type is not known during the configure run. It is only decided at build time.

I say “in general” because some variables are used to initialise target properties. If those target properties support generator expressions, then you can potentially use generator expressions in the variable value to give the config-specific behavior you are looking for. But for your specific example of `CPACK_RPM_DEBUGINFO_PACKAGE`, this is not the case.

---

<div class="post-metadata">

### Author: ![quanzhuo](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/q/13edae/32.png) [@quanzhuo](https://discourse.cmake.org/u/quanzhuo)
#### Post date: [June 30, 2021, 8:27am UTC](https://discourse.cmake.org/t/how-to-get-current-build-type-for-a-multi-config-generator/3638/3 "2021-06-30T08:27:53Z")

</div>

Hi， Craig：

Thank you for your explaination.
