Make CMake Debug by Default
For single-configuration generators such as Makefiles or Ninja, add this to your CMakeLists.txt:
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
This leaves an explicitly selected build type alone. Multi-configuration generators choose the configuration at build time instead.