mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Add basic make
shim for CMake
This lets non-developers simply `cd` into the fish source directory and execute `make` to build the project. The Makefile searches for CMake and hands over the build to it if it is available, otherwise an error message is emitted. All dependency checking is left to CMake. Non-fish-devs shouldn't have to concern themselves with what build system fish developers have chosen, and building a random C++ project should not be a chore in familiarizing one's self with all the various build platforms out there. CMake is instructed to use `ninja` if it is available, otherwise the standard Unix Makefiles generator option is used. (This has already been the behavior on BSDs since CMake was adopted.)
This commit is contained in:
parent
d6a4694d9f
commit
20db22f0fe
1 changed files with 54 additions and 0 deletions
54
Makefile
Normal file
54
Makefile
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
# This is a very basic `make` wrapper around the CMake build toolchain.
|
||||||
|
#
|
||||||
|
# Supported arguments:
|
||||||
|
# PREFIX: sets the installation prefix
|
||||||
|
# GENERATOR: explicitly specifies the CMake generator to use
|
||||||
|
|
||||||
|
CMAKE ?= cmake
|
||||||
|
|
||||||
|
GENERATOR ?= $(shell (which ninja > /dev/null 2> /dev/null && echo Ninja) || \
|
||||||
|
echo 'Unix Makefiles')
|
||||||
|
prefix ?= /usr/local
|
||||||
|
PREFIX ?= $(prefix)
|
||||||
|
|
||||||
|
ifeq ($(GENERATOR), Ninja)
|
||||||
|
BUILDFILE = build.ninja
|
||||||
|
else
|
||||||
|
BUILDFILE = Makefile
|
||||||
|
endif
|
||||||
|
|
||||||
|
all: .begin build/fish
|
||||||
|
|
||||||
|
PHONY: .begin
|
||||||
|
.begin:
|
||||||
|
@which ninja > /dev/null 2> /dev/null || \
|
||||||
|
(echo 'Please install CMake and then re-run the `make` command!' 1>&2 && false)
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
build:
|
||||||
|
mkdir -p build
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
rm -rf build
|
||||||
|
|
||||||
|
.PHONY: test
|
||||||
|
test: build/fish
|
||||||
|
$(CMAKE) --build build --target test
|
||||||
|
|
||||||
|
.PHONY: install
|
||||||
|
install: build/fish
|
||||||
|
$(CMAKE) --build build --target install
|
||||||
|
|
||||||
|
.PHONY: run
|
||||||
|
run: build/fish
|
||||||
|
./build/fish || true
|
||||||
|
|
||||||
|
.PHONY: exec
|
||||||
|
exec: build/fish
|
||||||
|
exec ./build/fish
|
Loading…
Reference in a new issue