All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v6 0/9] Misc. CMake fixes
@ 2016-10-16 11:12 Samuel Martin
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 1/9] Revert "package/cmake: with BR2_ENABLE_DEBUG use RelWithDebInfo" Samuel Martin
                   ` (9 more replies)
  0 siblings, 10 replies; 18+ messages in thread
From: Samuel Martin @ 2016-10-16 11:12 UTC (permalink / raw)
  To: buildroot

Hi all,

Here is a short series reworking the way the Buildroot's CMake
infrastructure handles compiler/linker flags.

Patch 1 to 3 fix the optimization and debug flags passed/set by CMake
through the toolchainfile.cmake file.

Patches 4 to 8 clean up CMake-based package regarding {C,CXX,LD}FLAGS.

Patch 9 reworks the way the compiler/linker flags are set in
toolchainfile.cmake.

Regards,
Sam


Max Filippov (1):
  package/opencv3: fix CMAKE_CXX_FLAGS

Samuel Martin (8):
  Revert "package/cmake: with BR2_ENABLE_DEBUG use RelWithDebInfo"
  package/pkg-cmake.mk: move CMAKE_BUILD_TYPE definition into
    toolchainfile.cmake
  toolchainfile.cmake: set per-config appended {C,CXX}FLAGS
  package/gflags: include TARGET_CXXFLAGS to the overloaded CXXFLAGS
  package/gnuradio: include TARGET_CFLAGS to the overloaded CFLAGS
  package/libcec: include TARGET_{C,CXX}FLAGS to the overloaded
    {C,CXX}FLAGS
  package/rpi-userland: include TARGET_CFLAGS to the overloaded CFLAGS
  toochainfile.cmake: rework the way Buildroot sets flags

 CHANGES                              |  9 +++++++++
 package/gflags/gflags.mk             |  3 ++-
 package/gnuradio/gnuradio.mk         |  2 +-
 package/libcec/libcec.mk             |  5 +++--
 package/opencv3/opencv3.mk           |  2 +-
 package/pkg-cmake.mk                 |  2 +-
 package/rpi-userland/rpi-userland.mk |  3 ++-
 support/misc/toolchainfile.cmake.in  | 31 +++++++++++++++++++++++++++----
 8 files changed, 46 insertions(+), 11 deletions(-)

--
2.10.0

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v6 1/9] Revert "package/cmake: with BR2_ENABLE_DEBUG use RelWithDebInfo"
  2016-10-16 11:12 [Buildroot] [PATCH v6 0/9] Misc. CMake fixes Samuel Martin
@ 2016-10-16 11:12 ` Samuel Martin
  2016-10-16 18:53   ` Arnout Vandecappelle
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 2/9] package/pkg-cmake.mk: move CMAKE_BUILD_TYPE definition into toolchainfile.cmake Samuel Martin
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 18+ messages in thread
From: Samuel Martin @ 2016-10-16 11:12 UTC (permalink / raw)
  To: buildroot

This reverts commit 4b0120183404913f7f7788ef4f0f6b51498ef363.

Before reverting this patch, CMake packages are built with the following
options:
  * if BR2_ENABLE_DEBUG is set:
    The CMake build type is set to RelWithDebInfo, which means:
    - Optimization level is forced to: -O2;
    - no log nor assert due to -DNDEBUG;
    - BR2_DEBUG_{1..3} effect is unchanged;
  * otherwise:
    The CMake build type is set to Release, which means:
    - Optimization level is forced to: -O3;
    - no log nor assert due to -DNDEBUG (as expected).
  In any case, the optimization WRT the binary size is always ignored
  and forced.

Reverting to the previous situation, so Buildroot now chooses between
the 'Debug' and 'Release' config types, which are semantically closer
to what Buildroot does everywhere else:
  * if BR2_ENABLE_DEBUG is set:
    The CMake build type is set to Debug, which means:
    - only -g option is passed by CMake;
    - optimization is not forced, nor debug level, so they are kept
      as-is;
  * otherwise:
    The CMake build type is set to Release, so no change in this case:
    - Optimization level is forced to: -O3;
    - no log nor assert due to -DNDEBUG (as expected);
    - size optimization is ignored.

Follow-up patches will fix the CMake flag variables that are appended by
CMake.

Cc: Charles Hardin <ckhardin@exablox.com>
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 v5->v6:
- revert 4b01201 instead (Arnout)

changes v4->v5:
- none

changes v3->v4:
- simplify build type selection
---
 package/pkg-cmake.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
index aca9e61..4883b3b 100644
--- a/package/pkg-cmake.mk
+++ b/package/pkg-cmake.mk
@@ -87,7 +87,7 @@ define $(2)_CONFIGURE_CMDS
 	PATH=$$(BR_PATH) \
 	$$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \
 		-DCMAKE_TOOLCHAIN_FILE="$$(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake" \
-		-DCMAKE_BUILD_TYPE=$$(if $$(BR2_ENABLE_DEBUG),RelWithDebInfo,Release) \
+		-DCMAKE_BUILD_TYPE=$$(if $$(BR2_ENABLE_DEBUG),Debug,Release) \
 		-DCMAKE_INSTALL_PREFIX="/usr" \
 		-DCMAKE_COLOR_MAKEFILE=OFF \
 		-DBUILD_DOC=OFF \
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v6 2/9] package/pkg-cmake.mk: move CMAKE_BUILD_TYPE definition into toolchainfile.cmake
  2016-10-16 11:12 [Buildroot] [PATCH v6 0/9] Misc. CMake fixes Samuel Martin
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 1/9] Revert "package/cmake: with BR2_ENABLE_DEBUG use RelWithDebInfo" Samuel Martin
@ 2016-10-16 11:12 ` Samuel Martin
  2016-10-16 19:05   ` Arnout Vandecappelle
  2016-10-22 14:43   ` Thomas Petazzoni
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 3/9] toolchainfile.cmake: set per-config appended {C, CXX}FLAGS Samuel Martin
                   ` (7 subsequent siblings)
  9 siblings, 2 replies; 18+ messages in thread
From: Samuel Martin @ 2016-10-16 11:12 UTC (permalink / raw)
  To: buildroot

The chosen CMAKE_BUILD_TYPE encodes an option of the Buildroot
configuration, so it makes more sense to save it in the
toolchainfile.cmake than to pass it during configure.

It is still possible to override the build type on the cmake
command line.

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 v5->v6:
- reword commit log (Arnout)
- simplify/remove intermediate variable (Arnout)

changes v4->v5:
- fix cmake set call

changes v3->v4:
- new patch
---
 CHANGES                             | 6 ++++++
 package/pkg-cmake.mk                | 2 +-
 support/misc/toolchainfile.cmake.in | 3 +++
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/CHANGES b/CHANGES
index b4bd5fe..c0e3e79 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,9 @@
+2016.11-rc1,
+
+    toolchainfile.cmake:
+    * when used outside of Buildroot, if not specified on the command
+      line, the CMAKE_BUILD_TYPE is by toolchainfile.cmake.
+
 2016.08, Released September 1st, 2016
 
 	Minor fixes.
diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
index 4883b3b..4e0e838 100644
--- a/package/pkg-cmake.mk
+++ b/package/pkg-cmake.mk
@@ -87,7 +87,6 @@ define $(2)_CONFIGURE_CMDS
 	PATH=$$(BR_PATH) \
 	$$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \
 		-DCMAKE_TOOLCHAIN_FILE="$$(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake" \
-		-DCMAKE_BUILD_TYPE=$$(if $$(BR2_ENABLE_DEBUG),Debug,Release) \
 		-DCMAKE_INSTALL_PREFIX="/usr" \
 		-DCMAKE_COLOR_MAKEFILE=OFF \
 		-DBUILD_DOC=OFF \
@@ -247,5 +246,6 @@ $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake:
 		-e 's#@@TARGET_FC@@#$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_FC)))#' \
 		-e 's#@@CMAKE_SYSTEM_PROCESSOR@@#$(call qstrip,$(CMAKE_SYSTEM_PROCESSOR))#' \
 		-e 's#@@TOOLCHAIN_HAS_FORTRAN@@#$(if $(BR2_TOOLCHAIN_HAS_FORTRAN),1,0)#' \
+		-e 's#@@CMAKE_BUILD_TYPE@@#$(if $(BR2_ENABLE_DEBUG),Debug,Release)#' \
 		$(TOPDIR)/support/misc/toolchainfile.cmake.in \
 		> $@
diff --git a/support/misc/toolchainfile.cmake.in b/support/misc/toolchainfile.cmake.in
index 649b52d..1c5031f 100644
--- a/support/misc/toolchainfile.cmake.in
+++ b/support/misc/toolchainfile.cmake.in
@@ -13,6 +13,9 @@ string(REPLACE "/usr/share/buildroot" "" RELOCATED_HOST_DIR ${CMAKE_CURRENT_LIST
 set(CMAKE_SYSTEM_NAME Linux)
 set(CMAKE_SYSTEM_PROCESSOR @@CMAKE_SYSTEM_PROCESSOR@@)
 
+# Build type from the Buildroot configuration
+set(CMAKE_BUILD_TYPE @@CMAKE_BUILD_TYPE@@ CACHE STRING "Buildroot build configuration")
+
 set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@ ${CMAKE_C_FLAGS}" CACHE STRING "Buildroot CFLAGS")
 set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@ ${CMAKE_CXX_FLAGS}" CACHE STRING "Buildroot CXXFLAGS")
 set(CMAKE_EXE_LINKER_FLAGS "@@TARGET_LDFLAGS@@ ${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "Buildroot LDFLAGS")
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v6 3/9] toolchainfile.cmake: set per-config appended {C, CXX}FLAGS
  2016-10-16 11:12 [Buildroot] [PATCH v6 0/9] Misc. CMake fixes Samuel Martin
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 1/9] Revert "package/cmake: with BR2_ENABLE_DEBUG use RelWithDebInfo" Samuel Martin
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 2/9] package/pkg-cmake.mk: move CMAKE_BUILD_TYPE definition into toolchainfile.cmake Samuel Martin
@ 2016-10-16 11:12 ` Samuel Martin
  2016-10-16 19:09   ` Arnout Vandecappelle
  2016-10-22 14:43   ` Thomas Petazzoni
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 4/9] package/gflags: include TARGET_CXXFLAGS to the overloaded CXXFLAGS Samuel Martin
                   ` (6 subsequent siblings)
  9 siblings, 2 replies; 18+ messages in thread
From: Samuel Martin @ 2016-10-16 11:12 UTC (permalink / raw)
  To: buildroot

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>

---
changes v5->v6:
- reword commit log

changes v4->v5:
- fix cmake set call

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

diff --git a/support/misc/toolchainfile.cmake.in b/support/misc/toolchainfile.cmake.in
index 1c5031f..2ace940 100644
--- a/support/misc/toolchainfile.cmake.in
+++ b/support/misc/toolchainfile.cmake.in
@@ -13,6 +13,17 @@ string(REPLACE "/usr/share/buildroot" "" RELOCATED_HOST_DIR ${CMAKE_CURRENT_LIST
 set(CMAKE_SYSTEM_NAME Linux)
 set(CMAKE_SYSTEM_PROCESSOR @@CMAKE_SYSTEM_PROCESSOR@@)
 
+# Set the {C,CXX}FLAGS appended by CMake depending on the build type
+# sets by Buildroot.
+#
+# 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 STRING "Debug CFLAGS")
+set(CMAKE_CXX_FLAGS_DEBUG "" CACHE STRING "Debug CXXFLAGS")
+set(CMAKE_C_FLAGS_RELEASE " -DNEBUG" CACHE STRING "Release CFLAGS")
+set(CMAKE_CXX_FLAGS_RELEASE " -DNEBUG" CACHE STRING "Release CXXFLAGS")
+
 # Build type from the Buildroot configuration
 set(CMAKE_BUILD_TYPE @@CMAKE_BUILD_TYPE@@ CACHE STRING "Buildroot build configuration")
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v6 4/9] package/gflags: include TARGET_CXXFLAGS to the overloaded CXXFLAGS
  2016-10-16 11:12 [Buildroot] [PATCH v6 0/9] Misc. CMake fixes Samuel Martin
                   ` (2 preceding siblings ...)
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 3/9] toolchainfile.cmake: set per-config appended {C, CXX}FLAGS Samuel Martin
@ 2016-10-16 11:12 ` Samuel Martin
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 5/9] package/gnuradio: include TARGET_CFLAGS to the overloaded CFLAGS Samuel Martin
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: Samuel Martin @ 2016-10-16 11:12 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

---
changes v5->v6:
- none

changes v4->v5:
- none

changes v3->v4:
- fix commit subject
- update A/R/T tags

changes v2->v3:
- new patch
---
 package/gflags/gflags.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/package/gflags/gflags.mk b/package/gflags/gflags.mk
index 9dc4e15..89111ed 100644
--- a/package/gflags/gflags.mk
+++ b/package/gflags/gflags.mk
@@ -11,7 +11,8 @@ GFLAGS_LICENSE = BSD-3c
 GFLAGS_LICENSE_FILES = COPYING.txt
 
 ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),)
-GFLAGS_CONF_OPTS = -DBUILD_gflags_LIB=OFF -DCMAKE_CXX_FLAGS=-DNO_THREADS
+GFLAGS_CONF_OPTS = -DBUILD_gflags_LIB=OFF \
+	-DCMAKE_CXX_FLAGS="$(TARGET_CXXFLAGS) -DNO_THREADS"
 endif
 
 $(eval $(cmake-package))
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v6 5/9] package/gnuradio: include TARGET_CFLAGS to the overloaded CFLAGS
  2016-10-16 11:12 [Buildroot] [PATCH v6 0/9] Misc. CMake fixes Samuel Martin
                   ` (3 preceding siblings ...)
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 4/9] package/gflags: include TARGET_CXXFLAGS to the overloaded CXXFLAGS Samuel Martin
@ 2016-10-16 11:12 ` Samuel Martin
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 6/9] package/libcec: include TARGET_{C, CXX}FLAGS to the overloaded {C, CXX}FLAGS Samuel Martin
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: Samuel Martin @ 2016-10-16 11:12 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

---
changes v5->v6:
- none

changes v4->v5:
- none

changes v3->v4:
- fix commit subject
- update A/R/T tags

changes v2->v3:
- new patch
---
 package/gnuradio/gnuradio.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package/gnuradio/gnuradio.mk b/package/gnuradio/gnuradio.mk
index 972f7a4..5cb00d2 100644
--- a/package/gnuradio/gnuradio.mk
+++ b/package/gnuradio/gnuradio.mk
@@ -36,7 +36,7 @@ GNURADIO_INSTALL_STAGING = YES
 # CFLAGS to decide whether to build the NEON functions or not, and
 # wants to see the string 'armv7' in the CFLAGS.
 ifeq ($(BR2_ARM_CPU_ARMV7A)$(BR2_ARM_CPU_HAS_NEON),yy)
-GNURADIO_CONF_OPTS += -DCMAKE_C_FLAGS="-march=armv7-a"
+GNURADIO_CONF_OPTS += -DCMAKE_C_FLAGS="$(TARGET_CFLAGS) -march=armv7-a"
 endif
 
 # As soon as -mfpu=neon is supported by the compiler, gnuradio will try
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v6 6/9] package/libcec: include TARGET_{C, CXX}FLAGS to the overloaded {C, CXX}FLAGS
  2016-10-16 11:12 [Buildroot] [PATCH v6 0/9] Misc. CMake fixes Samuel Martin
                   ` (4 preceding siblings ...)
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 5/9] package/gnuradio: include TARGET_CFLAGS to the overloaded CFLAGS Samuel Martin
@ 2016-10-16 11:12 ` Samuel Martin
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 7/9] package/opencv3: fix CMAKE_CXX_FLAGS Samuel Martin
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: Samuel Martin @ 2016-10-16 11:12 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

---
changes v5->v6:
- none

changes v4->v5:
- none

changes v3->v4:
- fix commit subject
- update A/R/T tags

changes v2->v3:
- new patch
---
 package/libcec/libcec.mk | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/package/libcec/libcec.mk b/package/libcec/libcec.mk
index b762d88..55c5fbb 100644
--- a/package/libcec/libcec.mk
+++ b/package/libcec/libcec.mk
@@ -29,8 +29,9 @@ endif
 ifeq ($(BR2_PACKAGE_RPI_USERLAND),y)
 LIBCEC_DEPENDENCIES += rpi-userland
 LIBCEC_CONF_OPTS += \
-	-DCMAKE_C_FLAGS="-lvcos -lvchiq_arm" \
-	-DCMAKE_CXX_FLAGS="-I$(STAGING_DIR)/usr/include/interface/vmcs_host/linux \
+	-DCMAKE_C_FLAGS="$(TARGET_CFLAGS) -lvcos -lvchiq_arm" \
+	-DCMAKE_CXX_FLAGS="$(TARGET_CXXFLAGS) \
+		-I$(STAGING_DIR)/usr/include/interface/vmcs_host/linux \
 		-I$(STAGING_DIR)/usr/include/interface/vcos/pthreads"
 endif
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v6 7/9] package/opencv3: fix CMAKE_CXX_FLAGS
  2016-10-16 11:12 [Buildroot] [PATCH v6 0/9] Misc. CMake fixes Samuel Martin
                   ` (5 preceding siblings ...)
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 6/9] package/libcec: include TARGET_{C, CXX}FLAGS to the overloaded {C, CXX}FLAGS Samuel Martin
@ 2016-10-16 11:12 ` Samuel Martin
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 8/9] package/rpi-userland: include TARGET_CFLAGS to the overloaded CFLAGS Samuel Martin
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 18+ messages in thread
From: Samuel Martin @ 2016-10-16 11:12 UTC (permalink / raw)
  To: buildroot

From: Max Filippov <jcmvbkbc@gmail.com>

The commit 4904c4c "package/opencv3: use BR2_TOOLCHAIN_HAS_LIBATOMIC"
overrides CMAKE_CXX_FLAGS with the single -latomic, losing all ABI
CFLAGS that are passed there by default. This breaks build on xtensa
where ABI CFLAGS contain important code generation options.

Append $(TARGET_CXXFLAGS) to CMAKE_CXX_FLAGS along with -latomic.

Fixes:
  http://autobuild.buildroot.net/results/7f1c96abd8fbb5b358a07100ab623316e9bb9dcd
  http://autobuild.buildroot.net/results/e0c93d0f6d1da0d62d4dbba211a275bfe75e9645
  http://autobuild.buildroot.net/results/53e7e4b4b6a7b48b8012799d7507f7594dbf01b2

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Samuel Martin <s.martin49@gmail.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

---
changes v5->v6:
- none

changes v4->v5:
- none

changes v3->v4 [Samuel]:
- update A/R/T tags
---
 package/opencv3/opencv3.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package/opencv3/opencv3.mk b/package/opencv3/opencv3.mk
index 2529de9..10660a9 100644
--- a/package/opencv3/opencv3.mk
+++ b/package/opencv3/opencv3.mk
@@ -12,7 +12,7 @@ OPENCV3_LICENSE_FILES = LICENSE
 
 # Uses __atomic_fetch_add_4
 ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y)
-OPENCV3_CONF_OPTS += -DCMAKE_CXX_FLAGS="-latomic"
+OPENCV3_CONF_OPTS += -DCMAKE_CXX_FLAGS="$(TARGET_CXXFLAGS) -latomic"
 endif
 
 # OpenCV component options
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v6 8/9] package/rpi-userland: include TARGET_CFLAGS to the overloaded CFLAGS
  2016-10-16 11:12 [Buildroot] [PATCH v6 0/9] Misc. CMake fixes Samuel Martin
                   ` (6 preceding siblings ...)
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 7/9] package/opencv3: fix CMAKE_CXX_FLAGS Samuel Martin
@ 2016-10-16 11:12 ` Samuel Martin
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 9/9] toochainfile.cmake: rework the way Buildroot sets flags Samuel Martin
  2016-10-22 14:42 ` [Buildroot] [PATCH v6 0/9] Misc. CMake fixes Thomas Petazzoni
  9 siblings, 0 replies; 18+ messages in thread
