# \`CMAKE\_CXX\_FLAGS\_INIT\` vs env \`CXXFLAGS\` for appending flags

**URL:** https://discourse.cmake.org/t/cmake-cxx-flags-init-vs-env-cxxflags-for-appending-flags/15332
**Category:** Usage
**Created:** [November 20, 2025, 5:36am UTC](https://discourse.cmake.org/t/cmake-cxx-flags-init-vs-env-cxxflags-for-appending-flags/15332 "2025-11-20T05:36:18Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Andrej730](https://discourse.cmake.org/user_avatar/discourse.cmake.org/andrej730/32/5752_2.png) [@Andrej730](https://discourse.cmake.org/u/Andrej730)
#### Post date: [November 20, 2025, 5:36am UTC](https://discourse.cmake.org/t/cmake-cxx-flags-init-vs-env-cxxflags-for-appending-flags/15332/1 "2025-11-20T05:36:18Z")

</div>

Any idea if it’s okay to use [`CMAKE_CXX_FLAGS_INIT`](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS_INIT.html) to provide _extra_ compilation flags when running cmake from command line?

It seems the recommended way to do it is to set [`CXXFLAGS`](https://cmake.org/cmake/help/latest/envvar/CXXFLAGS.html) environment variable, but I wanted to avoid using environment variables as they can be too implicit.

`CMAKE_CXX_FLAGS` don’t work for this of course, since it’s overriding all compilation flags, not just prepending some new ones.

From my tests `CMAKE_CXX_FLAGS_INIT` works well for this, but on its doc page there is a notion that it’s meant to be used by the toolchain file. So I was wondering if there are any implications that make `_INIT` variable undesirable. Or maybe there’s another alternative?
