Optimisation flags in CMAKE_C_FLAGS/CMAKE_CXX_FLAGS should take precedence over flags set by cmake via CMAKE_BUILD_TYPE=Release/CMAKE_BUILD_TYPE=Debug
When using CMAKE_BUILD_TYPE=Release/CMAKE_BUILD_TYPE=Debug, cmake will automatically append optimisation flags to the compiler invocation (-O2 in release builds for makefiles, for example). However, these will always override any optimisation flags specified in CMAKE_C_FLAGS/CMAKE_CXX_FLAGS. This behaviour seems confusing to me. If the user manually specifies optimisation flags in CMAKE_C_FLAGS/CMAKE_CXX_FLAGS these should override any flags that cmake will attempt to set via CMAKE_BUILD_TYPE.