There is no default build type! If you do not specify a build types no flags will be added.
## CMake uses common environment variables to modify the compiler and linker commands.
CMake uses environment variables like `CFLAGS`, `CXXFLAGS`, `LDFLAGS`, ... to initialize its internal variables [[Ref]](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS.html#variable:CMAKE_%3CLANG%3E_FLAGS). You can either use the environment variables or the CMake variables directly.
**CAUTION! the internal variables are set during the first configure call and are cached. Meaning, subsequent changes to the environment variables will not be followed by CMake. To make CMake aware of the changes you can either delete and recreate the build folder or use `--fresh`[[Ref]](https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-fresh).**
CMake uses environment variables like `CFLAGS`, `CXXFLAGS`, `LDFLAGS`, ... to initialize its internal variables [[SOURCE]](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_FLAGS.html#variable:CMAKE_%3CLANG%3E_FLAGS).
| Environment Variable | CMake Variable |
|----------------------|-----------------|
| CFLAGS | CMAKE_C_FLAGS |
| CXXFLAGS | CMAKE_CXX_FLAGS |
| LDFLAGS | CMAKE_EXE_LINKER_FLAGS |
| ... | ... |
You can either use the environment variables or the CMake variables directly. If both are given the CMake variables will be used.
**CAUTION:
The internal variables are set during the first configure call and are cached. Meaning, subsequent changes to the environment variables will not be followed by CMake. To make CMake aware of the changes you can either delete and recreate the build folder or use `--fresh`[[SOURCE]](https://cmake.org/cmake/help/latest/manual/cmake.1.html#cmdoption-cmake-fresh).**
## Example
The following example shows how to add architecture specific optimization flags. **Note, without `CMAKE_BUILD_TYPE` no optimization level is set.**