Warning "The CMake build type was set to 'MinSizeRel', but the optimization flag was set to '-Og'." when debug options are set

When I compile the attached example project like this:

Fullscreen
1
west build --build-dir app/build app --pristine --board nrf52840dk/nrf52840 --sysbuild -- -DCONFIG_DEBUG_OPTIMIZATIONS=y -DCONFIG_DEBUG_THREAD_INFO=y
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I get the following warning:

Fullscreen
1
The CMake build type was set to 'MinSizeRel', but the optimization flag was set to '-Og'.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

And the compile flags for main.c (taken from compile_commands.json) are:

Fullscreen
1
-Os -DNDEBUG -Og
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I don't understand where and why the CMAKE_BUILD_TYPE option gets set to MinSizeRel.

When I use the following command:

Fullscreen
1
west build --build-dir app/build app --pristine --board nrf52840dk/nrf52840 --sysbuild -- -DCONFIG_DEBUG_OPTIMIZATIONS=y -DCONFIG_DEBUG_THREAD_INFO=y -DCMAKE_BUILD_TYPE=Debug
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I get the following warning:

Fullscreen
1
The CMake build type was set to 'Debug', but the optimization flag was set to '-Os'.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

And the compile flags for main.c are:

Fullscreen
1
Compile flags for main.c: -g -Og
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I'm using the v2.9.0 of the SDK and the toolchain.

BR

Martin

0842.nordic.zip