Skip to content
Snippets Groups Projects
Commit 095ea018 authored by Sebastian Eibl's avatar Sebastian Eibl
Browse files

some extensions

parent 8a492eea
No related branches found
No related tags found
No related merge requests found
Pipeline #227548 passed
......@@ -22,13 +22,27 @@ block.
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.**
```
CXXFLAGS="-march=icelake-server" cmake -S . -B build
cmake --build build --verbose
./build/hallo_world
```
or
```
cmake -S . -B build -DCMAKE_CXX_FLAGS="-march=icelake-server"
cmake --build build --verbose
```
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment