The optimization flags when configured with autotools are as set like:
- Always use -g, unless something is set in the CFLAGS as an
environment variable.
- Append -O3 if coverage is not enabled, -O0 otherwise.
This diff adds some kind of similar behavior to CMake:
- If no build configuration is defined, use RelWithDebInfo (release
with debug information).
- Set the flags to -g -O3 for this configuration.
With this diff, the CMake default build will have the same flags than
autotools by default, i.e. -g -O3. It is still possible to select a
different build configuration (and then use the associated flags), and
also pass additional flags through the CMAKE_C_FLAGS cache variable.
Note: It is not possible to select the optimization level with
autotools; since the -O3 flag is appended to the CFLAGS it will take
precedence over any passed value. As a consequence, I don't know what
the CFLAGS=-O0 case is testing in the Travis build, but it is not
testing against a non optimized binary.