#!/usr/bin/make -f include /usr/share/dpkg/pkg-info.mk # Do not build with link-time optimization, cf. https://bugs.debian.org/1034873 export DEB_BUILD_MAINT_OPTIONS := optimize=-lto export DEB_CXXFLAGS_MAINT_APPEND := $(shell dpkg-buildflags --get CPPFLAGS) export DEB_CFLAGS_MAINT_APPEND := $(shell dpkg-buildflags --get CPPFLAGS) export DEB_LDFLAGS_MAINT_APPEND := -Wl,--as-needed BUILD_DATE = $(shell LC_ALL=C date -u "+%B %d, %Y" -d "@$(SOURCE_DATE_EPOCH)") BUILD_FLAGS_FILE = build-flags.cmake set_build_flag = echo 'set($(1) $(2) CACHE \ $(if $(filter $(2),YES ON TRUE NO OFF FALSE),BOOL,STRING) \ $(or $(3),"") FORCE)' >> $(BUILD_FLAGS_FILE) verify_build_flag = @grep \ --include=CMakeLists.txt --include=*.cmake \ --exclude=$(BUILD_FLAGS_FILE) -rqs '\b$(1)\b' . || echo '$(1) flag is obsolete' $(BUILD_FLAGS_FILE) verify-build-flags: $(call $(flag_action),CMAKE_SKIP_RPATH,ON,"Skip rpath") $(call $(flag_action),CMAKE_USE_RELATIVE_PATHS,ON,"Use relative paths") $(call $(flag_action),CMAKE_VERBOSE_MAKEFILE,ON,"Verbose build") $(call $(flag_action),CMAKE_C_FLAGS,"$(CFLAGS)","C flags") $(call $(flag_action),CMAKE_CXX_FLAGS,"$(CXXFLAGS)","C++ flags") $(call $(flag_action),CMAKE_SKIP_BOOTSTRAP_TEST,ON,"Skip BootstrapTest") ifeq (,$(filter pkg.cmake.bootstrap pkg.cmake.nogui,$(DEB_BUILD_PROFILES))) $(call $(flag_action),BUILD_CursesDialog,ON,"Build curses GUI") $(call $(flag_action),BUILD_QtDialog,ON,"Build Qt GUI") endif ifeq ($(DEB_HOST_ARCH_OS),hurd) $(call $(flag_action),CMAKE_USE_LIBUV,0,"Do not use libuv") endif # $(call $(flag_action),BUILD_DOCUMENTATION,ON) $(BUILD_FLAGS_FILE): flag_action := set_build_flag verify-build-flags: flag_action := verify_build_flag .PHONY: verify-build-flags BOOTSTRAP_FLAGS = --prefix=/usr --docdir=/share/doc/cmake-data --mandir=/share/man \ --sphinx-man --sphinx-html --sphinx-flags="-D today=\"$(BUILD_DATE)\"" \ --init=../$(BUILD_FLAGS_FILE) --verbose CROSS_CMAKE_FLAGS = -C../$(BUILD_FLAGS_FILE) \ -DCMAKE_DOC_DIR=share/doc/cmake-data \ -DCMAKE_MAN_DIR=share/man \ -DSPHINX_HTML=ON -DSPHINX_MAN=ON \ -DSPHINX_FLAGS="-D today=\"$(BUILD_DATE)\"" ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) NUMJOBS = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) BOOTSTRAP_FLAGS += --parallel=$(NUMJOBS) else NUMJOBS = 1 endif ifeq (,$(filter pkg.cmake.bootstrap,$(DEB_BUILD_PROFILES))) BOOTSTRAP_FLAGS += --system-libs CROSS_CMAKE_FLAGS += -DCMAKE_USE_SYSTEM_LIBRARIES=ON endif override_dh_auto_configure: $(BUILD_FLAGS_FILE) ifeq (,$(filter cross,$(DEB_BUILD_PROFILES))) rm -rf Build && mkdir -p Build cd Build && ../bootstrap $(BOOTSTRAP_FLAGS) else dh_auto_configure --buildsystem=cmake --builddirectory=Build -- \ $(CROSS_CMAKE_FLAGS) endif ifeq ($(DEB_HOST_ARCH_OS),kfreebsd) # Workaround for Bug #815231: skip spuriously failing tests EXCLUDED_TESTS = CTestTestUpload\|curl\|kwsys.testSystemTools\|BuildDepends\|RunCMake.Configure else EXCLUDED_TESTS = CTestTestUpload\|curl endif override_dh_auto_test: # Pass -j1 to "make test" as a workaround, see https://gitlab.kitware.com/cmake/cmake/issues/17165 # The tests are still run in parallel as -jX is passed via ARGS to ctest. dh_auto_test --buildsystem=cmake -- -j1 ARGS="-E $(EXCLUDED_TESTS) --timeout 5000 -j$(NUMJOBS)" execute_after_dh_auto_clean: rm -f $(BUILD_FLAGS_FILE) override_dh_installdocs-arch: # dh_installdocs --link-doc generates binNMU unsafe deps (Bug #747141) dh_installdocs override_dh_installdocs-indep: dh_installdocs --link-doc=cmake-data override_dh_sphinxdoc: dh_sphinxdoc -pcmake-doc %: dh $@ --builddirectory=Build