# Custom Build Type

**URL:** https://discourse.cmake.org/t/custom-build-type/201
**Category:** Usage
**Created:** [November 13, 2019, 11:55pm UTC](https://discourse.cmake.org/t/custom-build-type/201 "2019-11-13T23:55:22Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![David\_Dixon](https://discourse.cmake.org/user_avatar/discourse.cmake.org/david_dixon/32/127_2.png) [@David\_Dixon](https://discourse.cmake.org/u/David_Dixon)
#### Post date: [November 13, 2019, 11:55pm UTC](https://discourse.cmake.org/t/custom-build-type/201/1 "2019-11-13T23:55:22Z")

</div>

Is there a idiomatic way to provide a custom build type? For example, if I want to have Release flags plus march=native and mtune=native how should I go about doing this? Certainly, I could add them to CMAKE\_CXX\_FLAGS when I invoke cmake but the devs on my team would like to have them baked in to a BUILD\_TYPE e.g. `-D CMAKE_BUILD_TYPE=Optimized` or something like that…

---

<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: [November 14, 2019, 1:40am UTC](https://discourse.cmake.org/t/custom-build-type/201/2 "2019-11-14T01:40:13Z")

</div>

One of the free sample chapters of my book shows how to do this. You can find it here:

> **[Professional CMake: A Practical Guide](https://crascit.com/professional-cmake/)**
>
> The handbook for every CMake user, providing structured learning, the latest best practices and real-world advice.

The free sample includes the whole _Build Types_ chapter, which includes a section on custom build types. That section includes an example which does exactly what you’re asking about.

---

<div class="post-metadata">

### Author: ![David\_Dixon](https://discourse.cmake.org/user_avatar/discourse.cmake.org/david_dixon/32/127_2.png) [@David\_Dixon](https://discourse.cmake.org/u/David_Dixon)
#### Post date: [November 14, 2019, 3:13pm UTC](https://discourse.cmake.org/t/custom-build-type/201/3 "2019-11-14T15:13:30Z")

</div>

Thanks - buying it now!
