build: be a bit smarter about how we set debug/release compiler flags
build: be a bit smarter about how we set debug/release compiler flags

CMake automatically sets -O3 -DNDEBUG for release builds, and -g for
debug builds.  We want to add -O2 to the debug flags.

Also, this drops -flto in favor of CMake's INTERPROCEDURAL_OPTIMIZATION
property.  In theory, this will let CMake enable LTO on systems which
support it.  In practice, however, CMake still doesn't support LTO with
GCC/clang, only ICC (see [1]).  Unfortunately, LTO is more complicated
than simply adding a flag; for example, for GCC you need to use gcc-ar
instead of ar, which meant that using static libraries in releas builds
was broken until now.

The end result of this is that LTO is going to be disabled on GCC/clang
until CMake gets around to fixing this issue, but long-term this should
be much more reliable, and hopefully we'll get LTO support in MSVC.

[1] https://gitlab.kitware.com/cmake/cmake/issues/15939

Cloudef/squash,Cloudef/squash,jibsen/squash,jibsen/squash,quixdb/squash,quixdb/squash,quixdb/squash,jibsen/squash,Cloudef/squash