From: Samuel Martin @ 2016-10-16 11:12 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

---
changes v5->v6:
- none

changes v4->v5:
- none

changes v3->v4:
- fix commit subject
- update A/R/T tags

changes v2->v3:
- new patch
---
 package/rpi-userland/rpi-userland.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/package/rpi-userland/rpi-userland.mk b/package/rpi-userland/rpi-userland.mk
index 86cde87..4a6eb41 100644
--- a/package/rpi-userland/rpi-userland.mk
+++ b/package/rpi-userland/rpi-userland.mk
@@ -10,7 +10,8 @@ RPI_USERLAND_LICENSE = BSD-3c
 RPI_USERLAND_LICENSE_FILES = LICENCE
 RPI_USERLAND_INSTALL_STAGING = YES
 RPI_USERLAND_CONF_OPTS = -DVMCS_INSTALL_PREFIX=/usr \
-	-DCMAKE_C_FLAGS="-DVCFILED_LOCKFILE=\\\"/var/run/vcfiled.pid\\\""
+	-DCMAKE_C_FLAGS="$(TARGET_CFLAGS) \
+		-DVCFILED_LOCKFILE=\\\"/var/run/vcfiled.pid\\\""
 
 RPI_USERLAND_PROVIDES = libegl libgles libopenmax libopenvg
 
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v6 9/9] toochainfile.cmake: rework the way Buildroot sets flags
  2016-10-16 11:12 [Buildroot] [PATCH v6 0/9] Misc. CMake fixes Samuel Martin
                   ` (7 preceding siblings ...)
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 8/9] package/rpi-userland: include TARGET_CFLAGS to the overloaded CFLAGS Samuel Martin
@ 2016-10-16 11:12 ` Samuel Martin
  2016-10-16 19:13   ` Arnout Vandecappelle
  2016-10-22 14:42 ` [Buildroot] [PATCH v6 0/9] Misc. CMake fixes Thomas Petazzoni
  9 siblings, 1 reply; 18+ messages in thread
