Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Samuel Martin <s.martin49@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v4 3/9] toolchainfile.cmake: set per-config appended {C, CXX}FLAGS
Date: Sat, 15 Oct 2016 22:31:17 +0200	[thread overview]
Message-ID: <20161015203123.11241-4-s.martin49@gmail.com> (raw)
In-Reply-To: <20161015203123.11241-1-s.martin49@gmail.com>

The toolchainfile.cmake file already sets the build type to get close
to the Buildroot configuration.

This change sets the per-config compiler flags CMake appends, so CMake
does not mess up with the compilation flags Buildroot sets.

This change still allows overriding the these variables from the
configure command line.

Note:
  If a CMake-based project forces using a given build type and/or
  force 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>

---
changes v3->v4:
- new patch
---
 support/misc/toolchainfile.cmake.in | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/support/misc/toolchainfile.cmake.in b/support/misc/toolchainfile.cmake.in
index b0a1cd9..fde141a 100644
--- a/support/misc/toolchainfile.cmake.in
+++ b/support/misc/toolchainfile.cmake.in
@@ -13,6 +13,18 @@ string(REPLACE "/usr/share/buildroot" "" RELOCATED_HOST_DIR ${CMAKE_CURRENT_LIST
 set(CMAKE_SYSTEM_NAME Linux)
 set(CMAKE_SYSTEM_PROCESSOR @@CMAKE_SYSTEM_PROCESSOR@@)
 
+# Give to CMake the {C,CXX}FLAGS to append in case the project's logic
+# falls back on a build type or another (i.e. set CMAKE_{C,CXX}_FLAGS_*
+# variables).
+#
+# Note:
+#   if the project forces some of these flag variables, Buildroot is
+#   screwed up and there is nothing Buildroot can do about that :(
+set(CMAKE_C_FLAGS_DEBUG "" CACHE)
+set(CMAKE_CXX_FLAGS_DEBUG "" CACHE)
+set(CMAKE_C_FLAGS_RELEASE " -DNEBUG" CACHE)
+set(CMAKE_CXX_FLAGS_RELEASE " -DNEBUG" CACHE)
+
 # Build type from the Buildroot configuration
 set(CMAKE_BUILD_TYPE @@BR_CMAKE_BUILD_TYPE@@ CACHE)
 
-- 
2.10.0

  parent reply	other threads:[~2016-10-15 20:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-15 20:31 [Buildroot] [PATCH v4 0/9] Misc. CMake fixes Samuel Martin
2016-10-15 20:31 ` [Buildroot] [PATCH v4 1/9] package/pkg-cmake.mk: fix build type and optimization flags Samuel Martin
2016-10-15 20:31 ` [Buildroot] [PATCH v4 2/9] package/pkg-cmake.mk: move CMAKE_BUILD_TYPE definition into toolchainfile.cmake Samuel Martin
2016-10-15 20:31 ` Samuel Martin [this message]
2016-10-15 20:31 ` [Buildroot] [PATCH v4 4/9] package/gflags: include TARGET_CXXFLAGS to the overloaded CXXFLAGS Samuel Martin
2016-10-15 20:31 ` [Buildroot] [PATCH v4 5/9] package/gnuradio: include TARGET_CFLAGS to the overloaded CFLAGS Samuel Martin
2016-10-15 20:31 ` [Buildroot] [PATCH v4 6/9] package/libcec: include TARGET_{C, CXX}FLAGS to the overloaded {C, CXX}FLAGS Samuel Martin
2016-10-15 20:31 ` [Buildroot] [PATCH v4 7/9] package/opencv3: fix CMAKE_CXX_FLAGS Samuel Martin
2016-10-15 20:31 ` [Buildroot] [PATCH v4 8/9] package/rpi-userland: include TARGET_CFLAGS to the overloaded CFLAGS Samuel Martin
2016-10-15 20:31 ` [Buildroot] [PATCH v4 9/9] toochainfile.cmake: rework the way Buildroot sets flags Samuel Martin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161015203123.11241-4-s.martin49@gmail.com \
    --to=s.martin49@gmail.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox