From f28952f838b7788a319bb414e95ba446fc878bbf Mon Sep 17 00:00:00 2001 From: Michal Sojka Date: Wed, 12 Sep 2018 20:23:43 +0200 Subject: [PATCH] Allow compiling all variants with ninja It is faster - see the comment in the Makefile. --- Makefile | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Makefile b/Makefile index b212a10..5134c8e 100644 --- a/Makefile +++ b/Makefile @@ -77,3 +77,37 @@ vot2016 $(TESTSEQ:%=vot2016/%): vot2016.zip .SECONDARY: vot2016.zip vot2016.zip: wget http://data.votchallenge.net/vot2016/vot2016.zip + +################### +# Ninja generator # +################### + +# Building all $(BUILDS) with make is slow, even when run with in +# parallel (make -j). The target below generates build.ninja file that +# compiles all variants in the same ways as this makefile, but faster. +# The down side is that the build needs about 10 GB of memory. + +ninja: build.ninja + ninja + +# Ninja generator - to have faster parallel builds +.PHONY: build.ninja +build.ninja: + $(file >$@,$(ninja-rule)) + $(foreach build,$(BUILDS),$(file >>$@,$(call ninja-build,$(build),$(CMAKE_OTPS_$(build))))) + +define ninja-rule +rule cmake + command = cd $$$$(dirname $$out) && cmake $(CMAKE_OPTS) $$opts .. + description = CMake $$out +rule ninja + # Absolute path in -C allows Emacs to properly jump to error message locations + command = ninja -C `realpath $$$$(dirname $$out)` + description = Ninja $$out +endef + +define ninja-build +build build-$(1)/build.ninja: cmake + opts = $(2) +build build-$(1)/kcf_vot: ninja build-$(1)/build.ninja build.ninja +endef -- 2.39.2