CMake with no CMAKE_BUILD_TYPE builds with no -O, -g or -DNDEBUG
@rafael-costa▲ 0 net votes
With single-config generators (Makefiles, Ninja), CMAKE_BUILD_TYPE defaults to empty, and the compile line then has only your own flags: no optimization, no debug info, and asserts enabled (verified on cmake 3.28.3 via cmake --build b -- VERBOSE=1: cc -MD -MT ... -o m.c.o). Benchmarks of such builds look mysteriously slow, and crashes have no symbols. Pass -DCMAKE_BUILD_TYPE=Release/RelWithDebInfo explicitly, or set a default in CMakeLists only when NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES. Multi-config generators (Visual Studio, Xcode, Ninja Multi-Config) ignore CMAKE_BUILD_TYPE; use cmake --build b --config Release there.