neovim/CMakeLists.txt

679 lines
23 KiB
CMake
Raw Normal View History

# CMAKE REFERENCE
# intro: https://codingnest.com/basic-cmake/
# best practices (3.0+): https://gist.github.com/mbinna/c61dbb39bca0e4fb7d1f73b0d66a4fd1
# Version should match the tested CMAKE_URL in .travis.yml.
cmake_minimum_required(VERSION 2.8.12)
project(nvim C)
if(POLICY CMP0065)
cmake_policy(SET CMP0065 NEW)
endif()
if(POLICY CMP0060)
cmake_policy(SET CMP0060 NEW)
endif()
2014-02-24 13:54:45 -07:00
# Point CMake at any custom modules we may ship
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
2014-02-24 13:54:45 -07:00
# We don't support building in-tree.
include(PreventInTreeBuilds)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Prefer our bundled versions of dependencies.
if(DEFINED ENV{DEPS_BUILD_DIR})
set(DEPS_PREFIX "$ENV{DEPS_BUILD_DIR}/usr" CACHE PATH "Path prefix for finding dependencies")
else()
set(DEPS_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/.deps/usr" CACHE PATH "Path prefix for finding dependencies")
# When running from within CLion or Visual Studio,
# build bundled dependencies automatically.
if(NOT EXISTS ${DEPS_PREFIX}
AND (DEFINED ENV{CLION_IDE}
OR DEFINED ENV{VisualStudioEdition}))
message(STATUS "Building dependencies...")
set(DEPS_BUILD_DIR ${PROJECT_BINARY_DIR}/.deps)
file(MAKE_DIRECTORY ${DEPS_BUILD_DIR})
execute_process(
COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}
-DCMAKE_C_FLAGS_MINSIZEREL=${CMAKE_C_FLAGS_MINSIZEREL}
-DCMAKE_C_FLAGS_RELWITHDEBINFO=${CMAKE_C_FLAGS_RELWITHDEBINFO}
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
${PROJECT_SOURCE_DIR}/third-party
WORKING_DIRECTORY ${DEPS_BUILD_DIR})
execute_process(
COMMAND ${CMAKE_COMMAND} --build ${DEPS_BUILD_DIR}
--config ${CMAKE_BUILD_TYPE})
set(DEPS_PREFIX ${DEPS_BUILD_DIR}/usr)
endif()
endif()
if(CMAKE_CROSSCOMPILING AND NOT UNIX)
list(INSERT CMAKE_FIND_ROOT_PATH 0 ${DEPS_PREFIX})
list(INSERT CMAKE_PREFIX_PATH 0 ${DEPS_PREFIX}/../host/bin)
else()
list(INSERT CMAKE_PREFIX_PATH 0 ${DEPS_PREFIX})
set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${DEPS_PREFIX}/lib/pkgconfig")
endif()
# used for check_c_compiler_flag
include(CheckCCompilerFlag)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# CMake tries to treat /sw and /opt/local as extension of the system path, but
# that doesn't really work out very well. Once you have a dependency that
# resides there and have to add it as an include directory, then any other
# dependency that could be satisfied from there must be--otherwise you can end
# up with conflicting versions. So, let's make them more of a priority having
# them be included as one of the first places to look for dependencies.
list(APPEND CMAKE_PREFIX_PATH /sw /opt/local)
# Work around some old, broken detection by CMake for knowing when to use the
# isystem flag. Apple's compilers have supported this for quite some time
# now.
if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem ")
endif()
2017-01-17 08:32:41 -07:00
endif()
2017-01-17 08:32:41 -07:00
if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# Enable fixing case-insensitive filenames for Windows and Mac.
set(USE_FNAME_CASE TRUE)
endif()
option(ENABLE_LIBINTL "enable libintl" ON)
option(ENABLE_LIBICONV "enable libiconv" ON)
if (MINGW)
# Disable LTO by default as it may not compile
# See https://github.com/Alexpux/MINGW-packages/issues/3516
# and https://github.com/neovim/neovim/pull/8654#issuecomment-402316672
option(ENABLE_LTO "enable link time optimization" OFF)
else()
option(ENABLE_LTO "enable link time optimization" ON)
endif()
message(STATUS "CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}")
# Build type.
2014-11-09 05:52:15 -07:00
if(NOT CMAKE_BUILD_TYPE)
message(STATUS "CMAKE_BUILD_TYPE not specified, default is 'Debug'")
2018-10-06 09:45:34 -07:00
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)
2014-11-09 05:52:15 -07:00
endif()
# Set available build types for CMake GUIs.
# Other build types can still be set by -DCMAKE_BUILD_TYPE=...
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
# If not in a git repo (e.g., a tarball) these tokens define the complete
# version string, else they are combined with the result of `git describe`.
set(NVIM_VERSION_MAJOR 0)
2019-09-15 16:19:49 -07:00
set(NVIM_VERSION_MINOR 5)
2018-12-30 16:44:49 -07:00
set(NVIM_VERSION_PATCH 0)
2019-09-15 16:19:49 -07:00
set(NVIM_VERSION_PRERELEASE "-dev") # for package maintainers
# API level
2018-12-31 04:54:57 -07:00
set(NVIM_API_LEVEL 6) # Bump this after any API change.
set(NVIM_API_LEVEL_COMPAT 0) # Adjust this after a _breaking_ API change.
NVIM v0.4.0 This release represents ~2700 commits since v0.3.4, the previous non-maintenance release. Besides the highlights listed below, this release features vast improvements to documentation, internal subsystems and test/CI infrastructure, and 700+ patches merged from Vim. FEATURES: New API functions: nvim_create_buf: create various kinds of buffers nvim_get_context, nvim_load_context 8e6b0a73c91b #10619 API: Context: save/restore/inspect editor state nvim_input_mouse: perform mouse actions nvim_open_win: create floating windows (and external, for supporting UIs) nvim_paste: paste text at cursor nvim_put: put text at cursor nvim_select_popupmenu_item: perform popupmenu actions nvim_set_keymap: create/delete mappings nvim_set_vvar: set v: variables nvim_ui_pum_set_height nvim_ui_try_resize_grid nvim_win_close: close windows nvim_win_get_config: get window configuration nvim_win_set_config: reconfigure windows New UI events: redraw.grid_destroy redraw.hl_group_set 8a3f8589a3ed #10504 UI/highlight: expose builtin highlight groups using hl_group_set event redraw.msg_clear redraw.msg_history_show redraw.msg_ruler redraw.msg_set_pos redraw.msg_show redraw.msg_showcmd redraw.msg_showmode redraw.win_close redraw.win_external_pos redraw.win_float_pos redraw.win_hide redraw.win_pos API f5c56f03bb9e #9170 API/Lua: nvim_buf_attach: support Lua callback 82d48c0dab0f #9896 API: emit nvim_error_event on failed async request b9ad12e6c2fa #9992 UI/nvim_ui_attach(): add `override` option 3d1ed7c95901 #9993 UI/ext_messages: learn more message kinds 8ed54bbec3b0 #9547 proper multiline error message for rpcrequest, API wrappers Lua This release introduces "Nvim-Lua standard library". See ":help lua-stdlib". 89d7e24891c2 #9463 Lua stdlib: vim.inspect, string functions 8e941c59ec23 #9740 Lua: generate documentation from docstrings 1cbe0145695b #9301 lua/stdlib: Introduce vim.shared c83926cd0aa5 #10123 Lua: introduce vim.loop (expose libuv event-loop) 81e1dbca99c1 #10120 Lua: vim.schedule(cb) 1f54f68732b4 #10688 Lua: minimal UTF-16 support needed for LSP 6fb0020df4eb #10513 Lua encoding support c0993ed3433e Lua: support getting UTF-32 and UTF-16 sizes of replaced text b0e26199ec02 Lua: add {old_byte_size} to on_lines buffer change event UI: - The Nvim 0.3.4 UI protocol introduced line-based updates instead of legacy char-based updates. Nvim 0.4 continues to evolve the UI protocol. See ":help ui". Legacy UI clients are supported. See ":help api-contract". 9a1675b06539 #6619 Floating windows - Can be (re)positioned, anchored, external. - Are real windows showing real buffers. No shortcuts, hacks, or compromises. - Support all features and API of normal windows, plus more. 6427894d8911 #8455 Multigrid: "windows drawn on separate grids" - Windows are logically isolated internally. - Windows are sent to UIs as distinct objects, so that UIs can control layout instead of being stuck with the classic TUI layout. - Per-window font-size, dimenions, line-spacing. - Compositor: Internal subsystem for composing grids. 3855204f5860 #6917 UIEnter, UILeave 788bcbba2465 #9923 ui: ":syn blend=", 'winblend' 7cf7c0a0b8e9 #9575 ui: 'redrawdebug' option for flexible debugging of redrawing 5c836d2ef8b6 #9607 wildoptions=pum (enabled by default) 37f8df882463 #9571 UI: 'pumblend' option for semi-transparent popupmenu c403a95a5297 #9446 Visual: highlight char-at-cursor - Traditionally Vim's visual selection does "reverse mode", which perhaps conflicts with the non-blinking block cursor. But 'guicursor' defaults to a vertical bar for selection=exclusive, and this confuses users who expect to see the text highlighted. :terminal fc27dc98d74f #8550 autocmds: TermEnter, TermLeave d13803f64fc5 #9810 keymap, terminal: more keycodes 3b56f59532ac #9535 :terminal : Fix F1-F4 key codes 2d4a37ebab35 #10370 :ls : show "R", "F" for terminal-jobs fd0fd752c872 #9966 terminal: swap priority of terminal, editor highlights 7bb858c39cac #9494 libvterm 0.1 TUI 3afb397407af syntax, TUI: support "strikethrough" ccbcd390d42d #9408 TUI: "title stacking" unconditionally 298608f88c46 #9509 TUI: detect background color, set bg=dark/light 42f492ac9905 #9097 TUI: handle Smulx extension capability (extended underline) 424ddd01f588 #10205 TUI: support rgba background detection 9b4383261a3d #9601 TUI: italics in tmux, Terminal.app f6fb370b1bcc #9793 keymap: support more (keypad) keycodes 3340e08becbf #9423 TUI: Konsole DECSCUSR fixup :checkhealth d0fd66ba82c4 health/provider.vim: check curl HTTPS support c38862aceabe #10490 checkhealth: try yarn if npm is missing 43356a43d00f #9929 health: check if tmux enabled true colors ec5a4d862d71 #9548 checkhealth: validate locale providers (clipboard, python, etc.): 96be8a2c4d63 #10161 Allow reloading providers (useful for UIs/clients) db3c797c6b3c #9487 provider: improve error message if provider is missing Various: 36762a00a801 #9295 signs: support multiple columns 801fe799ff35 #10382 eval: wait() (wait for any condition) 9df3a676e7f2 #10400 MsgArea highlight; message grid a9bea8c1047f #10790 keymap: allow modifiers to multibyte chars, like <m-ä> 25e0a449bb66 #10878 #4448 paste: redesign (10x+ faster pasting; extensible vim.paste Lua hook) ef5037e7f6e1 #9706 autocmd: introduce "++once" feature 175398f21645 #9616 add CompleteChanged autocmd 7fcf2f926fc6 #9717 TextYankPost: add v:event["inclusive"] 3a699a790c14 #8364 termdebug.vim plugin ca1ce590257c #9709 performance: use os_copy to create backups ed0e96cd28f8 man.vim: set 'linebreak' 70f6939fd4b5 #9564 events: add "Signal" event f89d0d8230f3 #9568 inccommand: auto-disable if folding is slow FIXES: 41bb68b8e8d0 #10584 process_stop: uv: do not close stdin first/explicitly e50aa2a6c654 #10117 normal: Don't exit CTRL-O mode after processing K_EVENT 95fa71c6d2b4 #9504 :recover : Fix crash on non-existent *.swp 5a836d4767b7 #9507 screen: don't unconditionally clear messages on window scroll 149dcbf2c762 #10021 channel: refactor events, prevent recursive invocation of events d19ff73b39a9 #10107 Fix multiple c_CTRL-D showing statusline b65a7b7f6692 #10103 Fix wildmode=list,full and display+=msgsep interaction 0be6d3c86fe5 #9634 fsync: Ignore ENOTSUP. Fix writing to SMB. b247c6fd2255 #10025 kbtree: pointer UB and unitialized value fixes 018e0d5a19c3 #9643 API/buffer-updates: always detach on buf-reload 400ee59247ea #9961 API: fix cursor position when lines are added 769f44e918c6 #9911 win/defaults: Use "…/nvim-data/site" in 'runtimepath' 83d571653bdc #9911 spellfile.vim: store files in stdpath('data') 8dbf23181add #9887 RPC: conform message-id type to msgpack-RPC spec 5f996e36d102 #9894 options: properly reset directories on 'autochdir' 4c4a57015687 #9807 various CursorMoved fixes 943bedfc86ab #9853 event-loop: do not set CA_COMMAND_BUSY 9d207fd87617 #9693 dictwatcheradd(): support b:changedtick 2d50bf349883 #9789 mac: fix locale detection c5631338b16b #9754 :mksession : restore tab-local working directories 092e7e6c6058 #9703 #9703 executable(): return false if user is not owner 11a481f711ee #9686 env var fixes/improvements 8e54847fdf3c #9666 #7920 os/env: Fix completion of multibyte env var names 519382646be3 #10468 Fix is_executable_in_path() on Windows 8eaa452073a1 #9516 win: exepath(), executable() fixes f55c1e4233a4 #10544 reltimefloat(): allow negative result b08dc3ec195f #10561 win: jobstart(), system(): $PATHEXT-resolve exe 7cc2b723d43c #10392 TextYankPost: spurious/too-early dispatch during delete 6e01ed6a4c85 OpenBSD: stop jobs/processes properly 58dd5fcc01ed #10522 jobstop(): close channel before process_stop() 83632022f84e #10959 improved resize behavior (all UIs) c6eb1f42bec0 #10830 API: fix nvim_command_output buffer overflow cbfd18c85acd #10763 startup: handle 'guicursor' after user config b8f2436febcc #10915 jobwait(): fix race if job exits quickly 2fafed6bb8aa #10765 clipboard: handle/avoid SIGTERM with previous owner 8aca932aa0ac #9954 clipboard: setreg("*") with clipboard=unnamed 3f10c5b5338f #9480 performance: clipboard/macOS: assume that pbcopy works 48efafc81c84 #10398 screen: disable redrawing inside VimResized 5e4b93a38f1e #10389 API/Lua: make nvim_execute_lua use native lua floats, not special tables 8c6f5b7f9268 #9934 Spurious quote mark in command line when typing <C-R> a8a38f346548 Lua 5.2/5.3 compat :terminal 47b7b471fa0f #10700 :terminal : update buffer when switching tabpage 5225c1ec302f #9605 terminal: Fix potential invalid local 'scrollback' 894f6bee54e8 #8325 :terminal : set topline based on window height 8171e96b9640 #9551 Improve :terminal resize d928b036dc2b #9856 :stopinsert should leave terminal-mode 3f712185058f #9926 :terminal : fix: Using `:stopinsert` while in normal mode 5020daa6e5ce #9883 ui/terminal: make terminal state redraw like any other state TUI: 9f19e8d29dce #9443 TUI: Do not disable BCE for builtin terminfos a4076e5dcf66 #9474 win/TUI: fix text overrides line numbers 533d4a36ec03 #9645 TUI: do not resize host-terminal on startup b51e5d8b8dd2 #9688 tui_tk_ti_getstr: handle weird value 1f5eac1115a4 #10785 TUI: fix data-race during resize CHANGES: 9697c7f56a26 #8194 fix menu_get() 7f2e43c637e5 #9520 improve Lua error messages c2343180d74f #9526 Remove jemalloc baf93d96063c #9581 UI: always use concrete colors for default_colors_set 91688b488310 #9563 defaults: set 'scrollback' to -1 by default bb24fec33355 #10136 defaults: exclude "S" from 'shortmess' ddd0eb6f5120 #8540 startup: -es/-Es (silent/batch mode): skip swapfile 35362495c965 #9805 jumplist: avoid extra tail entry 939d9053bdf2 #10573 channels: reflect exit due to signals in exit status code 45c34bd84aa5 #10689 :doautocmd : Never show "No matching autocommands" fb19aeeb33f7 #9110 API: make nvim_win_set_option() set window-global, not buffer-local abfc8b3257f8 #10778 emsg_multiline: log Vim errors 06d9cc734bf0 #10657 exists("$FOO"): return false for empty env var 6616d1d3e5c9 #10743 win/env: Vim-compat: Empty string deletes env var 7d664837e1a9 #10662 win: expand nested env var in $HOME 2816bc8620ca #8349 edit.c: Disable indent during completion 58f505dc7432 #9829 startup: remove TUI init special-case Historically Vim/Nvim does backflips to handle input and show messages before a UI is available. This logical contradiction was already fixed for remote UIs (#9024 c236e80cf3df). Fixing it also for the TUI avoids problems on Windows, simplifies the logic, and avoids races like #9959.
2019-09-15 12:38:40 -07:00
set(NVIM_API_PRERELEASE false)
2014-11-09 05:52:15 -07:00
set(NVIM_VERSION_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
# NVIM_VERSION_CFLAGS set further below.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# 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")
endif()
if(NOT CMAKE_C_FLAGS_MINSIZEREL MATCHES DMIN_LOG_LEVEL)
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DMIN_LOG_LEVEL=3")
endif()
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 1 (INFO)")
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()
set(HAS_OG_FLAG 0)
endif()
#
# Build-type: RelWithDebInfo
#
if(HAS_OG_FLAG)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -Og -g")
endif()
# We _want_ assertions in RelWithDebInfo build-type.
if(CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DNDEBUG)
string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
endif()
# gcc 4.0+ sets _FORTIFY_SOURCE=2 automatically. This currently
# does not work with Neovim due to some uses of dynamically-sized structures.
# https://github.com/neovim/neovim/issues/223
include(CheckCSourceCompiles)
# Include the build type's default flags in the check for _FORTIFY_SOURCE,
# otherwise we may incorrectly identify the level as acceptable and find out
# later that it was not when optimizations were enabled. CFLAGS is applied
# even though you don't see it in CMAKE_REQUIRED_FLAGS.
set(INIT_FLAGS_NAME CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE})
string(TOUPPER ${INIT_FLAGS_NAME} INIT_FLAGS_NAME)
if(${INIT_FLAGS_NAME})
set(CMAKE_REQUIRED_FLAGS "${${INIT_FLAGS_NAME}}")
endif()
# Include <string.h> because some toolchains define _FORTIFY_SOURCE=2 in
# internal header files, which should in turn be #included by <string.h>.
check_c_source_compiles("
#include <string.h>
#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 1
#error \"_FORTIFY_SOURCE > 1\"
#endif
int
main(void)
{
return 0;
}
" HAS_ACCEPTABLE_FORTIFY)
if(NOT HAS_ACCEPTABLE_FORTIFY)
2018-10-06 09:45:34 -07:00
message(STATUS "Unsupported _FORTIFY_SOURCE found, forcing _FORTIFY_SOURCE=1")
# Extract possible prefix to _FORTIFY_SOURCE (e.g. -Wp,-D_FORTIFY_SOURCE).
STRING(REGEX MATCH "[^\ ]+-D_FORTIFY_SOURCE" _FORTIFY_SOURCE_PREFIX "${CMAKE_C_FLAGS}")
STRING(REPLACE "-D_FORTIFY_SOURCE" "" _FORTIFY_SOURCE_PREFIX "${_FORTIFY_SOURCE_PREFIX}" )
if(NOT _FORTIFY_SOURCE_PREFIX STREQUAL "")
2018-10-06 09:45:34 -07:00
message(STATUS "Detected _FORTIFY_SOURCE Prefix=${_FORTIFY_SOURCE_PREFIX}")
endif()
# -U in add_definitions doesn't end up in the correct spot, so we add it to
# the flags variable instead.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FORTIFY_SOURCE_PREFIX}-U_FORTIFY_SOURCE ${_FORTIFY_SOURCE_PREFIX}-D_FORTIFY_SOURCE=1")
endif()
# Remove --sort-common from linker flags, as this seems to cause bugs (see #2641, #3374).
# TODO: Figure out the root cause.
if(CMAKE_EXE_LINKER_FLAGS MATCHES "--sort-common" OR
CMAKE_SHARED_LINKER_FLAGS MATCHES "--sort-common" OR
CMAKE_MODULE_LINKER_FLAGS MATCHES "--sort-common")
2018-10-06 09:45:34 -07:00
message(STATUS "Removing --sort-common from linker flags")
string(REGEX REPLACE ",--sort-common(=[^,]+)?" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
string(REGEX REPLACE ",--sort-common(=[^,]+)?" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
string(REGEX REPLACE ",--sort-common(=[^,]+)?" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}")
# If no linker flags remain for a -Wl argument, remove it.
# '-Wl$' will match LDFLAGS="-Wl,--sort-common",
# '-Wl ' will match LDFLAGS="-Wl,--sort-common -Wl,..."
string(REGEX REPLACE "-Wl($| )" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
string(REGEX REPLACE "-Wl($| )" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
string(REGEX REPLACE "-Wl($| )" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}")
endif()
check_c_source_compiles("
#include <execinfo.h>
int main(void)
{
void *trace[1];
backtrace(trace, 1);
return 0;
}
" HAVE_EXECINFO_BACKTRACE)
check_c_source_compiles("
int main(void)
{
int a = 42;
__builtin_add_overflow(a, a, &a);
__builtin_sub_overflow(a, a, &a);
return 0;
}
" HAVE_BUILTIN_ADD_OVERFLOW)
if(MSVC)
# XXX: /W4 gives too many warnings. #3241
add_compile_options(/W3)
add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-DWIN32)
else()
add_compile_options(-Wall -Wextra -pedantic -Wno-unused-parameter
-Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion
-Wmissing-prototypes)
check_c_compiler_flag(-Wimplicit-fallthrough HAS_WIMPLICIT_FALLTHROUGH_FLAG)
if(HAS_WIMPLICIT_FALLTHROUGH_FLAG)
add_compile_options(-Wimplicit-fallthrough)
endif()
# On FreeBSD 64 math.h uses unguarded C11 extension, which taints clang
# 3.4.1 used there.
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" AND CMAKE_C_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-c11-extensions)
endif()
endif()
if(MINGW)
# Use POSIX compatible stdio in Mingw
add_definitions(-D__USE_MINGW_ANSI_STDIO)
endif()
if(WIN32)
# Windows Vista is the minimum supported version
add_definitions(-D_WIN32_WINNT=0x0600)
endif()
# OpenBSD's GCC (4.2.1) doesn't have -Wvla
check_c_compiler_flag(-Wvla HAS_WVLA_FLAG)
if(HAS_WVLA_FLAG)
add_compile_options(-Wvla)
endif()
if(UNIX)
# -fstack-protector breaks non Unix builds even in Mingw-w64
check_c_compiler_flag(-fstack-protector-strong HAS_FSTACK_PROTECTOR_STRONG_FLAG)
check_c_compiler_flag(-fstack-protector HAS_FSTACK_PROTECTOR_FLAG)
if(HAS_FSTACK_PROTECTOR_STRONG_FLAG)
add_compile_options(-fstack-protector-strong)
elseif(HAS_FSTACK_PROTECTOR_FLAG)
add_compile_options(-fstack-protector --param ssp-buffer-size=4)
endif()
endif()
check_c_compiler_flag(-fdiagnostics-color=auto HAS_DIAG_COLOR_FLAG)
if(HAS_DIAG_COLOR_FLAG)
if(CMAKE_GENERATOR MATCHES "Ninja")
add_compile_options(-fdiagnostics-color=always)
else()
add_compile_options(-fdiagnostics-color=auto)
endif()
endif()
option(TRAVIS_CI_BUILD "Travis/sourcehut CI, extra flags will be set" OFF)
if(TRAVIS_CI_BUILD)
message(STATUS "Travis/sourcehut CI build enabled")
add_compile_options(-Werror)
if(DEFINED ENV{BUILD_32BIT})
# Get some test coverage for unsigned char
add_compile_options(-funsigned-char)
endif()
endif()
option(LOG_LIST_ACTIONS "Add list actions logging" OFF)
add_definitions(-DINCLUDE_GENERATED_DECLARATIONS)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
set(NO_UNDEFINED "-Wl,--no-undefined -lsocket")
elseif(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(NO_UNDEFINED "-Wl,--no-undefined")
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${NO_UNDEFINED}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${NO_UNDEFINED}")
# For O_CLOEXEC, O_DIRECTORY, and O_NOFOLLOW flags on older systems
# (pre POSIX.1-2008: glibc 2.11 and earlier). #4042
# For ptsname(). #6743
add_definitions(-D_GNU_SOURCE)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SIZEOF_VOID_P EQUAL 8)
# Required for luajit.
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} -pagezero_size 10000 -image_base 100000000")
set(CMAKE_SHARED_LINKER_FLAGS
"${CMAKE_SHARED_LINKER_FLAGS} -image_base 100000000")
set(CMAKE_MODULE_LINKER_FLAGS
"${CMAKE_MODULE_LINKER_FLAGS} -image_base 100000000")
endif()
include_directories("${PROJECT_BINARY_DIR}/config")
include_directories("${PROJECT_SOURCE_DIR}/src")
find_package(LibUV 1.28.0 REQUIRED)
include_directories(SYSTEM ${LIBUV_INCLUDE_DIRS})
find_package(Msgpack 1.0.0 REQUIRED)
include_directories(SYSTEM ${MSGPACK_INCLUDE_DIRS})
2014-04-10 11:39:34 -07:00
find_package(LibLUV 1.30.0 REQUIRED)
include_directories(SYSTEM ${LIBLUV_INCLUDE_DIRS})
find_package(UTF8PROC REQUIRED)
include_directories(SYSTEM ${UTF8PROC_INCLUDE_DIRS})
if(WIN32)
add_definitions(-DUTF8PROC_STATIC)
endif()
# Note: The test lib requires LuaJIT; it will be skipped if LuaJIT is missing.
option(PREFER_LUA "Prefer Lua over LuaJIT in the nvim executable." OFF)
if(PREFER_LUA)
find_package(Lua 5.1 REQUIRED)
set(LUA_PREFERRED_INCLUDE_DIRS ${LUA_INCLUDE_DIR})
set(LUA_PREFERRED_LIBRARIES ${LUA_LIBRARIES})
# Passive (not REQUIRED): if LUAJIT_FOUND is not set, nvim-test is skipped.
find_package(LuaJit)
else()
find_package(LuaJit REQUIRED)
set(LUA_PREFERRED_INCLUDE_DIRS ${LUAJIT_INCLUDE_DIRS})
set(LUA_PREFERRED_LIBRARIES ${LUAJIT_LIBRARIES})
endif()
list(APPEND CMAKE_REQUIRED_INCLUDES "${MSGPACK_INCLUDE_DIRS}")
check_c_source_compiles("
#include <msgpack.h>
int
main(void)
{
return MSGPACK_OBJECT_FLOAT32;
}
" MSGPACK_HAS_FLOAT32)
list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES "${MSGPACK_INCLUDE_DIRS}")
if(MSGPACK_HAS_FLOAT32)
add_definitions(-DNVIM_MSGPACK_HAS_FLOAT32)
endif()
option(FEAT_TUI "Enable the Terminal UI" ON)
if(FEAT_TUI)
find_package(UNIBILIUM 2.0 REQUIRED)
include_directories(SYSTEM ${UNIBILIUM_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_INCLUDES "${UNIBILIUM_INCLUDE_DIRS}")
list(APPEND CMAKE_REQUIRED_LIBRARIES "${UNIBILIUM_LIBRARIES}")
check_c_source_compiles("
#include <unibilium.h>
int
main(void)
{
return unibi_num_from_var(unibi_var_from_num(0));
}
" UNIBI_HAS_VAR_FROM)
list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES "${UNIBILIUM_INCLUDE_DIRS}")
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "${UNIBILIUM_LIBRARIES}")
if(UNIBI_HAS_VAR_FROM)
add_definitions(-DNVIM_UNIBI_HAS_VAR_FROM)
endif()
find_package(LibTermkey 0.18 REQUIRED)
include_directories(SYSTEM ${LIBTERMKEY_INCLUDE_DIRS})
endif()
find_package(LIBVTERM 0.1 REQUIRED)
include_directories(SYSTEM ${LIBVTERM_INCLUDE_DIRS})
if(WIN32)
find_package(Winpty 0.4.3 REQUIRED)
include_directories(SYSTEM ${WINPTY_INCLUDE_DIRS})
endif()
option(CLANG_ASAN_UBSAN "Enable Clang address & undefined behavior sanitizer for nvim binary." OFF)
2015-06-08 09:49:23 -07:00
option(CLANG_MSAN "Enable Clang memory sanitizer for nvim binary." OFF)
option(CLANG_TSAN "Enable Clang thread sanitizer for nvim binary." OFF)
if((CLANG_ASAN_UBSAN AND CLANG_MSAN)
OR (CLANG_ASAN_UBSAN AND CLANG_TSAN)
OR (CLANG_MSAN AND CLANG_TSAN))
2018-10-06 09:45:34 -07:00
message(FATAL_ERROR "Sanitizers cannot be enabled simultaneously")
2015-06-08 09:49:23 -07:00
endif()
if((CLANG_ASAN_UBSAN OR CLANG_MSAN OR CLANG_TSAN) AND NOT CMAKE_C_COMPILER_ID MATCHES "Clang")
2018-10-06 09:45:34 -07:00
message(FATAL_ERROR "Sanitizers are only supported for Clang")
endif()
if(ENABLE_LIBINTL)
# LibIntl (not Intl) selects our FindLibIntl.cmake script. #8464
find_package(LibIntl REQUIRED)
include_directories(SYSTEM ${LibIntl_INCLUDE_DIRS})
endif()
if(ENABLE_LIBICONV)
find_package(Iconv REQUIRED)
include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
endif()
# Determine platform's threading library. Set CMAKE_THREAD_PREFER_PTHREAD
# explicitly to indicate a strong preference for pthread.
set(CMAKE_THREAD_PREFER_PTHREAD ON)
find_package(Threads REQUIRED)
# Place targets in bin/ or lib/ for all build configurations
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
foreach(CFGNAME ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${CFGNAME} CFGNAME)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFGNAME} ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFGNAME} ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFGNAME} ${CMAKE_BINARY_DIR}/lib)
endforeach()
# Find Lua interpreter
include(LuaHelpers)
set(LUA_DEPENDENCIES lpeg mpack bit)
if(NOT LUA_PRG)
foreach(CURRENT_LUA_PRG luajit lua5.1 lua5.2 lua)
unset(_CHECK_LUA_PRG CACHE)
unset(LUA_PRG_WORKS)
find_program(_CHECK_LUA_PRG ${CURRENT_LUA_PRG})
if(_CHECK_LUA_PRG)
check_lua_deps(${_CHECK_LUA_PRG} "${LUA_DEPENDENCIES}" LUA_PRG_WORKS)
if(LUA_PRG_WORKS)
set(LUA_PRG "${_CHECK_LUA_PRG}" CACHE FILEPATH "Path to a program.")
break()
endif()
endif()
endforeach()
unset(_CHECK_LUA_PRG CACHE)
else()
check_lua_deps(${LUA_PRG} "${LUA_DEPENDENCIES}" LUA_PRG_WORKS)
endif()
if(NOT LUA_PRG_WORKS)
2018-10-06 09:45:34 -07:00
message(FATAL_ERROR "Failed to find a Lua 5.1-compatible interpreter")
endif()
2018-10-06 09:45:34 -07:00
message(STATUS "Using Lua interpreter: ${LUA_PRG}")
# Setup busted.
find_program(BUSTED_PRG NAMES busted busted.bat)
find_program(BUSTED_LUA_PRG busted-lua)
if(NOT BUSTED_OUTPUT_TYPE)
set(BUSTED_OUTPUT_TYPE "nvim")
endif()
find_program(LUACHECK_PRG luacheck)
find_program(FLAKE8_PRG flake8)
find_program(GPERF_PRG gperf)
include(InstallHelpers)
file(GLOB MANPAGES
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
Remove outdated and unused manuals #2891 `nvim-[lang].1`: The non-english manuals are completely outdated and still written in roff, as opposed to mdoc, which is used for `nvim.1`. Given that, they're nearly useless at the moment, and when/if they are updated, they should probably be rewritten from scratch using `nvim.1` as a reference. `xxd*.1`: xxd hasn't been in the source tree for a long time, so the manual is of little use. `nvimtutor*.1`: The vimtutor script hasn't ever shipped with nvim, and the consensus seems to be that it won't, at least in the form of an executable installed alongside `$(PREFIX)/bin/nvim` (see #2700). In `nvim.1`, the argument to the `.Os` macro was removed. This was done because its only purpose was to signify that nvim and nvimtutor were part of the "Neovim" distribution, i.e., one and the same, which isn't applicable anymore because `nvimtutor.1` is being removed. From the `.Os` documentation in `man mdoc`: Os Operating system version for display in the page footer. This is the mandatory third macro of any mdoc file. Its syntax is as follows: .Os [system [version]] The optional system parameter specifies the relevant operating system or environment. It is suggested to leave it unspecified, in which case mandoc(1) uses its -Ios argument or, if that isn't specified either, sysname and release as returned by uname(3). Examples: .Os .Os KTH/CSC/TCS .Os BSD 4.3 See also Dd and Dt. Reviewed-by: Felipe Morales <hel.sheep@gmail.com> Reviewed-by: Florian Walch <florian@fwalch.com> Reviewed-by: Justin M. Keyes <justinkz@gmail.com> [ci skip]
2015-06-24 11:12:51 -07:00
man/nvim.1)
install_helper(
FILES ${MANPAGES}
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
#
# Go down the tree.
#
add_subdirectory(src/nvim)
get_directory_property(NVIM_VERSION_CFLAGS DIRECTORY src/nvim DEFINITION NVIM_VERSION_CFLAGS)
add_subdirectory(test/includes)
2014-11-09 05:52:15 -07:00
add_subdirectory(config)
add_subdirectory(test/functional/fixtures) # compile test programs
add_subdirectory(runtime)
get_directory_property(GENERATED_HELP_TAGS DIRECTORY runtime DEFINITION GENERATED_HELP_TAGS)
if(WIN32)
install_helper(
FILES ${DEPS_PREFIX}/share/nvim-qt/runtime/plugin/nvim_gui_shim.vim
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/nvim-qt/runtime/plugin)
endif()
# Setup some test-related bits. We do this after going down the tree because we
# need some of the targets.
if(BUSTED_PRG)
get_property(TEST_INCLUDE_DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
PROPERTY INCLUDE_DIRECTORIES)
2016-05-16 03:49:32 -07:00
# When running tests from 'ninja' we need to use the
# console pool: to do so we need to use the USES_TERMINAL
# option, but this is only available in CMake 3.2
set(TEST_TARGET_ARGS)
if(NOT (${CMAKE_VERSION} VERSION_LESS 3.2.0))
list(APPEND TEST_TARGET_ARGS "USES_TERMINAL")
endif()
set(UNITTEST_PREREQS nvim-test unittest-headers)
set(FUNCTIONALTEST_PREREQS nvim printenv-test printargs-test shell-test streams-test tty-test ${GENERATED_HELP_TAGS})
set(BENCHMARK_PREREQS nvim tty-test)
# Useful for automated build systems, if they want to manually run the tests.
add_custom_target(unittest-prereqs
DEPENDS ${UNITTEST_PREREQS})
set_target_properties(unittest-prereqs PROPERTIES FOLDER test)
add_custom_target(functionaltest-prereqs
DEPENDS ${FUNCTIONALTEST_PREREQS})
add_custom_target(benchmark-prereqs
DEPENDS ${BENCHMARK_PREREQS})
check_lua_module(${LUA_PRG} "ffi" LUA_HAS_FFI)
if(LUA_HAS_FFI)
add_custom_target(unittest
COMMAND ${CMAKE_COMMAND}
-DBUSTED_PRG=${BUSTED_PRG}
-DLUA_PRG=${LUA_PRG}
-DWORKING_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-DBUSTED_OUTPUT_TYPE=${BUSTED_OUTPUT_TYPE}
-DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
-DBUILD_DIR=${CMAKE_BINARY_DIR}
-DTEST_TYPE=unit
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
DEPENDS ${UNITTEST_PREREQS}
${TEST_TARGET_ARGS})
set_target_properties(unittest PROPERTIES FOLDER test)
else()
message(WARNING "disabling unit tests: no Luajit FFI in ${LUA_PRG}")
endif()
if(LUA_HAS_FFI)
set(TEST_LIBNVIM_PATH $<TARGET_FILE:nvim-test>)
else()
set(TEST_LIBNVIM_PATH "")
endif()
configure_file(
${CMAKE_SOURCE_DIR}/test/config/paths.lua.in
${CMAKE_BINARY_DIR}/test/config/paths.lua.gen)
file(GENERATE
OUTPUT ${CMAKE_BINARY_DIR}/test/config/paths.lua
INPUT ${CMAKE_BINARY_DIR}/test/config/paths.lua.gen)
add_custom_target(functionaltest
COMMAND ${CMAKE_COMMAND}
-DBUSTED_PRG=${BUSTED_PRG}
-DLUA_PRG=${LUA_PRG}
-DNVIM_PRG=$<TARGET_FILE:nvim>
-DWORKING_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-DBUSTED_OUTPUT_TYPE=${BUSTED_OUTPUT_TYPE}
-DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
-DBUILD_DIR=${CMAKE_BINARY_DIR}
-DTEST_TYPE=functional
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
2016-05-16 03:49:32 -07:00
DEPENDS ${FUNCTIONALTEST_PREREQS}
${TEST_TARGET_ARGS})
set_target_properties(functionaltest functionaltest-prereqs
PROPERTIES FOLDER test)
add_custom_target(benchmark
COMMAND ${CMAKE_COMMAND}
-DBUSTED_PRG=${BUSTED_PRG}
-DLUA_PRG=${LUA_PRG}
-DNVIM_PRG=$<TARGET_FILE:nvim>
-DWORKING_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-DBUSTED_OUTPUT_TYPE=${BUSTED_OUTPUT_TYPE}
-DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
-DBUILD_DIR=${CMAKE_BINARY_DIR}
-DTEST_TYPE=benchmark
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
2016-05-16 03:49:32 -07:00
DEPENDS ${BENCHMARK_PREREQS}
${TEST_TARGET_ARGS})
set_target_properties(benchmark benchmark-prereqs PROPERTIES FOLDER test)
endif()
if(BUSTED_LUA_PRG)
add_custom_target(functionaltest-lua
COMMAND ${CMAKE_COMMAND}
-DBUSTED_PRG=${BUSTED_LUA_PRG}
-DLUA_PRG=${LUA_PRG}
-DNVIM_PRG=$<TARGET_FILE:nvim>
-DWORKING_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-DBUSTED_OUTPUT_TYPE=${BUSTED_OUTPUT_TYPE}
-DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
-DBUILD_DIR=${CMAKE_BINARY_DIR}
-DTEST_TYPE=functional
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
2016-05-16 03:49:32 -07:00
DEPENDS ${FUNCTIONALTEST_PREREQS}
${TEST_TARGET_ARGS})
set_target_properties(functionaltest-lua PROPERTIES FOLDER test)
endif()
if(LUACHECK_PRG)
add_custom_target(lualint
COMMAND ${LUACHECK_PRG} -q runtime/ src/ test/
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
else()
add_custom_target(lualint false
COMMENT "lualint: LUACHECK_PRG not defined")
endif()
set(CPACK_PACKAGE_NAME "Neovim")
set(CPACK_PACKAGE_VENDOR "neovim.io")
set(CPACK_PACKAGE_VERSION ${NVIM_VERSION_MEDIUM})
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Neovim")
# Set toplevel directory/installer name as Neovim
set(CPACK_PACKAGE_FILE_NAME "Neovim")
set(CPACK_TOPLEVEL_TAG "Neovim")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
set(CPACK_NSIS_MODIFY_PATH ON)
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
include(CPack)