BOUT-dev icon indicating copy to clipboard operation
BOUT-dev copied to clipboard

cmake: `--enable-optimize=fast` / `--enable-debug`

Open dschwoerer opened this issue 4 years ago • 1 comments

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=3 and CXXFLAGS=-g -O0 -fno-inline)
  • --enable-optimize=3 (I think-DCHECK=0 and CXXFLAGS=-O3)
  • --enable-optimize=fast (I think-DCHECK=0 and CXXFLAGS=-Ofast) (maybe, see #2342 ) Should we drop some so we can map it to CMAKE_BUILD_TYPE or is there another, clean way? Base it on CHECK?

dschwoerer avatar Jul 21 '21 07:07 dschwoerer

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.

  • Debug should do the same as --enable-debug
  • Release should 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

ZedThree avatar Jul 21 '21 08:07 ZedThree