Skip to contentSkip to conversation

CMake infrastructure refactoring

PATCH New Samuel Martin 3 participants 33 messages Jun 1, 2014

lore
Share & tools
lore
#0 lore raw

v4 cover CMake infrastructure refactoring

Hi all,

Here is another series about the CMake infrastructure.

No big change in here, except that now the toolchainfile.cmake file is templated instead of being generated.

Yours,
Samuel

Samuel Martin (11):
pkg-cmake.mk: refactor the toolchainfile.cmake generation pkg-cmake.mk: do not hardcode absolute path in toolchainfile.cmake pkg-cmake.mk: enable ccache for cmake packages
rpi-userland: cleanup *_CONF_OPT
xbmc: fix missing libraries from rpi-userland pkg-cmake.mk: globally disable BUILD_TESTING flag pkg-cmake.mk: globally drive the CMAKE_BUILD_TYPE flag using
BR2_ENABLE_DEBUG
openpowerlink: do not override CMAKE_BUILD_TYPE
opencv: do not override CMAKE_BUILD_TYPE
flann: do not override CMAKE_BUILD_TYPE
qhull: do not override CMAKE_BUILD_TYPE

 package/flann/flann.mk                 |  1 -
 package/opencv/opencv.mk               |  1 -
 package/openpowerlink/openpowerlink.mk |  6 ----
 package/pkg-cmake.mk                   | 31 ++++++++++---------
 package/qhull/qhull.mk                 |  1 -
 package/rpi-userland/rpi-userland.mk   |  2 +-
 package/xbmc/xbmc.mk                   |  3 +-
 support/misc/toolchainfile.cmake.in    | 56 ++++++++++++++++++++++++++++++++++
 8 files changed, 76 insertions(+), 25 deletions(-)
 create mode 100644 support/misc/toolchainfile.cmake.in

--
1.9.2

#1 lore raw

PATCH v4 1/11 pkg-cmake.mk: refactor the toolchainfile.cmake generation

This patch introduces a toolchainfile.cmake.in template which is filled by Buildroot.

Using a toolchainfile.cmake.in template file allows to avoid overloading quoting and/or escaping and it becomes much more similar to the resulting file.

This patch also cleans up the quoting style.

Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>
Cc Baruch Siach <[email protected]>

---
changes v3 -> v4:
- rebase
- introduce toolchainfile.cmake template
- squash csets (Baruch, Arnout)
- cleanup quoting (Arnout)

changes v2 -> v3:
- new patch

---
 package/pkg-cmake.mk                | 23 +++++++++--------------
 support/misc/toolchainfile.cmake.in | 20 ++++++++++++++++++++
 2 files changed, 29 insertions(+), 14 deletions(-)
 create mode 100644 support/misc/toolchainfile.cmake.in
