build/Makefile: check CMAKE_INSTALL_PREFIX

closes #9615
This commit is contained in:
Justin M. Keyes 2019-02-16 00:23:51 +01:00
parent 4397bf5785
commit 05c6c6ae08
2 changed files with 30 additions and 18 deletions

View File

@ -7,13 +7,31 @@ filter-true = $(strip $(filter-out 1 on ON true TRUE,$1))
CMAKE_PRG ?= $(shell (command -v cmake3 || echo cmake))
CMAKE_BUILD_TYPE ?= Debug
CMAKE_FLAGS := -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)
# Extra CMake flags which extend the default set
CMAKE_EXTRA_FLAGS ?=
# CMAKE_INSTALL_PREFIX
# - May be passed directly or as part of CMAKE_EXTRA_FLAGS.
# - Fail if the given value does not match the CMake cached value. #9615
CACHED_PREFIX := $(shell $(CMAKE_PRG) -L -N build | 2>/dev/null \
grep 'CMAKE_INSTALL_PREFIX' | cut -d '=' -f2)
CMAKE_INSTALL_PREFIX ?= $(shell echo $(CMAKE_EXTRA_FLAGS) | 2>/dev/null \
grep -o 'CMAKE_INSTALL_PREFIX=[^ ]\+' | cut -d '=' -f2)
ifneq (,$(CMAKE_INSTALL_PREFIX))
ifneq (,$(CACHED_PREFIX))
ifneq ($(CMAKE_INSTALL_PREFIX),$(CACHED_PREFIX))
$(info error: CMAKE_INSTALL_PREFIX "$(CMAKE_INSTALL_PREFIX)" does not match cached value "$(CACHED_PREFIX)")
$(info . Run this command, then try again:)
$(info . cmake build -DCMAKE_INSTALL_PREFIX=$(CMAKE_INSTALL_PREFIX))
$(error error)
endif
endif
endif
BUILD_TYPE ?= $(shell (type ninja > /dev/null 2>&1 && echo "Ninja") || \
echo "Unix Makefiles")
DEPS_BUILD_DIR ?= .deps
ifneq (1,$(words [$(DEPS_BUILD_DIR)]))
$(error DEPS_BUILD_DIR must not contain whitespace)
endif
@ -41,8 +59,6 @@ endif
BUILD_CMD = $(BUILD_TOOL) $(VERBOSE_FLAG)
# Extra CMake flags which extend the default set
CMAKE_EXTRA_FLAGS ?=
DEPS_CMAKE_FLAGS ?=
# Back-compat: USE_BUNDLED_DEPS was the old name.
USE_BUNDLED ?= $(USE_BUNDLED_DEPS)
@ -153,8 +169,9 @@ generated-sources: build/.ran-cmake
appimage:
bash scripts/genappimage.sh
# Build an appimage with embedded update information appimage-nightly for
# nightly builds or appimage-latest for a release
# Build an appimage with embedded update information.
# appimage-nightly: for nightly builds
# appimage-latest: for a release
appimage-%:
bash scripts/genappimage.sh $*

View File

@ -57,12 +57,14 @@ and [more](https://github.com/neovim/neovim/wiki/Installing-Neovim)!
Install from source
-------------------
The build is CMake-based, but a Makefile is provided as a convenience.
make CMAKE_BUILD_TYPE=RelWithDebInfo
sudo make install
To install to a non-default location, set `CMAKE_INSTALL_PREFIX`:
To install to a non-default location:
make CMAKE_EXTRA_FLAGS="-DCMAKE_INSTALL_PREFIX=/full/path/"
make CMAKE_INSTALL_PREFIX=/full/path/
make install
To skip bundled (`third-party/*`) dependencies:
@ -80,17 +82,10 @@ To skip bundled (`third-party/*`) dependencies:
sudo make install
```
CMake features:
To inspect the build, these CMake features are useful:
- List all build targets:
```
cmake --build build --target help
```
- Print all variable definitions:
```
cmake -LAH
```
- `build/CMakeCache.txt` contains the resolved values of all CMake variables.
- `cmake --build build --target help` lists all build targets.
- `build/CMakeCache.txt` (or `cmake -LAH build/`) contains the resolved values of all CMake variables.
- `build/compile_commands.json` shows the full compiler invocations for each translation unit.
See the [Building Neovim](https://github.com/neovim/neovim/wiki/Building-Neovim) wiki page for details.