aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2021-06-06 14:31:01 +0200
committerFelix Fietkau <nbd@nbd.name>2021-06-12 10:46:39 +0200
commit97258f53634d7237a2962aec3387f011047ce83b (patch)
tree24966f800bdf95b4f3ef3126772f5017c78c0c2e /include
parenta85aaa1bc299301ad741b6ef94d7580c9095f1be (diff)
downloadupstream-97258f53634d7237a2962aec3387f011047ce83b.tar.gz
upstream-97258f53634d7237a2962aec3387f011047ce83b.tar.bz2
upstream-97258f53634d7237a2962aec3387f011047ce83b.zip
build: add ninja build tool and make it available for cmake
ninja is faster at building cmake packages than make, and according to reports also more reliable at handling parallel builds This commit includes a patch that adds GNU make jobserver support, in order to allow more precise control over the number of parallel tasks Enable parallel build by default for packages using ninja Signed-off-by: Felix Fietkau <nbd@nbd.name> Signed-off-by: Rosen Penev <rosenp@gmail.com>
Diffstat (limited to 'include')
-rw-r--r--include/cmake.mk34
1 files changed, 34 insertions, 0 deletions
diff --git a/include/cmake.mk b/include/cmake.mk
index 96c4d7df34..8a1c4fc4d5 100644
--- a/include/cmake.mk
+++ b/include/cmake.mk
@@ -1,5 +1,11 @@
cmake_bool = $(patsubst %,-D%:BOOL=$(if $($(1)),ON,OFF),$(2))
+ifeq ($(PKG_USE_NINJA),1)
+ PKG_BUILD_PARALLEL ?= 1
+endif
+ifeq ($(HOST_USE_NINJA),1)
+ HOST_BUILD_PARALLEL ?= 1
+endif
PKG_INSTALL:=1
ifneq ($(findstring c,$(OPENWRT_VERBOSE)),)
@@ -44,6 +50,34 @@ CMAKE_FIND_ROOT_PATH:=$(STAGING_DIR)/usr;$(TOOLCHAIN_DIR)$(if $(CONFIG_EXTERNAL_
CMAKE_HOST_FIND_ROOT_PATH:=$(STAGING_DIR)/host;$(STAGING_DIR_HOSTPKG);$(STAGING_DIR_HOST)
CMAKE_SHARED_LDFLAGS:=-Wl,-Bsymbolic-functions
+ifeq ($(HOST_USE_NINJA),1)
+ CMAKE_HOST_OPTIONS += -DCMAKE_GENERATOR="Ninja"
+
+ define Host/Compile/Default
+ +$(NINJA) -C $(HOST_BUILD_DIR) $(1)
+ endef
+
+ define Host/Install/Default
+ +DESTDIR="$(HOST_INSTALL_DIR)" $(NINJA) -C $(HOST_BUILD_DIR) install
+ endef
+
+ define Host/Uninstall/Default
+ +DESTDIR="$(HOST_INSTALL_DIR)" $(NINJA) -C $(HOST_BUILD_DIR) uninstall
+ endef
+endif
+
+ifeq ($(PKG_USE_NINJA),1)
+ CMAKE_OPTIONS += -DCMAKE_GENERATOR="Ninja"
+
+ define Build/Compile/Default
+ +$(NINJA) -C $(CMAKE_BINARY_DIR) $(1)
+ endef
+
+ define Build/Install/Default
+ +DESTDIR="$(PKG_INSTALL_DIR)" $(NINJA) -C $(CMAKE_BINARY_DIR) install
+ endef
+endif
+
define Build/Configure/Default
mkdir -p $(CMAKE_BINARY_DIR)
(cd $(CMAKE_BINARY_DIR); \