package/pkg-cmake.mk +9 -14
index edda14a..a7a9380 100644
@@ -160,17 +160,12 @@ host-cmake-package = $(call inner-cmake-package,host-$(pkgname),$(call UPPERCASE
 
 $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake:
 	@mkdir -p $(@D)
-	@printf "\
-	set(CMAKE_SYSTEM_NAME Linux)\n\
-	set(CMAKE_C_COMPILER $(TARGET_CC_NOCCACHE))\n\
-	set(CMAKE_CXX_COMPILER $(TARGET_CXX_NOCCACHE))\n\
-	set(CMAKE_C_FLAGS \"\$${CMAKE_C_FLAGS} $(TARGET_CFLAGS)\" CACHE STRING \"Buildroot CFLAGS\" FORCE)\n\
-	set(CMAKE_CXX_FLAGS \"\$${CMAKE_CXX_FLAGS} $(TARGET_CXXFLAGS)\" CACHE STRING \"Buildroot CXXFLAGS\" FORCE)\n\
-	set(CMAKE_INSTALL_SO_NO_EXE 0)\n\
-	set(CMAKE_PROGRAM_PATH \"$(HOST_DIR)/usr/bin\")\n\
-	set(CMAKE_FIND_ROOT_PATH \"$(STAGING_DIR)\")\n\
-	set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\n\
-	set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\n\
-	set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)\n\
-	set(ENV{PKG_CONFIG_SYSROOT_DIR} \"$(STAGING_DIR)\")\n\
-	" > $@
+	sed \
+		-e 's:@@HOST_DIR@@:$(call qstrip,$(HOST_DIR)):' \
+		-e 's:@@STAGING_DIR@@:$(call qstrip,$(STAGING_DIR)):' \
+		-e 's:@@TARGET_CFLAGS@@:$(call qstrip,$(TARGET_CFLAGS)):' \
+		-e 's:@@TARGET_CXXFLAGS@@:$(call qstrip,$(TARGET_CXXFLAGS)):' \
+		-e 's:@@TARGET_CC_NOCCACHE@@:$(call qstrip,$(TARGET_CC_NOCCACHE)):' \
+		-e 's:@@TARGET_CXX_NOCCACHE@@:$(call qstrip,$(TARGET_CXX_NOCCACHE)):' \
+		< $(TOPDIR)/support/misc/toolchainfile.cmake.in \
+		> $@
support/misc/toolchainfile.cmake.in new file +20 -0
new file mode 100644
index 0000000..e8cc378
@@ -0,0 +1,20 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# CMake toolchain file for Buildroot
+#
+
+set(CMAKE_SYSTEM_NAME Linux)
+
+set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@ ${CMAKE_C_FLAGS}" CACHE STRING "Buildroot CFLAGS" FORCE)
+set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@ ${CMAKE_CXX_FLAGS}" CACHE STRING "Buildroot CXXFLAGS" FORCE)
+set(CMAKE_INSTALL_SO_NO_EXE 0)
+
+set(CMAKE_PROGRAM_PATH "@@HOST_DIR@@/usr/bin")
+set(CMAKE_FIND_ROOT_PATH "@@STAGING_DIR@@")
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+set(ENV{PKG_CONFIG_SYSROOT_DIR} "@@STAGING_DIR@@")
+
+set(CMAKE_C_COMPILER "@@TARGET_CC_NOCCACHE@@")
+set(CMAKE_CXX_COMPILER "@@TARGET_CXX_NOCCACHE@@")
Signature · 1 line
1.9.2
#2 lore raw

PATCH v4 1/11 pkg-cmake.mk: refactor the toolchainfile.cmake generation

Dear Samuel Martin,

Quoted 7 lines · Samuel Martin

This patch introduces a toolchainfile.cmake.in template which is filled by Buildroot.

Using a toolchainfile.cmake.in template file allows to avoid overloading quoting and/or escaping and it becomes much more similar to the resulting file.

Quoted 5 lines

This patch also cleans up the quoting style.

Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>
Cc Baruch Siach <[email protected]>

package/pkg-cmake.mk host-cmake-package = $(call inner-cmake-package,host-$(pkgname),$(call UPPERCASE · line 170

Quoted 8 lines
package/pkg-cmake.mk +8 -0
+	sed \
+		-e 's:@@HOST_DIR@@:$(call qstrip,$(HOST_DIR)):' \
+		-e 's:@@STAGING_DIR@@:$(call qstrip,$(STAGING_DIR)):' \
+		-e 's:@@TARGET_CFLAGS@@:$(call qstrip,$(TARGET_CFLAGS)):' \
+		-e 's:@@TARGET_CXXFLAGS@@:$(call qstrip,$(TARGET_CXXFLAGS)):' \
+		-e 's:@@TARGET_CC_NOCCACHE@@:$(call qstrip,$(TARGET_CC_NOCCACHE)):' \
+		-e 's:@@TARGET_CXX_NOCCACHE@@:$(call qstrip,$(TARGET_CXX_NOCCACHE)):' \
+		< $(TOPDIR)/support/misc/toolchainfile.cmake.in \

The stdin redirection here is not strictly needed: as argument, sed takes an input file. But it's not necessary to do another post of the patch series just for this, I believe.

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#3 lore raw

PATCH v4 1/11 pkg-cmake.mk: refactor the toolchainfile.cmake generation

In reply to Samuel Martin
Quoted 9 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Samuel" == Samuel Martin <[email protected]> writes:

This patch introduces a toolchainfile.cmake.in template which is filled by Buildroot.

Using a toolchainfile.cmake.in template file allows to avoid overloading quoting and/or escaping and it becomes much more similar to the resulting file.

Quoted 5 lines

This patch also cleans up the quoting style.

Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>
Cc Baruch Siach <[email protected]>

Committed with the stdin redirect changed as suggested by Thomas, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#4 lore raw

PATCH v4 2/11 pkg-cmake.mk: do not hardcode absolute path in toolchainfile.cmake

In reply to Samuel Martin

The patch allows sharing or moving the toolchains.

This is a step toward making the toolchain/sdk relocatable.

Closes #6818

Cc Uwe Strempel <[email protected]>
Cc Arnout Vandecappelle <[email protected]>

---
changes v3 -> v4:
- rebase
- add comments to explain the logic (Arnout)

changes v2 -> v3:
- rebase
- use CMAKE_CURRENT_LIST_DIR instead of get_filename_component()
- rewrite subst call in a more natural way (Arnout)

---
 package/pkg-cmake.mk                | 11 +++++++----
 support/misc/toolchainfile.cmake.in | 17 ++++++++++++-----
 2 files changed, 19 insertions(+), 9 deletions(-)
package/pkg-cmake.mk +7 -4
index a7a9380..2d4a264 100644
@@ -158,14 +158,17 @@ host-cmake-package = $(call inner-cmake-package,host-$(pkgname),$(call UPPERCASE
 # Generation of the CMake toolchain file
 ################################################################################
 
+# In order to allow the toolchain to be relocated, we calculate the HOST_DIR
+# based on the toolchainfile.cmake file's location: $(HOST_DIR)/usr/share/buildroot
+# In all the other variables, HOST_DIR will be replaced by RELOCATED_HOST_DIR,
+# so we have to strip "$(HOST_DIR)/" from the paths that contain it.
 $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake:
 	@mkdir -p $(@D)
 	sed \
-		-e 's:@@HOST_DIR@@:$(call qstrip,$(HOST_DIR)):' \
-		-e 's:@@STAGING_DIR@@:$(call qstrip,$(STAGING_DIR)):' \
+		-e 's:@@STAGING_SUBDIR@@:$(call qstrip,$(STAGING_SUBDIR)):' \
 		-e 's:@@TARGET_CFLAGS@@:$(call qstrip,$(TARGET_CFLAGS)):' \
 		-e 's:@@TARGET_CXXFLAGS@@:$(call qstrip,$(TARGET_CXXFLAGS)):' \
-		-e 's:@@TARGET_CC_NOCCACHE@@:$(call qstrip,$(TARGET_CC_NOCCACHE)):' \
-		-e 's:@@TARGET_CXX_NOCCACHE@@:$(call qstrip,$(TARGET_CXX_NOCCACHE)):' \
+		-e 's:@@TARGET_CC_NOCCACHE@@:$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_CC_NOCCACHE))):' \
+		-e 's:@@TARGET_CXX_NOCCACHE@@:$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_CXX_NOCCACHE))):' \
 		< $(TOPDIR)/support/misc/toolchainfile.cmake.in \
 		> $@
support/misc/toolchainfile.cmake.in +12 -5
index e8cc378..df79acd 100644
@@ -3,18 +3,25 @@
 # CMake toolchain file for Buildroot
 #
 
+# In order to allow the toolchain to be relocated, we calculate the
+# HOST_DIR based on this file's location: $(HOST_DIR)/usr/share/buildroot
+# and store it in RELOCATED_HOST_DIR.
+# In all the other variables that need to refer to HOST_DIR will use
+# the RELOCATED_HOST_DIR variable.
+string(REPLACE "/usr/share/buildroot" "" RELOCATED_HOST_DIR ${CMAKE_CURRENT_LIST_DIR})
+
 set(CMAKE_SYSTEM_NAME Linux)
 
 set(CMAKE_C_FLAGS "@@TARGET_CFLAGS@@ ${CMAKE_C_FLAGS}" CACHE STRING "Buildroot CFLAGS" FORCE)
 set(CMAKE_CXX_FLAGS "@@TARGET_CXXFLAGS@@ ${CMAKE_CXX_FLAGS}" CACHE STRING "Buildroot CXXFLAGS" FORCE)
 set(CMAKE_INSTALL_SO_NO_EXE 0)
 
-set(CMAKE_PROGRAM_PATH "@@HOST_DIR@@/usr/bin")
-set(CMAKE_FIND_ROOT_PATH "@@STAGING_DIR@@")
+set(CMAKE_PROGRAM_PATH "${RELOCATED_HOST_DIR}/usr/bin")
+set(CMAKE_FIND_ROOT_PATH "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-set(ENV{PKG_CONFIG_SYSROOT_DIR} "@@STAGING_DIR@@")
+set(ENV{PKG_CONFIG_SYSROOT_DIR} "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
 
-set(CMAKE_C_COMPILER "@@TARGET_CC_NOCCACHE@@")
-set(CMAKE_CXX_COMPILER "@@TARGET_CXX_NOCCACHE@@")
+set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC_NOCCACHE@@")
+set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX_NOCCACHE@@")
Signature · 1 line
1.9.2
#5 lore raw

PATCH v4 2/11 pkg-cmake.mk: do not hardcode absolute path in toolchainfile.cmake

Dear Samuel Martin,

Quoted 9 lines · Samuel Martin

The patch allows sharing or moving the toolchains.

This is a step toward making the toolchain/sdk relocatable.

Closes #6818

Cc Uwe Strempel <[email protected]>
Cc Arnout Vandecappelle <[email protected]>

support/misc/toolchainfile.cmake.in line 10

Quoted 2 lines
support/misc/toolchainfile.cmake.in +2 -0
+# In all the other variables that need to refer to HOST_DIR will use
+# the RELOCATED_HOST_DIR variable.

There's a typo in this sentence. Either:

"""
All the other variables that need to refer to HOST_DIR will use the RELOCATED_HOST_DIR variable.
"""

or

"""
In all the other variables that need to refer to HOST_DIR, we'll use the RELOCATED_HOST_DIR variable.
"""

But hopefully Peter can fix this while applying.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#6 lore raw

PATCH v4 2/11 pkg-cmake.mk: do not hardcode absolute path in toolchainfile.cmake

In reply to Samuel Martin
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Samuel" == Samuel Martin <[email protected]> writes:

The patch allows sharing or moving the toolchains. This is a step toward making the toolchain/sdk relocatable.

Closes #6818

Quoted 8 lines
Cc Uwe Strempel <[email protected]>
Cc Arnout Vandecappelle <[email protected]>

---
changes v3 -> v4:
- rebase
- add comments to explain the logic (Arnout)

Committed with the comment reworded as suggested by Thomas, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#7 lore raw

PATCH v4 3/11 pkg-cmake.mk: enable ccache for cmake packages

In reply to Samuel Martin

This patch updates the generated toolchainfile.cmake to use ccache.

When toolchainfile.cmake is used inside Buildroot, using ccache during the build is driven by a CMake knob: USE_CCACHE, automatically set by the cmake-package infrastructure and reflecting the BR2_CCACHE value.

Since this toolchainefile.cmake file can be used outside Buildroot, and this file also set a couple of things (among these: the sysroot cflag, some pkg-config environment variables), it is important to set the compiler variables as well to keep the consistency of the cross-compilation configuration.
So, when it is used outside Buildroot, using ccache for the build is driven by the ccache program availability.

Note that using ccache for the build is achieved by setting the *_ARG1 CMake variables to let CMake use ccache without failing in detecting the compiler.

Cc Luca Ceresoli <[email protected]>
Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>

---
changes v3 -> v4 (Samuel):
- rebase
- make sure ccache built by Buildroot can be found when toolchainfile.cmakeis used outside Buildroot (Arnout)

changes v2 -> v3 (Samuel):
- rebase
- inline the -DUSE_CCACHE=... in the configure commands.
- always set the compiler variables, even when called for outside Buildroot.
- update commit message

changes v1 -> v2 (Luca):
- totally reimplemented based on Samuel's suggestion;
- added dependency on host-ccache for cmake packages if ccache is enabled.

---
 package/pkg-cmake.mk                |  2 ++
 support/misc/toolchainfile.cmake.in | 33 +++++++++++++++++++++++++++++++--
 2 files changed, 33 insertions(+), 2 deletions(-)
package/pkg-cmake.mk +2 -0
index 2d4a264..1de1d4a 100644
@@ -66,6 +66,7 @@ define $(2)_CONFIGURE_CMDS
 		-DCMAKE_INSTALL_PREFIX="/usr" \
 		-DCMAKE_COLOR_MAKEFILE=OFF \
 		-DBUILD_SHARED_LIBS=$(if $(BR2_PREFER_STATIC_LIB),OFF,ON) \
+		-DUSE_CCACHE=$(if $(BR2_CCACHE),ON,OFF) \
 		$$($$(PKG)_CONF_OPT) \
 	)
 endef
@@ -83,6 +84,7 @@ define $(2)_CONFIGURE_CMDS
 		-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY="BOTH" \
 		-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE="BOTH" \
 		-DCMAKE_INSTALL_PREFIX="$$(HOST_DIR)/usr" \
+		-DUSE_CCACHE=$(if $(BR2_CCACHE),ON,OFF) \
 		$$($$(PKG)_CONF_OPT) \
 	)
 endef
support/misc/toolchainfile.cmake.in +31 -2
index df79acd..8cf28e9 100644
@@ -23,5 +23,34 @@ set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
 set(ENV{PKG_CONFIG_SYSROOT_DIR} "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
 
-set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC_NOCCACHE@@")
-set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX_NOCCACHE@@")
+# This toolchain file can be used both inside and outside Buildroot.
+# * When used inside Buildroot, ccache support is explicitly driven using the
+#   USE_CCACHE variable.
+# * When used outside Buildroot (i.e. when USE_CCACHE is not defined), ccache
+#   support is automatically enabled if the ccache program is available.
+if(DEFINED USE_CCACHE)
+	if(USE_CCACHE)
+		set(CMAKE_ASM_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC_NOCCACHE@@")
+		set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/usr/bin/ccache")
+		set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/usr/bin/ccache")
+		set(CMAKE_C_COMPILER_ARG1 "${RELOCATED_HOST_DIR}/@@TARGET_CC_NOCCACHE@@")
+		set(CMAKE_CXX_COMPILER_ARG1 "${RELOCATED_HOST_DIR}/@@TARGET_CXX_NOCCACHE@@")
+	else()
+		set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC_NOCCACHE@@")
+		set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX_NOCCACHE@@")
+	endif()
+else()
+	find_program(CCACHE ccache HINTS "${RELOCATED_HOST_DIR}/usr/bin")
+	if(CCACHE)
+		set(CMAKE_ASM_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC_NOCCACHE@@")
+		set(CMAKE_C_COMPILER "${CCACHE}")
+		set(CMAKE_CXX_COMPILER "${CCACHE}")
+		set(CMAKE_C_COMPILER_ARG1 "${RELOCATED_HOST_DIR}/@@TARGET_CC_NOCCACHE@@")
+		set(CMAKE_CXX_COMPILER_ARG1 "${RELOCATED_HOST_DIR}/@@TARGET_CXX_NOCCACHE@@")
+		message(STATUS "ccache program has been found and will be used for the build.")
+		message(STATUS "  To disable ccache, add -DUSE_CCACHE=OFF on the cmake command line.")
+	else()
+		set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC_NOCCACHE@@")
+		set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX_NOCCACHE@@")
+	endif()
+endif()
Signature · 1 line
1.9.2
#8 lore raw

PATCH v4 3/11 pkg-cmake.mk: enable ccache for cmake packages

Dear Samuel Martin,

Quoted 14 lines · Samuel Martin

This patch updates the generated toolchainfile.cmake to use ccache.

When toolchainfile.cmake is used inside Buildroot, using ccache during the build is driven by a CMake knob: USE_CCACHE, automatically set by the cmake-package infrastructure and reflecting the BR2_CCACHE value.

Since this toolchainefile.cmake file can be used outside Buildroot, and this file also set a couple of things (among these: the sysroot cflag, some pkg-config environment variables), it is important to set the compiler variables as well to keep the consistency of the cross-compilation configuration.
So, when it is used outside Buildroot, using ccache for the build is driven by the ccache program availability.

Quoted 8 lines

Note that using ccache for the build is achieved by setting the *_ARG1 CMake variables to let CMake use ccache without failing in detecting the compiler.

Cc Luca Ceresoli <[email protected]>
Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#9 lore raw

PATCH v4 3/11 pkg-cmake.mk: enable ccache for cmake packages

In reply to Samuel Martin
Quoted 15 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Samuel" == Samuel Martin <[email protected]> writes:

This patch updates the generated toolchainfile.cmake to use ccache. When toolchainfile.cmake is used inside Buildroot, using ccache during the build is driven by a CMake knob: USE_CCACHE, automatically set by the cmake-package infrastructure and reflecting the BR2_CCACHE value.

Since this toolchainefile.cmake file can be used outside Buildroot, and this file also set a couple of things (among these: the sysroot cflag, some pkg-config environment variables), it is important to set the compiler variables as well to keep the consistency of the cross-compilation configuration.
So, when it is used outside Buildroot, using ccache for the build is driven by the ccache program availability.

Quoted 8 lines

Note that using ccache for the build is achieved by setting the *_ARG1 CMake variables to let CMake use ccache without failing in detecting the compiler.

Cc Luca Ceresoli <[email protected]>
Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#10 lore raw

PATCH v4 4/11 rpi-userland: cleanup *_CONF_OPT

In reply to Samuel Martin

rpi-userland does not need -DBUILD_SHARED_LIBS=OFF to be passed to correclty build its static libraries; so remove this cmake flag from the configure options.

Cc "Yann E. MORIN" <[email protected]>

---
changes v3 -> v4:
- rebase

changes v2 -> v3:
- new patch

---
 package/rpi-userland/rpi-userland.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/rpi-userland/rpi-userland.mk +1 -1
index 8b225ba..2de6b92 100644
@@ -9,7 +9,7 @@ RPI_USERLAND_SITE = $(call github,raspberrypi,userland,$(RPI_USERLAND_VERSION))
 RPI_USERLAND_LICENSE = BSD-3c
 RPI_USERLAND_LICENSE_FILES = LICENCE
 RPI_USERLAND_INSTALL_STAGING = YES
-RPI_USERLAND_CONF_OPT = -DVMCS_INSTALL_PREFIX=/usr -DBUILD_SHARED_LIBS=OFF
+RPI_USERLAND_CONF_OPT = -DVMCS_INSTALL_PREFIX=/usr
 
 RPI_USERLAND_PROVIDES = libegl libgles libopenmax libopenvg
 
Signature · 1 line
1.9.2
#11 lore raw

PATCH v4 4/11 rpi-userland: cleanup *_CONF_OPT

Dear Samuel Martin,

Quoted 6 lines · Samuel Martin

rpi-userland does not need -DBUILD_SHARED_LIBS=OFF to be passed to correclty build its static libraries; so remove this cmake flag from the configure options.

Cc "Yann E. MORIN" <[email protected]>

As discussed in real-life, this should probably be squashed with PATCH 05/11, and with an expanded explanation that details why reverting 5e3b1f31b3f82e3b163567f10d7131c9d649a2cf does not re-introduce the bug that 5e3b1f31b3f82e3b163567f10d7131c9d649a2cf was fixing.

Maybe you should submit these fixes separately, since they are not related to the CMake package infrastructure per se?

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#12 lore raw

PATCH v4 5/11 xbmc: fix missing libraries from rpi-userland

In reply to Samuel Martin

When rpi-userland libraries are built as shared-objects, not all needed libraries are passed in the LD_FLAGS, leading to failure at linkage.

To avoid this issue, set the LIBS variable content in accordance with the INCLUDES variable value.

---
changes v3 -> v4:
- rebase

changes v2 -> v3:
- new patch

---
 package/xbmc/xbmc.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
package/xbmc/xbmc.mk +2 -1
index c7a4607..8c0146e 100644
@@ -53,7 +53,8 @@ ifeq ($(BR2_PACKAGE_RPI_USERLAND),y)
 XBMC_DEPENDENCIES += rpi-userland
 XBMC_CONF_OPT += --with-platform=raspberry-pi --enable-player=omxplayer
 XBMC_CONF_ENV += INCLUDES="-I$(STAGING_DIR)/usr/include/interface/vcos/pthreads \
-	-I$(STAGING_DIR)/usr/include/interface/vmcs_host/linux"
+	-I$(STAGING_DIR)/usr/include/interface/vmcs_host/linux" \
+	LIBS="-lvcos -lvchostif"
 endif
 
 ifeq ($(BR2_PACKAGE_DBUS),y)
Signature · 1 line
1.9.2
#13 lore raw

PATCH v4 6/11 pkg-cmake.mk: globally disable BUILD_TESTING flag

In reply to Samuel Martin

This CMake flag is used to enable tests. It may not disable the test programs from being built, but it controls the test execution.

Since we don't care about building the tests (and usually disable them when possible), make sure Buildroot won't try to run them.

Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>

---
changes v3 -> v4:
- rebase
- disable BUILD_TESTING for host-package as well (Arnout)

changes v2 -> v3:
- new patch

---
 package/pkg-cmake.mk | 2 ++
 1 file changed, 2 insertions(+)
package/pkg-cmake.mk +2 -0
index 1de1d4a..c34b979 100644
@@ -65,6 +65,7 @@ define $(2)_CONFIGURE_CMDS
 		-DCMAKE_TOOLCHAIN_FILE="$$(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake" \
 		-DCMAKE_INSTALL_PREFIX="/usr" \
 		-DCMAKE_COLOR_MAKEFILE=OFF \
+		-DBUILD_TESTING=OFF \
 		-DBUILD_SHARED_LIBS=$(if $(BR2_PREFER_STATIC_LIB),OFF,ON) \
 		-DUSE_CCACHE=$(if $(BR2_CCACHE),ON,OFF) \
 		$$($$(PKG)_CONF_OPT) \
@@ -85,6 +86,7 @@ define $(2)_CONFIGURE_CMDS
 		-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE="BOTH" \
 		-DCMAKE_INSTALL_PREFIX="$$(HOST_DIR)/usr" \
 		-DUSE_CCACHE=$(if $(BR2_CCACHE),ON,OFF) \
+		-DBUILD_TESTING=OFF \
 		$$($$(PKG)_CONF_OPT) \
 	)
 endef
Signature · 1 line
1.9.2
#14 lore raw

PATCH v4 6/11 pkg-cmake.mk: globally disable BUILD_TESTING flag

Dear Samuel Martin,

Quoted 8 lines · Samuel Martin

This CMake flag is used to enable tests. It may not disable the test programs from being built, but it controls the test execution.

Since we don't care about building the tests (and usually disable them when possible), make sure Buildroot won't try to run them.

Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#15 lore raw

PATCH v4 6/11 pkg-cmake.mk: globally disable BUILD_TESTING flag

In reply to Samuel Martin
Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Samuel" == Samuel Martin <[email protected]> writes:

This CMake flag is used to enable tests. It may not disable the test programs from being built, but it controls the test execution.

Since we don't care about building the tests (and usually disable them when possible), make sure Buildroot won't try to run them.

Cc Arnout Vandecappelle (Essensium/Mind) <[email protected]>

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#16 lore raw

PATCH v4 7/11 pkg-cmake.mk: globally drive the CMAKE_BUILD_TYPE flag using BR2_ENABLE_DEBUG

In reply to Samuel Martin

This CMake flag is usually used to adjust compiler flags (like: -Ox, -g, etc).

So, it makes sense for Buildroot to globally drive this CMake flags in the cmake-package infrastructure.

However, if a package prefer overriding this default setting, it still can via the <PKG>_CONF_OPT variable.

---
changes v3 -> v4:
- rebase
- add tags

changes v2 -> v3:
- new patch

---
 package/pkg-cmake.mk | 1 +
 1 file changed, 1 insertion(+)
package/pkg-cmake.mk +1 -0
index c34b979..5ccda76 100644
@@ -63,6 +63,7 @@ define $(2)_CONFIGURE_CMDS
 	PATH=$(BR_PATH) \
 	$$($$(PKG)_CONF_ENV) $(HOST_DIR)/usr/bin/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_TESTING=OFF \
Signature · 1 line
1.9.2
#17 lore raw

PATCH v4 7/11 pkg-cmake.mk: globally drive the CMAKE_BUILD_TYPE flag using BR2_ENABLE_DEBUG

Dear Samuel Martin,

Quoted 6 lines · Samuel Martin

This CMake flag is usually used to adjust compiler flags (like: -Ox, -g, etc).

So, it makes sense for Buildroot to globally drive this CMake flags in the cmake-package infrastructure.

Quoted 6 lines

However, if a package prefer overriding this default setting, it still can via the <PKG>_CONF_OPT variable.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#18 lore raw

PATCH v4 7/11 pkg-cmake.mk: globally drive the CMAKE_BUILD_TYPE flag using BR2_ENABLE_DEBUG

In reply to Samuel Martin
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Samuel" == Samuel Martin <[email protected]> writes:

This CMake flag is usually used to adjust compiler flags (like: -Ox, -g, etc).

So, it makes sense for Buildroot to globally drive this CMake flags in the cmake-package infrastructure.

Quoted 6 lines

However, if a package prefer overriding this default setting, it still can via the <PKG>_CONF_OPT variable.

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard
#19 lore raw

PATCH v4 8/11 openpowerlink: do not override CMAKE_BUILD_TYPE

In reply to Samuel Martin

This flag is already correctly set by the cmake-package infrastructure.

---
changes v3 -> v4:
- rebase

changes v2 -> v3:
- new patch

---
 package/openpowerlink/openpowerlink.mk | 6 ------
 1 file changed, 6 deletions(-)
package/openpowerlink/openpowerlink.mk +0 -6
index 152f014..a888eb3 100644
@@ -25,12 +25,6 @@ OPENPOWERLINK_CONF_OPT = -DCMAKE_SYSTEM_PROCESSOR=$(OPENPOWERLINK_ARCH)
 # so force static lib to build libpowerlink.a
 OPENPOWERLINK_CONF_OPT += -DBUILD_SHARED_LIBS=OFF
 
-ifeq ($(BR2_ENABLE_DEBUG),y)
-OPENPOWERLINK_CONF_OPT += -DCMAKE_BUILD_TYPE=Debug
-else
-OPENPOWERLINK_CONF_OPT += -DCMAKE_BUILD_TYPE=Release
-endif
-
 OPENPOWERLINK_CONF_OPT += -DCFG_DEBUG_LVL=$(call qstrip,$(BR2_PACKAGE_OPENPOWERLINK_DEBUG_LEVEL))
 
 ifeq ($(BR2_PACKAGE_OPENPOWERLINK_LIBPCAP),y)
Signature · 1 line
1.9.2
#22 lore raw

PATCH v4 9/11 opencv: do not override CMAKE_BUILD_TYPE

In reply to Samuel Martin

This flag is already correctly set by the cmake-package infrastructure.

---
changes v3 -> v4:
- rebase

changes v2 -> v3:
- new patch

---
 package/opencv/opencv.mk | 1 -
 1 file changed, 1 deletion(-)
package/opencv/opencv.mk +0 -1
index 42f9b0a..3fcba80 100644
@@ -10,7 +10,6 @@ OPENCV_SOURCE  = OpenCV-$(OPENCV_VERSION).tar.bz2
 OPENCV_INSTALL_STAGING = YES
 
 OPENCV_CONF_OPT += \
-	-DCMAKE_BUILD_TYPE=$(if $(BR2_ENABLE_DEBUG),Debug,Release)   \
 	-DBUILD_WITH_STATIC_CRT=OFF                                  \
 	-DBUILD_DOCS=OFF                                             \
 	-DBUILD_EXAMPLES=OFF                                         \
Signature · 1 line
1.9.2
#25 lore raw

PATCH v4 10/11 flann: do not override CMAKE_BUILD_TYPE

In reply to Samuel Martin

This flag is already correctly set by the cmake-package infrastructure.

---
changes v3 -> v4:
- rebase

changes v2 -> v3:
- new patch

---
 package/flann/flann.mk | 1 -
 1 file changed, 1 deletion(-)
package/flann/flann.mk +0 -1
index 5b73881..dc9cd1a 100644
@@ -10,7 +10,6 @@ FLANN_INSTALL_STAGING = YES
 FLANN_LICENSE = BSD-3c
 FLANN_LICENSE_FILES = COPYING
 FLANN_CONF_OPT = \
-	-DCMAKE_BUILD_TYPE=Release \
 	-DBUILD_C_BINDINGS=ON \
 	-DBUILD_PYTHON_BINDINGS=OFF \
 	-DBUILD_MATLAB_BINDINGS=OFF \
Signature · 1 line
1.9.2
#28 lore raw

PATCH v4 11/11 qhull: do not override CMAKE_BUILD_TYPE

In reply to Samuel Martin

This flag is already correctly set by the cmake-package infrastructure.

---
changes v3 -> v4:
- rebase

changes v2 -> v3:
- new patch

---
 package/qhull/qhull.mk | 1 -
 1 file changed, 1 deletion(-)
package/qhull/qhull.mk +0 -1
index 15fb46e..6992d71 100644
@@ -9,6 +9,5 @@ QHULL_SITE = git://gitorious.org/qhull/qhull.git
 QHULL_INSTALL_STAGING = YES
 QHULL_LICENSE = BSD-Style
 QHULL_LICENSE_FILES = COPYING.txt
-QHULL_CONF_OPT = -DCMAKE_BUILD_TYPE=Release
 
 $(eval $(cmake-package))
Signature · 1 line
1.9.2
#31 lore raw

v4 cover CMake infrastructure refactoring

In reply to Samuel Martin

Peter,

Quoted 4 lines · Samuel Martin

Here is another series about the CMake infrastructure.

No big change in here, except that now the toolchainfile.cmake file is templated instead of being generated.

Could you apply patches 1 to 3 and 6 to 11 from this series? I think they are ready, and they have been around for quite some time, so they should be applied now.

Thanks,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#32 lore raw

v4 cover CMake infrastructure refactoring

Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Thomas" == Thomas Petazzoni <[email protected]> writes:

Peter,
On Sun, 1 Jun 2014 11:24:22 +0200, Samuel Martin wrote:

Quoted 8 lines
Quoted 4 lines

Here is another series about the CMake infrastructure.

No big change in here, except that now the toolchainfile.cmake file is templated instead of being generated.

Could you apply patches 1 to 3 and 6 to 11 from this series? I think they are ready, and they have been around for quite some time, so they should be applied now.

Done, thanks.

Signature · 1 line
Bye, Peter Korsgaard