Turns out if you don't set CMAKE_BUILD_TYPE the default is an empty string. This results in some of the behaviors of debug builds, but not all of them. For example ENABLE_ASSERTIONS is false.
Details
Diff Detail
Event Timeline
I thought Richard actually used this configuration, but I could be wrong. I'd rather default it to Debug. IIRC ninja doesn't support the "empty string" build type and it just forces the build type to Debug. That seems like good prior art.
I have no objection to making the default Debug rather than RelWithDebInfo. I use RelWithDebInfo primarily because it builds faster, but Debug works too.
The real problem is that the behavior when CMAKE_BUILD_TYPE is the empty string is very inconsistent. The CMAKE_C_FLAGS and CMAKE_CXX_FLAGS variables are empty unless you explicitly set them or the build type, so you actually end up with an unoptimized build with no debug info.
Here's an example compile command from a CMake + Ninja build with no build type set:
/usr/bin/c++ -DGTEST_HAS_RTTI=0 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -fPIC -fvisibility-inlines-hidden -Wall -W -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wcovered-switch-default -std=c++11 -fcolor-diagnostics -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -Ilib/Support -I/Users/cbieneman/dev/open-source/llvm/lib/Support -Iinclude -I/Users/cbieneman/dev/open-source/llvm/include -fno-exceptions -fno-rtti -MMD -MT lib/Support/CMakeFiles/LLVMSupport.dir/Allocator.cpp.o -MF lib/Support/CMakeFiles/LLVMSupport.dir/Allocator.cpp.o.d -o lib/Support/CMakeFiles/LLVMSupport.dir/Allocator.cpp.o -c /Users/cbieneman/dev/open-source/llvm/lib/Support/Allocator.cpp
Actually, you should probably conditionalize this on whether the generator is single-target or not. We should have a predicate for that somewhere....
Conditionalized based on CMAKE_CONFIGURATION_TYPES to not set a default for multi-configuration generators.
I don't prefer "Debug" nor "RelWithDebInfo" by default.
For Clang/LLVM users, I suggest "Release".
To develop with our tree, they may set with debug symbols, I think.
Defaulting to debug makes the behavior almost the same as today sans undefined behavior.
I think that is the right way to go.
lgtm
I agree, the cmake default is closer to debug anyway. We also have a status message.