Misc. CMake fixes
v5 cover Misc. CMake fixes
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):
package/pkg-cmake.mk: fix build type and optimization flags 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 | 10 +++++++++- package/rpi-userland/rpi-userland.mk | 3 ++- support/misc/toolchainfile.cmake.in | 32 ++++++++++++++++++++++++++++---- 8 files changed, 55 insertions(+), 11 deletions(-)
--
2.10.0
PATCH v5 1/9 package/pkg-cmake.mk: fix build type and optimization flags
tl;dr:
Before applying 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.
This change chooses the build type doing the closest thing to what Buildroot attempts to do.
Long version:
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_n | -On -gx
n | BR2_OPTIMIZE_S | -Os
n | BR2_OPTIMIZE_G | -Og
n | BR2_OPTIMIZE_n | -OnDefault 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 BRSince CMake appends its own build type flags and because of the gcc option parser, the CMake flags takes precedence over the Buildroot flags.
So, this change sets the build type in a very simple way depending on the BR2_ENABLE_DEBUG symbol.
Follow-up patches will fix the CMake flag variables that are appended by CMake.
---
changes v4->v5:
- none
changes v3->v4:
- simplify build type selection
--- package/pkg-cmake.mk | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
package/pkg-cmake.mk +9 -1
@@ -35,6 +35,14 @@ ifneq ($(QUIET),) CMAKE_QUIET = -DCMAKE_RULE_MESSAGES=OFF -DCMAKE_INSTALL_MESSAGE=NEVER endif +# Set the CMake build type which matches the best the build configuration sets +# in Buildroot. +ifeq ($(BR2_ENABLE_DEBUG),y) +BR_CMAKE_BUILD_TYPE=Debug +else +BR_CMAKE_BUILD_TYPE=Release +endif + ################################################################################ # inner-cmake-package -- defines how the configuration, compilation and # installation of a CMake package should be done, implements a few hooks to
@@ -87,7 +95,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=$(BR_CMAKE_BUILD_TYPE) \ -DCMAKE_INSTALL_PREFIX="/usr" \ -DCMAKE_COLOR_MAKEFILE=OFF \ -DBUILD_DOC=OFF \
Signature · 1 line
2.10.0
PATCH v5 1/9 package/pkg-cmake.mk: fix build type and optimization flags
Subject is wrong: no optimization flags are fixed.
Quoted 46 lines · Samuel Martin
tl;dr:
Before applying this patch, CMake packages are built with the following options:
* ifBR2_ENABLE_DEBUGis 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.This change chooses the build type doing the closest thing to what Buildroot attempts to do.
Long version:
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_n | -On -gx n | BR2_OPTIMIZE_S | -Os n | BR2_OPTIMIZE_G | -Og n | BR2_OPTIMIZE_n | -OnDefault 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 BRSince CMake appends its own build type flags and because of the gcc option parser, the CMake flags takes precedence over the Buildroot flags.
Quoted 5 lines
So, this change sets the build type in a very simple way depending on the
BR2_ENABLE_DEBUGsymbol.Follow-up patches will fix the CMake flag variables that are appended by CMake.
Most of this explanation fits better in patch 3, because here we're not yet
fixing anything.
Also, this patch is now basically reverting4b0120183404913f7f7788ef4f0f6b51498ef363, so that should be mentioned.
How about:
package/pkg-cmake.mk: use Debug or Release build types
Before applying 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.
In particular, the -DNDEBUG added by RelWithDebInfo is wrong because it removes assertions and logging, which is exactly what we do want in BR2_ENABLE_DEBUG.
Follow-up patches will fix the CMake flag variables that are appended by CMake. But then, the 'Debug' and 'Release' config types make more semantical sense than 'RelWithDebInfo' and 'Release'. So revert commit 4b012018 which introduced RelWithDebInfo.
Quoted 21 lines
Cc Charles Hardin <[email protected]>Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>Signed-off-by Samuel Martin <[email protected]>Signed-off-by Maxime Hadjinlian <[email protected]>---
changesv4->v5:
- nonechanges
v3->v4:
- simplify build type selection--- package/pkg-cmake.mk | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)package/pkg-cmake.mk +0
-0
package/pkg-cmake.mk ifneq ($(QUIET),) · line 39
Quoted 5 lines
package/pkg-cmake.mk +2
-0@@ -35,6 +35,14 @@ ifneq ($(QUIET),) CMAKE_QUIET = -DCMAKE_RULE_MESSAGES=OFF -DCMAKE_INSTALL_MESSAGE=NEVER endif +# Set the CMake build type which matches the best the build configuration sets +# in Buildroot.
This explanation is now not needed anymore: it's quite obvious that debug
corresponds to debug...
package/pkg-cmake.mk ifneq ($(QUIET),) · line 44
Quoted 5 lines
package/pkg-cmake.mk +5
-0+ifeq ($(BR2_ENABLE_DEBUG),y) +BR_CMAKE_BUILD_TYPE=Debug +else +BR_CMAKE_BUILD_TYPE=Release +endif
This is now so simple that the original in-line definition is good enough.
In other words, I would do an exact revert of commit 4b012018 instead of
introducing a new symbol that is used only once (after patch 2 it is still used only once).
Regards,
Arnout
Quoted 14 lines
package/pkg-cmake.mk +2
-1+ ################################################################################ # inner-cmake-package -- defines how the configuration, compilation and # installation of a CMake package should be done, implements a few hooks to@@ -87,7 +95,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=$(BR_CMAKE_BUILD_TYPE) \ -DCMAKE_INSTALL_PREFIX="/usr" \ -DCMAKE_COLOR_MAKEFILE=OFF \ -DBUILD_DOC=OFF \
Signature · 6 lines
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
PATCH v5 2/9 package/pkg-cmake.mk: move CMAKE_BUILD_TYPE definition into toolchainfile.cmake
In reply to Samuel MartinThis change still allows overriding the build type from the configure command line.
---
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(-)
CHANGES +6 -0
@@ -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.
package/pkg-cmake.mk +1 -1
@@ -95,7 +95,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=$(BR_CMAKE_BUILD_TYPE) \ -DCMAKE_INSTALL_PREFIX="/usr" \ -DCMAKE_COLOR_MAKEFILE=OFF \ -DBUILD_DOC=OFF \
@@ -255,5 +254,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#@@BR_CMAKE_BUILD_TYPE@@#$(BR_CMAKE_BUILD_TYPE)#' \ $(TOPDIR)/support/misc/toolchainfile.cmake.in \ > $@
support/misc/toolchainfile.cmake.in +3 -0
@@ -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 @@BR_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")
Signature · 1 line
2.10.0
PATCH v5 2/9 package/pkg-cmake.mk: move CMAKE_BUILD_TYPE definition into toolchainfile.cmake
Quoted 2 lines · Samuel Martin
This change still allows overriding the build type from the configure command line.
Maybe explain why we want this:
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.
Quoted 22 lines
Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>Cc Maxime Hadjinlian <[email protected]>Signed-off-by Samuel Martin <[email protected]>---
changesv4->v5:
- fix cmake set callchanges
v3->v4:
- new patch--- CHANGES | 6 ++++++ package/pkg-cmake.mk | 2 +- support/misc/toolchainfile.cmake.in | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-)CHANGES +0
-0
CHANGES line 5
Quoted 5 lines
CHANGES +5
-0@@ -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.
I'm not sure if this is something important enough to mention in the CHANGES.
If it is (up to Peter to decide when commit I'd say), the maybe rephrase as
* when used outside of Buildroot, the toolchainfile.cmake will set the CMAKE_BUILD_TYPE to Debug or Release, according to the configuration. It is still possible to override this by adding -DCMAKE_BUILD_TYPE=... on the cmake command line.
Quoted 17 lines
CHANGES +1
-0+ 2016.08, Released September 1st, 2016 Minor fixes.package/pkg-cmake.mk +0
-1@@ -95,7 +95,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=$(BR_CMAKE_BUILD_TYPE) \ -DCMAKE_INSTALL_PREFIX="/usr" \ -DCMAKE_COLOR_MAKEFILE=OFF \ -DBUILD_DOC=OFF \
package/pkg-cmake.mk $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake: · line 257
Quoted 4 lines
package/pkg-cmake.mk +1
-0@@ -255,5 +254,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#@@BR_CMAKE_BUILD_TYPE@@#$(BR_CMAKE_BUILD_TYPE)#' \
So I'd still keep the $(if $(BR2_ENABLE_DEBUG),Debug,Release) form here.
Regards,
Arnout
Quoted 17 lines
package/pkg-cmake.mk +0
-0$(TOPDIR)/support/misc/toolchainfile.cmake.in \ > $@support/misc/toolchainfile.cmake.in +3
-0@@ -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 @@BR_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")
Signature · 6 lines
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
PATCH v5 3/9 toolchainfile.cmake: set per-config appended {C, CXX}FLAGS
In reply to Samuel MartinThe 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.
---
changes v4->v5:
- fix cmake set call
changes v3->v4:
- new patch
--- support/misc/toolchainfile.cmake.in | 12 ++++++++++++ 1 file changed, 12 insertions(+)
support/misc/toolchainfile.cmake.in +12 -0
@@ -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 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 @@BR_CMAKE_BUILD_TYPE@@ CACHE STRING "Buildroot build configuration")
Signature · 1 line
2.10.0
PATCH v5 4/9 package/gflags: include TARGET_CXXFLAGS to the overloaded CXXFLAGS
In reply to Samuel Martin---
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(-)
package/gflags/gflags.mk +2 -1
@@ -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))
Signature · 1 line
2.10.0
PATCH v5 5/9 package/gnuradio: include TARGET_CFLAGS to the overloaded CFLAGS
In reply to Samuel Martin---
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(-)
package/gnuradio/gnuradio.mk +1 -1
@@ -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
Signature · 1 line
2.10.0
PATCH v5 6/9 package/libcec: include TARGET_{C, CXX}FLAGS to the overloaded {C, CXX}FLAGS
In reply to Samuel Martin---
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(-)
package/libcec/libcec.mk +3 -2
@@ -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
Signature · 1 line
2.10.0
PATCH v5 7/9 package/opencv3: fix CMAKE_CXX_FLAGS
In reply to Samuel MartinFrom: Max Filippov <[email protected]>
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
---
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(-)
package/opencv3/opencv3.mk +1 -1
@@ -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
Signature · 1 line
2.10.0
PATCH v5 8/9 package/rpi-userland: include TARGET_CFLAGS to the overloaded CFLAGS
In reply to Samuel Martin---
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(-)
package/rpi-userland/rpi-userland.mk +2 -1
@@ -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
Signature · 1 line
2.10.0
PATCH v5 9/9 toochainfile.cmake: rework the way Buildroot sets flags
In reply to Samuel MartinFrom 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
---
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(-)
CHANGES +4 -1
@@ -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
support/misc/toolchainfile.cmake.in +13 -4
@@ -28,9 +28,17 @@ set(CMAKE_CXX_FLAGS_RELEASE " -DNEBUG" CACHE STRING "Release CXXFLAGS") # Build type from the Buildroot configuration set(CMAKE_BUILD_TYPE @@BR_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")
@@ -46,6 +54,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()
Signature · 1 line
2.10.0