From: Samuel Martin @ 2016-10-16 11:12 UTC (permalink / raw)
  To: buildroot

From the build configuration, Buildroot defines and set some compiler
and linker flags that should be passed to any packages build-system.

For package using the cmake-package infrastructure, this is achieved
via the toolchainfile.cmake.

This change simplifies the way the toolchainfile.cmake file handles
these flags: it now just sets them, without any attempt to extend them
with those Buildroot defined.

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

So, now, when a CMake-based package needs to extend them, they should
be fully set from the package *.mk file. This behavior is consistent
with what is done for others package infrastructures.

This change should not pull any regression WRT the bug #7280 [1].

However, now, when someone uses the toolchainfile.cmake file outside of
Buildroot, he/she must overload all compiler/linker flags (including the
ones Buildroot sets since they no longer get automatically added).

[1] https://bugs.busybox.net/show_bug.cgi?id=7280

Cc: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Cc: Max Filippov <jcmvbkbc@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Samuel Martin <s.martin49@gmail.com>

---
changes v5->v6:
- none

changes v4->v5:
- fix cmake set call

changes v3->v4:
- add a note about what the CMake code should look like (Arnout)
- fix overriding support (add missing CACHE keyword)
- update CHANGES text
---
 CHANGES                             |  5 ++++-
 support/misc/toolchainfile.cmake.in | 17 +++++++++++++----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/CHANGES b/CHANGES
index c0e3e79..3657710 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,7 +2,10 @@
 
     toolchainfile.cmake:
     * when used outside of Buildroot, if not specified on the command
-      line, the CMAKE_BUILD_TYPE is by toolchainfile.cmake.
+      line, the CMAKE_BUILD_TYPE is by toolchainfile.cmake;
+    * when used outside of Buildroot with custom compiler/linker
+      flags, the Buildroot flags should be set along side with the
+      custom ones.
 
 2016.08, Released September 1st, 2016
 
diff --git a/support/misc/toolchainfile.cmake.in b/support/misc/toolchainfile.cmake.in
index 2ace940..0283b62 100644
--- a/support/misc/toolchainfile.cmake.in
+++ b/support/misc/toolchainfile.cmake.in
@@ -27,9 +27,17 @@ set(CMAKE_CXX_FLAGS_RELEASE " -DNEBUG" CACHE STRING "Release CXXFLAGS")
 # Build type from the Buildroot configuration
 set(CMAKE_BUILD_TYPE @@CMAKE_BUILD_TYPE@@ CACHE STRING "Buildroot build configuration")
 
-set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@ ${CMAKE_C_FLAGS}" CACHE STRING "Buildroot CFLAGS")
-set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@ ${CMAKE_CXX_FLAGS}" CACHE STRING "Buildroot CXXFLAGS")
-set(CMAKE_EXE_LINKER_FLAGS "@@TARGET_LDFLAGS@@ ${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "Buildroot LDFLAGS")
+# Buildroot defaults flags.
+# If you are using this toolchainfile.cmake file outside of Buildroot and
+# want to customize the compiler/linker flags, then:
+# * set them all on the cmake command line, e.g.:
+#     cmake -DCMAKE_C_FLAGS="@@TARGET_CFLAGS@@ -Dsome_custom_flag" ...
+# * and make sure the project's CMake code extendsthem like this if needed:
+#     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Dsome_definitions")
+set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@" CACHE STRING "Buildroot CFLAGS")
+set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@" CACHE STRING "Buildroot CXXFLAGS")
+set(CMAKE_EXE_LINKER_FLAGS "@@TARGET_LDFLAGS@@" CACHE STRING "Buildroot LDFLAGS for executables")
+
 set(CMAKE_INSTALL_SO_NO_EXE 0)
 
 set(CMAKE_PROGRAM_PATH "${RELOCATED_HOST_DIR}/usr/bin")
@@ -45,6 +53,7 @@ set(ENV{PKG_CONFIG_SYSROOT_DIR} "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
 set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC@@")
 set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX@@")
 if(@@TOOLCHAIN_HAS_FORTRAN@@)
-  set(CMAKE_Fortran_FLAGS "@@TARGET_FCFLAGS@@ ${CMAKE_Fortran_FLAGS}" CACHE STRING "Buildroot FCFLAGS")
+  # Buildroot defaults flags.
+  set(CMAKE_Fortran_FLAGS "@@TARGET_FCFLAGS@@" CACHE STRING "Buildroot FCFLAGS")
   set(CMAKE_Fortran_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_FC@@")
 endif()
-- 
2.10.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v6 1/9] Revert "package/cmake: with BR2_ENABLE_DEBUG use RelWithDebInfo"
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 1/9] Revert "package/cmake: with BR2_ENABLE_DEBUG use RelWithDebInfo" Samuel Martin
@ 2016-10-16 18:53   ` Arnout Vandecappelle
  0 siblings, 0 replies; 18+ messages in thread
From: Arnout Vandecappelle @ 2016-10-16 18:53 UTC (permalink / raw)
  To: buildroot



On 16-10-16 13:12, Samuel Martin wrote:
> This reverts commit 4b0120183404913f7f7788ef4f0f6b51498ef363.
> 
> Before reverting this patch, CMake packages are built with the following
> options:
>   * if BR2_ENABLE_DEBUG is set:
>     The CMake build type is set to RelWithDebInfo, which means:
>     - Optimization level is forced to: -O2;
>     - no log nor assert due to -DNDEBUG;
>     - BR2_DEBUG_{1..3} effect is unchanged;
>   * otherwise:
>     The CMake build type is set to Release, which means:
>     - Optimization level is forced to: -O3;
>     - no log nor assert due to -DNDEBUG (as expected).
>   In any case, the optimization WRT the binary size is always ignored
>   and forced.
> 
> Reverting to the previous situation, so Buildroot now chooses between
> the 'Debug' and 'Release' config types, which are semantically closer
> to what Buildroot does everywhere else:
>   * if BR2_ENABLE_DEBUG is set:
>     The CMake build type is set to Debug, which means:
>     - only -g option is passed by CMake;
>     - optimization is not forced, nor debug level, so they are kept
>       as-is;
>   * otherwise:
>     The CMake build type is set to Release, so no change in this case:
>     - Optimization level is forced to: -O3;
>     - no log nor assert due to -DNDEBUG (as expected);
>     - size optimization is ignored.
> 
> Follow-up patches will fix the CMake flag variables that are appended by
> CMake.
> 
> Cc: Charles Hardin <ckhardin@exablox.com>
> 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>


 Regards,
 Arnout

> 
> ---
> changes v5->v6:
> - revert 4b01201 instead (Arnout)
> 
> changes v4->v5:
> - none
> 
> changes v3->v4:
> - simplify build type selection
> ---
>  package/pkg-cmake.mk | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
> index aca9e61..4883b3b 100644
> --- a/package/pkg-cmake.mk
> +++ b/package/pkg-cmake.mk
> @@ -87,7 +87,7 @@ define $(2)_CONFIGURE_CMDS
>  	PATH=$$(BR_PATH) \
>  	$$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \
>  		-DCMAKE_TOOLCHAIN_FILE="$$(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake" \
> -		-DCMAKE_BUILD_TYPE=$$(if $$(BR2_ENABLE_DEBUG),RelWithDebInfo,Release) \
> +		-DCMAKE_BUILD_TYPE=$$(if $$(BR2_ENABLE_DEBUG),Debug,Release) \
>  		-DCMAKE_INSTALL_PREFIX="/usr" \
>  		-DCMAKE_COLOR_MAKEFILE=OFF \
>  		-DBUILD_DOC=OFF \
> 

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v6 2/9] package/pkg-cmake.mk: move CMAKE_BUILD_TYPE definition into toolchainfile.cmake
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 2/9] package/pkg-cmake.mk: move CMAKE_BUILD_TYPE definition into toolchainfile.cmake Samuel Martin
@ 2016-10-16 19:05   ` Arnout Vandecappelle
  2016-10-22 14:43   ` Thomas Petazzoni
  1 sibling, 0 replies; 18+ messages in thread
From: Arnout Vandecappelle @ 2016-10-16 19:05 UTC (permalink / raw)
  To: buildroot



On 16-10-16 13:12, Samuel Martin wrote:
> The chosen CMAKE_BUILD_TYPE encodes an option of the Buildroot
> configuration, so it makes more sense to save it in the
> toolchainfile.cmake than to pass it during configure.
> 
> It is still possible to override the build type on the cmake
> command line.
> 
> 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>
except for a small typo in the CHANGES file...

> 
> ---
> changes v5->v6:
> - reword commit log (Arnout)
> - simplify/remove intermediate variable (Arnout)
> 
> changes v4->v5:
> - fix cmake set call
> 
> changes v3->v4:
> - new patch
> ---
>  CHANGES                             | 6 ++++++
>  package/pkg-cmake.mk                | 2 +-
>  support/misc/toolchainfile.cmake.in | 3 +++
>  3 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/CHANGES b/CHANGES
> index b4bd5fe..c0e3e79 100644
> --- a/CHANGES
> +++ b/CHANGES
> @@ -1,3 +1,9 @@
> +2016.11-rc1,
> +
> +    toolchainfile.cmake:
> +    * when used outside of Buildroot, if not specified on the command
> +      line, the CMAKE_BUILD_TYPE is by toolchainfile.cmake.
                                      ^^set

 Actually the "when used outside of Buildroot" part is redundant because it is
still true when used inside Buildroot :-)


 Regards,
 Arnout

> +
>  2016.08, Released September 1st, 2016
>  
>  	Minor fixes.
> diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
> index 4883b3b..4e0e838 100644
> --- a/package/pkg-cmake.mk
> +++ b/package/pkg-cmake.mk
> @@ -87,7 +87,6 @@ define $(2)_CONFIGURE_CMDS
>  	PATH=$$(BR_PATH) \
>  	$$($$(PKG)_CONF_ENV) $$(BR2_CMAKE) $$($$(PKG)_SRCDIR) \
>  		-DCMAKE_TOOLCHAIN_FILE="$$(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake" \
> -		-DCMAKE_BUILD_TYPE=$$(if $$(BR2_ENABLE_DEBUG),Debug,Release) \
>  		-DCMAKE_INSTALL_PREFIX="/usr" \
>  		-DCMAKE_COLOR_MAKEFILE=OFF \
>  		-DBUILD_DOC=OFF \
> @@ -247,5 +246,6 @@ $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake:
>  		-e 's#@@TARGET_FC@@#$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_FC)))#' \
>  		-e 's#@@CMAKE_SYSTEM_PROCESSOR@@#$(call qstrip,$(CMAKE_SYSTEM_PROCESSOR))#' \
>  		-e 's#@@TOOLCHAIN_HAS_FORTRAN@@#$(if $(BR2_TOOLCHAIN_HAS_FORTRAN),1,0)#' \
> +		-e 's#@@CMAKE_BUILD_TYPE@@#$(if $(BR2_ENABLE_DEBUG),Debug,Release)#' \
>  		$(TOPDIR)/support/misc/toolchainfile.cmake.in \
>  		> $@
> diff --git a/support/misc/toolchainfile.cmake.in b/support/misc/toolchainfile.cmake.in
> index 649b52d..1c5031f 100644
> --- a/support/misc/toolchainfile.cmake.in
> +++ b/support/misc/toolchainfile.cmake.in
> @@ -13,6 +13,9 @@ string(REPLACE "/usr/share/buildroot" "" RELOCATED_HOST_DIR ${CMAKE_CURRENT_LIST
>  set(CMAKE_SYSTEM_NAME Linux)
>  set(CMAKE_SYSTEM_PROCESSOR @@CMAKE_SYSTEM_PROCESSOR@@)
>  
> +# Build type from the Buildroot configuration
> +set(CMAKE_BUILD_TYPE @@CMAKE_BUILD_TYPE@@ CACHE STRING "Buildroot build configuration")
> +
>  set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@ ${CMAKE_C_FLAGS}" CACHE STRING "Buildroot CFLAGS")
>  set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@ ${CMAKE_CXX_FLAGS}" CACHE STRING "Buildroot CXXFLAGS")
>  set(CMAKE_EXE_LINKER_FLAGS "@@TARGET_LDFLAGS@@ ${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "Buildroot LDFLAGS")
> 

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v6 3/9] toolchainfile.cmake: set per-config appended {C, CXX}FLAGS
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 3/9] toolchainfile.cmake: set per-config appended {C, CXX}FLAGS Samuel Martin
@ 2016-10-16 19:09   ` Arnout Vandecappelle
  2016-10-22 14:43   ` Thomas Petazzoni
  1 sibling, 0 replies; 18+ messages in thread
From: Arnout Vandecappelle @ 2016-10-16 19:09 UTC (permalink / raw)
  To: buildroot



On 16-10-16 13:12, Samuel Martin wrote:
> 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>

 Small improvement in the comment is still possible...

> 
> ---
> changes v5->v6:
> - reword commit log
> 
> changes v4->v5:
> - fix cmake set call
> 
> changes v3->v4:
> - new patch
> ---
>  support/misc/toolchainfile.cmake.in | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/support/misc/toolchainfile.cmake.in b/support/misc/toolchainfile.cmake.in
> index 1c5031f..2ace940 100644
> --- a/support/misc/toolchainfile.cmake.in
> +++ b/support/misc/toolchainfile.cmake.in
> @@ -13,6 +13,17 @@ string(REPLACE "/usr/share/buildroot" "" RELOCATED_HOST_DIR ${CMAKE_CURRENT_LIST
>  set(CMAKE_SYSTEM_NAME Linux)
>  set(CMAKE_SYSTEM_PROCESSOR @@CMAKE_SYSTEM_PROCESSOR@@)
>  
> +# Set the {C,CXX}FLAGS appended by CMake depending on the build type
> +# sets by Buildroot.

 Add:

CMake defaults these variables with -g and/or -O options, and they are appended
at the end of the argument list, so the Buildroot options are overridden.
Therefore these variables have to be cleared, so the options in CMAKE_C_FLAGS do
apply.

> +#
> +# 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 STRING "Debug CFLAGS")
> +set(CMAKE_CXX_FLAGS_DEBUG "" CACHE STRING "Debug CXXFLAGS")
> +set(CMAKE_C_FLAGS_RELEASE " -DNEBUG" CACHE STRING "Release CFLAGS")
> +set(CMAKE_CXX_FLAGS_RELEASE " -DNEBUG" CACHE STRING "Release CXXFLAGS")

 Shouldn't CMAKE_FC_FLAGS_* be overridden as well?

 Regards,
 Arnout

> +
>  # Build type from the Buildroot configuration
>  set(CMAKE_BUILD_TYPE @@CMAKE_BUILD_TYPE@@ CACHE STRING "Buildroot build configuration")
>  
> 

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v6 9/9] toochainfile.cmake: rework the way Buildroot sets flags
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 9/9] toochainfile.cmake: rework the way Buildroot sets flags Samuel Martin
@ 2016-10-16 19:13   ` Arnout Vandecappelle
  0 siblings, 0 replies; 18+ messages in thread
From: Arnout Vandecappelle @ 2016-10-16 19:13 UTC (permalink / raw)
  To: buildroot



On 16-10-16 13:12, Samuel Martin wrote:
>>From the build configuration, Buildroot defines and set some compiler
                                                         ^s

> and linker flags that should be passed to any packages build-system.
> 
> For package using the cmake-package infrastructure, this is achieved
             ^s

> via the toolchainfile.cmake.
> 
> This change simplifies the way the toolchainfile.cmake file handles
> these flags: it now just sets them, without any attempt to extend them
> with those Buildroot defined.
> 
> This change still allows overriding these flags from the configure
> command line.
> 
> So, now, when a CMake-based package needs to extend them, they should
> be fully set from the package *.mk file. This behavior is consistent
> with what is done for others package infrastructures.
> 
> This change should not pull any regression WRT the bug #7280 [1].
> 
> However, now, when someone uses the toolchainfile.cmake file outside of
> Buildroot, he/she must overload all compiler/linker flags (including the
> ones Buildroot sets since they no longer get automatically added).
> 
> [1] https://bugs.busybox.net/show_bug.cgi?id=7280
> 
> Cc: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
> Cc: Max Filippov <jcmvbkbc@gmail.com>
> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Signed-off-by: Samuel Martin <s.martin49@gmail.com>

Reviewed-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>

> 
> ---
> changes v5->v6:
> - none
> 
> changes v4->v5:
> - fix cmake set call
> 
> changes v3->v4:
> - add a note about what the CMake code should look like (Arnout)
> - fix overriding support (add missing CACHE keyword)
> - update CHANGES text
> ---
>  CHANGES                             |  5 ++++-
>  support/misc/toolchainfile.cmake.in | 17 +++++++++++++----
>  2 files changed, 17 insertions(+), 5 deletions(-)
> 
> diff --git a/CHANGES b/CHANGES
> index c0e3e79..3657710 100644
> --- a/CHANGES
> +++ b/CHANGES
> @@ -2,7 +2,10 @@
>  
>      toolchainfile.cmake:
>      * when used outside of Buildroot, if not specified on the command
> -      line, the CMAKE_BUILD_TYPE is by toolchainfile.cmake.
> +      line, the CMAKE_BUILD_TYPE is by toolchainfile.cmake;

 Don't forget to amend this with the missing "set"


 Regards,
 Arnout


> +    * when used outside of Buildroot with custom compiler/linker
> +      flags, the Buildroot flags should be set along side with the
> +      custom ones.
>  
>  2016.08, Released September 1st, 2016
>  
> diff --git a/support/misc/toolchainfile.cmake.in b/support/misc/toolchainfile.cmake.in
> index 2ace940..0283b62 100644
> --- a/support/misc/toolchainfile.cmake.in
> +++ b/support/misc/toolchainfile.cmake.in
> @@ -27,9 +27,17 @@ set(CMAKE_CXX_FLAGS_RELEASE " -DNEBUG" CACHE STRING "Release CXXFLAGS")
>  # Build type from the Buildroot configuration
>  set(CMAKE_BUILD_TYPE @@CMAKE_BUILD_TYPE@@ CACHE STRING "Buildroot build configuration")
>  
> -set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@ ${CMAKE_C_FLAGS}" CACHE STRING "Buildroot CFLAGS")
> -set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@ ${CMAKE_CXX_FLAGS}" CACHE STRING "Buildroot CXXFLAGS")
> -set(CMAKE_EXE_LINKER_FLAGS "@@TARGET_LDFLAGS@@ ${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "Buildroot LDFLAGS")
> +# Buildroot defaults flags.
> +# If you are using this toolchainfile.cmake file outside of Buildroot and
> +# want to customize the compiler/linker flags, then:
> +# * set them all on the cmake command line, e.g.:
> +#     cmake -DCMAKE_C_FLAGS="@@TARGET_CFLAGS@@ -Dsome_custom_flag" ...
> +# * and make sure the project's CMake code extendsthem like this if needed:
> +#     set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Dsome_definitions")
> +set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@" CACHE STRING "Buildroot CFLAGS")
> +set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@" CACHE STRING "Buildroot CXXFLAGS")
> +set(CMAKE_EXE_LINKER_FLAGS "@@TARGET_LDFLAGS@@" CACHE STRING "Buildroot LDFLAGS for executables")
> +
>  set(CMAKE_INSTALL_SO_NO_EXE 0)
>  
>  set(CMAKE_PROGRAM_PATH "${RELOCATED_HOST_DIR}/usr/bin")
> @@ -45,6 +53,7 @@ set(ENV{PKG_CONFIG_SYSROOT_DIR} "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
>  set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC@@")
>  set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX@@")
>  if(@@TOOLCHAIN_HAS_FORTRAN@@)
> -  set(CMAKE_Fortran_FLAGS "@@TARGET_FCFLAGS@@ ${CMAKE_Fortran_FLAGS}" CACHE STRING "Buildroot FCFLAGS")
> +  # Buildroot defaults flags.
> +  set(CMAKE_Fortran_FLAGS "@@TARGET_FCFLAGS@@" CACHE STRING "Buildroot FCFLAGS")
>    set(CMAKE_Fortran_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_FC@@")
>  endif()
> 

-- 
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v6 0/9] Misc. CMake fixes
  2016-10-16 11:12 [Buildroot] [PATCH v6 0/9] Misc. CMake fixes Samuel Martin
                   ` (8 preceding siblings ...)
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 9/9] toochainfile.cmake: rework the way Buildroot sets flags Samuel Martin
@ 2016-10-22 14:42 ` Thomas Petazzoni
  2016-10-22 15:09   ` Samuel Martin
  9 siblings, 1 reply; 18+ messages in thread
From: Thomas Petazzoni @ 2016-10-22 14:42 UTC (permalink / raw)
  To: buildroot

Hello,

On Sun, 16 Oct 2016 13:12:36 +0200, Samuel Martin wrote:

> Max Filippov (1):
>   package/opencv3: fix CMAKE_CXX_FLAGS
> 
> Samuel Martin (8):
>   Revert "package/cmake: with BR2_ENABLE_DEBUG use RelWithDebInfo"
>   package/pkg-cmake.mk: move CMAKE_BUILD_TYPE definition into
>     toolchainfile.cmake
>   toolchainfile.cmake: set per-config appended {C,CXX}FLAGS
>   package/gflags: include TARGET_CXXFLAGS to the overloaded CXXFLAGS
>   package/gnuradio: include TARGET_CFLAGS to the overloaded CFLAGS
>   package/libcec: include TARGET_{C,CXX}FLAGS to the overloaded
>     {C,CXX}FLAGS
>   package/rpi-userland: include TARGET_CFLAGS to the overloaded CFLAGS
>   toochainfile.cmake: rework the way Buildroot sets flags

I've applied the series. I've done a few changes on specific patches,
I'll reply to the patches themselves.

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v6 3/9] toolchainfile.cmake: set per-config appended {C, CXX}FLAGS
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 3/9] toolchainfile.cmake: set per-config appended {C, CXX}FLAGS Samuel Martin
  2016-10-16 19:09   ` Arnout Vandecappelle
@ 2016-10-22 14:43   ` Thomas Petazzoni
  1 sibling, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2016-10-22 14:43 UTC (permalink / raw)
  To: buildroot

Hello,

On Sun, 16 Oct 2016 13:12:39 +0200, Samuel Martin wrote:

> +# Set the {C,CXX}FLAGS appended by CMake depending on the build type
> +# sets by Buildroot.
> +#
> +# 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 STRING "Debug CFLAGS")
> +set(CMAKE_CXX_FLAGS_DEBUG "" CACHE STRING "Debug CXXFLAGS")
> +set(CMAKE_C_FLAGS_RELEASE " -DNEBUG" CACHE STRING "Release CFLAGS")
> +set(CMAKE_CXX_FLAGS_RELEASE " -DNEBUG" CACHE STRING "Release CXXFLAGS")

As suggested by Arnout, I've changed this commit to also adjust
CMAKE_Fortran_FLAGS_{DEBUG,RELEASE}. Please double check what I've done.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v6 2/9] package/pkg-cmake.mk: move CMAKE_BUILD_TYPE definition into toolchainfile.cmake
  2016-10-16 11:12 ` [Buildroot] [PATCH v6 2/9] package/pkg-cmake.mk: move CMAKE_BUILD_TYPE definition into toolchainfile.cmake Samuel Martin
  2016-10-16 19:05   ` Arnout Vandecappelle
@ 2016-10-22 14:43   ` Thomas Petazzoni
  1 sibling, 0 replies; 18+ messages in thread
From: Thomas Petazzoni @ 2016-10-22 14:43 UTC (permalink / raw)
  To: buildroot

Hello,

On Sun, 16 Oct 2016 13:12:38 +0200, Samuel Martin wrote:

> +    toolchainfile.cmake:
> +    * when used outside of Buildroot, if not specified on the command
> +      line, the CMAKE_BUILD_TYPE is by toolchainfile.cmake.

I've reworded this differently. Please double check that the new text
is fine.

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [Buildroot] [PATCH v6 0/9] Misc. CMake fixes
  2016-10-22 14:42 ` [Buildroot] [PATCH v6 0/9] Misc. CMake fixes Thomas Petazzoni
@ 2016-10-22 15:09   ` Samuel Martin
  0 siblings, 0 replies; 18+ messages in thread
From: Samuel Martin @ 2016-10-22 15:09 UTC (permalink / raw)
  To: buildroot

On Sat, Oct 22, 2016 at 4:42 PM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Hello,
>
> On Sun, 16 Oct 2016 13:12:36 +0200, Samuel Martin wrote:
>
>> Max Filippov (1):
>>   package/opencv3: fix CMAKE_CXX_FLAGS
>>
>> Samuel Martin (8):
>>   Revert "package/cmake: with BR2_ENABLE_DEBUG use RelWithDebInfo"
>>   package/pkg-cmake.mk: move CMAKE_BUILD_TYPE definition into
>>     toolchainfile.cmake
>>   toolchainfile.cmake: set per-config appended {C,CXX}FLAGS
>>   package/gflags: include TARGET_CXXFLAGS to the overloaded CXXFLAGS
>>   package/gnuradio: include TARGET_CFLAGS to the overloaded CFLAGS
>>   package/libcec: include TARGET_{C,CXX}FLAGS to the overloaded
>>     {C,CXX}FLAGS
>>   package/rpi-userland: include TARGET_CFLAGS to the overloaded CFLAGS
>>   toochainfile.cmake: rework the way Buildroot sets flags
>
> I've applied the series. I've done a few changes on specific patches,
> I'll reply to the patches themselves.

All fixes/amendments look fine, thanks.

-- 
Samuel

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2016-10-22 15:09 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-16 11:12 [Buildroot] [PATCH v6 0/9] Misc. CMake fixes Samuel Martin
2016-10-16 11:12 ` [Buildroot] [PATCH v6 1/9] Revert "package/cmake: with BR2_ENABLE_DEBUG use RelWithDebInfo" Samuel Martin
2016-10-16 18:53   ` Arnout Vandecappelle
2016-10-16 11:12 ` [Buildroot] [PATCH v6 2/9] package/pkg-cmake.mk: move CMAKE_BUILD_TYPE definition into toolchainfile.cmake Samuel Martin
2016-10-16 19:05   ` Arnout Vandecappelle
2016-10-22 14:43   ` Thomas Petazzoni
2016-10-16 11:12 ` [Buildroot] [PATCH v6 3/9] toolchainfile.cmake: set per-config appended {C, CXX}FLAGS Samuel Martin
2016-10-16 19:09   ` Arnout Vandecappelle
2016-10-22 14:43   ` Thomas Petazzoni
2016-10-16 11:12 ` [Buildroot] [PATCH v6 4/9] package/gflags: include TARGET_CXXFLAGS to the overloaded CXXFLAGS Samuel Martin
2016-10-16 11:12 ` [Buildroot] [PATCH v6 5/9] package/gnuradio: include TARGET_CFLAGS to the overloaded CFLAGS Samuel Martin
2016-10-16 11:12 ` [Buildroot] [PATCH v6 6/9] package/libcec: include TARGET_{C, CXX}FLAGS to the overloaded {C, CXX}FLAGS Samuel Martin
2016-10-16 11:12 ` [Buildroot] [PATCH v6 7/9] package/opencv3: fix CMAKE_CXX_FLAGS Samuel Martin
2016-10-16 11:12 ` [Buildroot] [PATCH v6 8/9] package/rpi-userland: include TARGET_CFLAGS to the overloaded CFLAGS Samuel Martin
2016-10-16 11:12 ` [Buildroot] [PATCH v6 9/9] toochainfile.cmake: rework the way Buildroot sets flags Samuel Martin
2016-10-16 19:13   ` Arnout Vandecappelle
2016-10-22 14:42 ` [Buildroot] [PATCH v6 0/9] Misc. CMake fixes Thomas Petazzoni
2016-10-22 15:09   ` Samuel Martin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.