mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 18:55:14 -07:00
Merge #9617
This commit is contained in:
commit
9bfd304459
@ -97,14 +97,22 @@ else()
|
||||
option(ENABLE_LTO "enable link time optimization" ON)
|
||||
endif()
|
||||
|
||||
# Set default build type.
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
message(STATUS "CMAKE_BUILD_TYPE not given, defaulting to 'Debug'")
|
||||
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build" FORCE)
|
||||
endif()
|
||||
message(STATUS "CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
# Build type.
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
message(STATUS "CMAKE_BUILD_TYPE not specified, default is 'Debug'")
|
||||
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build" FORCE)
|
||||
else()
|
||||
message(STATUS "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
|
||||
endif()
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
set(DEBUG 1)
|
||||
else()
|
||||
set(DEBUG 0)
|
||||
endif()
|
||||
# Set available build types for CMake GUIs.
|
||||
# A different build type can still be set by -DCMAKE_BUILD_TYPE=...
|
||||
# Other build types can still be set by -DCMAKE_BUILD_TYPE=...
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
|
||||
STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
|
||||
@ -138,12 +146,6 @@ set(NVIM_VERSION_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# Default to -O2 on release builds.
|
||||
if(CMAKE_C_FLAGS_RELEASE MATCHES "-O3")
|
||||
message(STATUS "Replacing -O3 in CMAKE_C_FLAGS_RELEASE with -O2")
|
||||
string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
|
||||
endif()
|
||||
|
||||
# Minimize logging for release-type builds.
|
||||
if(NOT CMAKE_C_FLAGS_RELEASE MATCHES DMIN_LOG_LEVEL)
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DMIN_LOG_LEVEL=3")
|
||||
@ -155,6 +157,22 @@ if(NOT CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DMIN_LOG_LEVEL)
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DMIN_LOG_LEVEL=3")
|
||||
endif()
|
||||
|
||||
# Log level (MIN_LOG_LEVEL in log.h)
|
||||
if("${MIN_LOG_LEVEL}" MATCHES "^$")
|
||||
message(STATUS "MIN_LOG_LEVEL not specified, default is 0 (DEBUG)")
|
||||
else()
|
||||
if(NOT MIN_LOG_LEVEL MATCHES "^[0-3]$")
|
||||
message(FATAL_ERROR "invalid MIN_LOG_LEVEL: " ${MIN_LOG_LEVEL})
|
||||
endif()
|
||||
message(STATUS "MIN_LOG_LEVEL=${MIN_LOG_LEVEL}")
|
||||
endif()
|
||||
|
||||
# Default to -O2 on release builds.
|
||||
if(CMAKE_C_FLAGS_RELEASE MATCHES "-O3")
|
||||
message(STATUS "Replacing -O3 in CMAKE_C_FLAGS_RELEASE with -O2")
|
||||
string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
check_c_compiler_flag(-Og HAS_OG_FLAG)
|
||||
else()
|
||||
@ -329,12 +347,6 @@ if(TRAVIS_CI_BUILD)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
set(DEBUG 1)
|
||||
else()
|
||||
set(DEBUG 0)
|
||||
endif()
|
||||
|
||||
option(LOG_LIST_ACTIONS "Add list actions logging" OFF)
|
||||
|
||||
add_definitions(-DINCLUDE_GENERATED_DECLARATIONS)
|
||||
@ -525,17 +537,9 @@ install_helper(
|
||||
FILES ${MANPAGES}
|
||||
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
|
||||
|
||||
# MIN_LOG_LEVEL for log.h
|
||||
if("${MIN_LOG_LEVEL}" MATCHES "^$")
|
||||
message(STATUS "MIN_LOG_LEVEL not specified")
|
||||
else()
|
||||
if(NOT MIN_LOG_LEVEL MATCHES "^[0-3]$")
|
||||
message(FATAL_ERROR "invalid MIN_LOG_LEVEL: " ${MIN_LOG_LEVEL})
|
||||
endif()
|
||||
message(STATUS "MIN_LOG_LEVEL set to ${MIN_LOG_LEVEL}")
|
||||
endif()
|
||||
|
||||
#
|
||||
# Go down the tree.
|
||||
#
|
||||
|
||||
add_subdirectory(src/nvim)
|
||||
# Read compilation flags from src/nvim, used in config subdirectory below.
|
||||
|
29
Makefile
29
Makefile
@ -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 $*
|
||||
|
||||
|
19
README.md
19
README.md
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user