These flags are actually causing my program to run almost 2x slower! and took me a long time to figure it out. How can I tell CMake to use only the flags I have told it to use? Could someone please help me?
I am using
cmake --version [17:44:08]
cmake version 3.27.0-rc4
It seems like CMake uses CMAKE_CXX_FLAGS_RELEASE and CMAKE_CXX_FLAGS_DEBUG (depending on the current value of CMAKE_BUILD_TYPE) in addition to CMAKE_CXX_FLAGS. The -O3 you see is likely set by default in CMAKE_CXX_FLAGS_RELEASE.
If you want to use only the flags you manually specified, you can set the build type-specific flags to the empty string like this: