summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorLuca Ceresoli <luca@lucaceresoli.net>2016-09-12 23:59:19 +0200
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>2016-09-17 16:12:06 +0200
commitc2d80a8c5d8b97cdc84c297a3d2d6896fff6560b (patch)
treea9bb85d0e396d8d402142937c2fcfa45c9cff0bf /support
parentce29aaf030bdb82c5eec5ab8deafad6a863a3331 (diff)
core: don't build host-cmake if it is available on the build host
Currently all cmake packages depend on host-cmake. Unfortunately host-cmake takes a long time to configure and build: almost 7 minutes on a dual-core i5 with SSD. The time does not change even with ccache enabled. Indeed, building host-cmake is avoidable if it is already installed on the build host: CMake is supposed to be quite portable, and the only patch in Buildroot for the CMake package seems to only affect target-cmake. Thus we automatically skip building host-cmake and use the one on the system if: - cmake is available on the system and - it is recent enough. First, we leverage the existing infrastructure in support/dependencies/dependencies.mk to find out whether there's a suitable cmake executable on the system. Its path can be passed in the BR2_CMAKE environment variable, otherwise it defaults to "cmake". If it is enabled, found and suitable then we set BR2_CMAKE_HOST_DEPENDENCY to empty; otherwise we set BR2_CMAKE_HOST_DEPENDENCY to 'host-cmake' and override BR2_CMAKE with "$(HOST_DIR)/usr/bin/cmake" to revert to using our own cmake (the old behaviour). Then in pkg-cmake.mk we replace the hard-coded dependency on host-cmake to using the BR2_CMAKE_HOST_DEPENDENCY variable, and we use $(BR2_CMAKE) instead of $(HOST_DIR)/usr/bin/cmake. Unlike what we do for host-tar and host-xzcat, for host-cmake we do not add host-cmake to DEPENDENCIES_HOST_PREREQ. If we did, host-cmake would be a dependency for _any_ package when it's not installed on the host, even when no cmake package is selected. Cmake versions older than 3.0 are affected by the bug described and fixed in Buildroot in ef2c1970e4bf ("cmake: add patch to fix Qt mkspecs detection"). The bug was fixed in upstream CMake in version 3.0 [0]. Amongst all the cmake packages currently in Buildroot, the currently highest version mentioned in cmake_minimum_required() is 3.1 (grantlee and opencv3). Thus we use 3.1 as the lowest required cmake for now, until a package is bumped, or a new package added, with a higher required version. [0] https://cmake.org/gitweb?p=cmake.git;h=e8b8b37ef6fef094940d3384df5a1d421b9fa568 Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net> Cc: Samuel Martin <s.martin49@gmail.com> Cc: Davide Viti <zinosat@tiscali.it> Cc: Arnout Vandecappelle <arnout@mind.be> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Reviewed-by: Romain Naour <romain.naour@gmail.com> Tested-by: Romain Naour <romain.naour@gmail.com> [yann.morin.1998@free.fr: - simplify logic in check-host-cmake.mk; - set and use BR2_CMAKE_HOST_DEPENDENCY, drop USE_SYSTEM_CMAKE; - bump to cmake 3.1 for grantlee and opencv; ] Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Diffstat (limited to 'support')
-rw-r--r--support/dependencies/check-host-cmake.mk18
-rwxr-xr-xsupport/dependencies/check-host-cmake.sh39
2 files changed, 57 insertions, 0 deletions
diff --git a/support/dependencies/check-host-cmake.mk b/support/dependencies/check-host-cmake.mk
new file mode 100644
index 000000000..8002278a3
--- /dev/null
+++ b/support/dependencies/check-host-cmake.mk
@@ -0,0 +1,18 @@
+# Versions before 3.0 are affected by the bug described in
+# https://git.busybox.net/buildroot/commit/?id=ef2c1970e4bff3be3992014070392b0e6bc28bd2
+# and fixed in upstream CMake in version 3.0:
+# https://cmake.org/gitweb?p=cmake.git;h=e8b8b37ef6fef094940d3384df5a1d421b9fa568
+#
+# Set this to either 3.0 or higher, depending on the highest minimum
+# version required by any of the packages bundled in Buildroot. If a
+# package is bumped or a new one added, and it requires a higher
+# version, our cmake infra will catch it and whine.
+#
+BR2_CMAKE_VERSION_MIN = 3.1
+
+BR2_CMAKE ?= cmake
+ifeq ($(call suitable-host-package,cmake,\
+ $(BR2_CMAKE) $(BR2_CMAKE_VERSION_MIN)),)
+BR2_CMAKE = $(HOST_DIR)/usr/bin/cmake
+BR2_CMAKE_HOST_DEPENDENCY = host-cmake
+endif
diff --git a/support/dependencies/check-host-cmake.sh b/support/dependencies/check-host-cmake.sh
new file mode 100755
index 000000000..9b63b0648
--- /dev/null
+++ b/support/dependencies/check-host-cmake.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+candidate="${1}"
+version_min="${2}"
+
+major_min="${version_min%.*}"
+minor_min="${version_min#*.}"
+
+cmake=`which ${candidate}`
+if [ ! -x "${cmake}" ]; then
+ # echo nothing: no suitable cmake found
+ exit 1
+fi
+
+# Extract version X.Y from versions in the form X.Y or X.Y.Z
+# with X, Y and Z numbers with one or more digits each, e.g.
+# 3.2 -> 3.2
+# 3.2.3 -> 3.2
+# 3.2.42 -> 3.2
+# 3.10 -> 3.10
+# 3.10.4 -> 3.10
+# 3.10.42 -> 3.10
+version="$(${cmake} --version \
+ |sed -r -e '/.* ([[:digit:]]+\.[[:digit:]]+).*$/!d;' \
+ -e 's//\1/'
+ )"
+major="${version%.*}"
+minor="${version#*.}"
+
+if [ ${major} -gt ${major_min} ]; then
+ echo "${cmake}"
+else
+ if [ ${major} -eq ${major_min} -a ${minor} -ge ${minor_min} ]; then
+ echo "${cmake}"
+ else
+ # echo nothing: no suitable cmake found
+ exit 1
+ fi
+fi