cmake: `--enable-optimize=fast` / `--enable-debug`
with configure I could run --enable-optimize=fast or --enable-debug and got everything set, CHECK, compiler flags and some other options.
Unfortunately -DCMAKE_BUILD_TYPE does not allow for that level off control - it seems cmake knows:
Debug Release RelWithDebInfo and MinSizeRel
I think it would be nice to have at least the three options easily available:
- Current default
--enable-debug(I think-DCHECK=3andCXXFLAGS=-g -O0 -fno-inline)--enable-optimize=3(I think-DCHECK=0andCXXFLAGS=-O3)--enable-optimize=fast(I think-DCHECK=0andCXXFLAGS=-Ofast) (maybe, see #2342 ) Should we drop some so we can map it toCMAKE_BUILD_TYPEor is there another, clean way? Base it onCHECK?
If you don't specify CMAKE_BUILD_TYPE it defaults to the empty string and no optimisations are used. We might want to have RelWithDebInfo as the default. That's probably roughly equivalent to the default with configure.
Here's a nice blogpost on setting the default CMAKE_BUILD_TYPE, which would be modifiable to add some different options. Here's a SO post that's a bit more explicit on how to add a new build type.
Debugshould do the same as--enable-debugReleaseshould do the same as--enable-optimize=3
I'm less certain about adding a new build type for fast, we'd probably like to support as many compilers as possible. The user can always set CXXFLAGS to add -Ofast or equivalent so not having it as a build type wouldn't be shutting users out