CMAKE_CXX_FLAGS not initialized with CMAKE_CXX_FLAGS_INIT from toolchain-file if CMakePresets.json sets CMAKE_CXX_FLAGS
If a configure preset in CMakePresets.json
writes to CMAKE_CXX_FLAGS
via cacheVariables
, like so:
[...]
"cacheVariables": {
"CMAKE_CXX_FLAGS: "<some flags>"
}
[...]
then CMAKE_CXX_FLAGS_INIT
set from a toolchain file (via toolchainFile
) doesn't take effect.
Here's an SSCCE that reproduces the bug: preset-bug.7z
Extract the archive and cd
into it and run:
cmake --preset my-configure-preset
Expected outcome: CMAKE_CXX_FLAGS
is -o this_flag_will_not_exist_in_CMAKE_CXX_FLAGS_if_CMakePresets_writes_to_CMAKE_CXX_FLAGS
.
Observed outcome: CMAKE_CXX_FLAGS
is empty.
I believe the observed outcome is incorrect since the toolchain file sets the CMAKE_CXX_FLAGS_INIT
, which ought to initialize CMAKE_CXX_FLAGS
with the contents of CMAKE_CXX_FLAGS_INIT
of my toolchain file toolchain-with-disrespected-CMAKE_CXX_FLAGS_INIT.cmake
.