From abc2468c70c2026c59dde19380e3a0bca8a2bccf Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Wed, 18 Dec 2019 21:28:56 -0600 Subject: [PATCH] Add alternate patch to support in-tree CMake Makefile builds This patch keeps the existing `make` shims via `GNUmakefile` and `BSDmakefile` but also resolves the issue reported in #6264 with CMake-generated `Makefile` overwriting the extant `Makefile` causing the source directory to become dirty once again. Closes #6264 --- Makefile => GNUmakefile | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) rename Makefile => GNUmakefile (72%) diff --git a/Makefile b/GNUmakefile similarity index 72% rename from Makefile rename to GNUmakefile index dedfec76c..246b2940e 100644 --- a/Makefile +++ b/GNUmakefile @@ -17,6 +17,16 @@ else BUILDFILE = Makefile endif + +# If CMake has generated an in-tree Makefile, use that instead (issue #6264) +MAKE_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) +ifeq ($(shell test -f $(MAKE_DIR)/Makefile && echo 1), 1) + +all: + @+$(MAKE) -f $(MAKE_DIR)/Makefile $(MAKECMDGOALS) --no-print-directory + +else + all: .begin build/fish PHONY: .begin @@ -28,7 +38,8 @@ build/fish: build/$(BUILDFILE) $(CMAKE) --build build build/$(BUILDFILE): build - cd build; $(CMAKE) .. -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -G "$(GENERATOR)" -DCMAKE_INSTALL_PREFIX="$(PREFIX)" -DCMAKE_EXPORT_COMPILE_COMMANDS=1 + cd build; $(CMAKE) .. -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -G "$(GENERATOR)" \ + -DCMAKE_INSTALL_PREFIX="$(PREFIX)" -DCMAKE_EXPORT_COMPILE_COMMANDS=1 build: mkdir -p build @@ -52,3 +63,5 @@ run: build/fish .PHONY: exec exec: build/fish exec ./build/fish + +endif # CMake in-tree build check