# overwriting CMAKE\_CXX\_FLAGS

**URL:** https://discourse.cmake.org/t/overwriting-cmake-cxx-flags/1548
**Category:** Usage
**Tags:** os:linux
**Created:** [July 13, 2020, 6:54pm UTC](https://discourse.cmake.org/t/overwriting-cmake-cxx-flags/1548 "2020-07-13T18:54:10Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![flashburn](https://discourse.cmake.org/user_avatar/discourse.cmake.org/flashburn/32/738_2.png) [@flashburn](https://discourse.cmake.org/u/flashburn)
#### Post date: [July 13, 2020, 6:54pm UTC](https://discourse.cmake.org/t/overwriting-cmake-cxx-flags/1548/1 "2020-07-13T18:54:10Z")

</div>

My environment has `CXXFLAGS=-O2 -pipe -g -feliminate-unused-debug-types`. For debugging purposes I don’t want to use these settings. In my `CMakeLists.txt` I tried `set(CMAKE_CXX_FLAGS "")`. However when I rebuild my makefiles and recompiled the code, I still could see `-O2 -pipe -g -feliminate-unused-debug-types`. Why is this happening? I there a way to overwrite `CXXFLAGS`?

---

<div class="post-metadata">

### Author: ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)
#### Post date: [July 13, 2020, 7:59pm UTC](https://discourse.cmake.org/t/overwriting-cmake-cxx-flags/1548/2 "2020-07-13T19:59:10Z")

</div>

```cmake
set(ENV{CXXFLAGS} -my -flags)

```

---

<div class="post-metadata">

### Author: ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)
#### Post date: [July 13, 2020, 7:59pm UTC](https://discourse.cmake.org/t/overwriting-cmake-cxx-flags/1548/3 "2020-07-13T19:59:39Z")

</div>

Or you can set the environment variable from outside the build using your system’s shell.
