As I explained in the linked CMake Issue 23956, the difference between CMAKE_CXX_FLAGS
and CXXFLAGS
is intentional. The flags are stored in the CMAKE_CXX_FLAGS
cache entry, and the default value for that is taken from a combination of builtin flags and the CXXFLAGS
environment variable. By specifying -DCMAKE_CXX_FLAGS=...
one says “use my flags instead of the defaults”.