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
This commit is contained in:
Mahmoud Al-Qudsi 2019-12-18 21:28:56 -06:00
parent aeaf2f93e2
commit abc2468c70

View File

@ -17,6 +17,16 @@ else
BUILDFILE = Makefile BUILDFILE = Makefile
endif 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 all: .begin build/fish
PHONY: .begin PHONY: .begin
@ -28,7 +38,8 @@ build/fish: build/$(BUILDFILE)
$(CMAKE) --build build $(CMAKE) --build build
build/$(BUILDFILE): 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: build:
mkdir -p build mkdir -p build
@ -52,3 +63,5 @@ run: build/fish
.PHONY: exec .PHONY: exec
exec: build/fish exec: build/fish
exec ./build/fish exec ./build/fish
endif # CMake in-tree build check