kumquat-buildroot/support/misc
Samuel Martin 12494ef48f toolchainfile.cmake: set per-config appended {C, CXX}FLAGS
When a build type is set, CMake does append some flags that can override
those set by Buildroot due to the gcc option parser (in which the last
argument controling an option wins).

Hereafter is a summary of the optimization and debug flags set by
Buildroot and appended by CMake.

* Flags set by Buildroot depending on the configuration:

  BR2_ENABLE_DEBUG | Optim. level        | Buildroot {C,CXX}FLAGS
  =================+=====================+=======================
          y        | BR2_OPTIMIZE_S      | -Os -gx
          y        | BR2_OPTIMIZE_G      | -Og -gx
          y        | BR2_OPTIMIZE_{0..3} | -On -gx
          n        | BR2_OPTIMIZE_S      | -Os
          n        | BR2_OPTIMIZE_G      | -Og
          n        | BR2_OPTIMIZE_{0..3} | -On

* Default flags appended by CMake depending on the build type:

  Build type     | Flags           | Effects on {C,CXX}FLAGS
  ===============+=================+===========================================
  Debug          | -g              | Force -g, compatible with BR2_ENABLE_DEBUG
  MinSizeRel     | -Os -DNDEBUG    | Set -Os, compatible with BR2_OPTIMIZE_S
  Release        | -O3 -DNDEBUG    | Set -O3, closest to the others cases,
                 |                 | though the optimization level is forced.
  RelWithDebInfo | -O2 -g -DNDEBUG | Force -g and set -O2, not friendly with BR

To avoid the CMake flags take precedence over the Buildroot ones, this
change sets in toolchainfile.cmake the per-config compiler flags CMake
can append depending on the build type Buildroot defined.
So, CMake does not mess up with the compilation flags Buildroot sets.

It is still possible to override these per-config flags on the cmake
command line.

Note:
  If a CMake-based project forces the compiler and/or linker flag
  definitions (the default ones or the per-config ones - e.g.
  CMAKE_C_FLAGS/CMAKE_C_FLAGS_{DEBUG,RELEASE}), there is not much
  Buildroot can do about it.
  So, the flags will be overwritten anyway in these cases.

Cc: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Cc: Maxime Hadjinlian <maxime.hadjinlian@gmail.com>
Signed-off-by: Samuel Martin <s.martin49@gmail.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
[Thomas:
 - adjust comment in toolchainfile.cmake.in, as suggested by Arnout.
 - also handle CMAKE_Fortran_FLAGS_*, as suggested by Arnout.]
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-10-22 16:20:17 +02:00
..
target-dir-warning.txt
toolchainfile.cmake.in toolchainfile.cmake: set per-config appended {C, CXX}FLAGS 2016-10-22 16:20:17 +02:00
utils.mk
Vagrantfile support/misc/Vagrantfile: bump to ubuntu 16.04 2016-10-19 23:00:38 +02:00