2014-11-18 06:01:24 -07:00
|
|
|
cmake_minimum_required(VERSION 2.8.7)
|
2016-02-17 07:16:25 -07:00
|
|
|
project(nvim)
|
2014-01-31 06:39:15 -07:00
|
|
|
|
2016-03-09 08:25:28 -07:00
|
|
|
if(POLICY CMP0059)
|
|
|
|
cmake_policy(SET CMP0059 OLD) # Needed until cmake 2.8.12. #4389
|
|
|
|
endif()
|
|
|
|
|
2014-02-24 13:54:45 -07:00
|
|
|
# Point CMake at any custom modules we may ship
|
2014-11-10 17:26:01 -07:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
2014-02-24 13:54:45 -07:00
|
|
|
|
2016-10-11 15:35:02 -07:00
|
|
|
# We don't support building in-tree.
|
|
|
|
include(PreventInTreeBuilds)
|
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
# Prefer our bundled versions of dependencies.
|
2014-12-11 10:17:20 -07:00
|
|
|
set(DEPS_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/.deps/usr" CACHE PATH "Path prefix for finding dependencies")
|
2015-04-18 16:20:26 -07:00
|
|
|
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()
|
2014-03-03 08:09:06 -07:00
|
|
|
|
2015-08-27 00:56:46 -07:00
|
|
|
# used for check_c_compiler_flag
|
|
|
|
include(CheckCCompilerFlag)
|
|
|
|
|
2014-11-08 14:16:39 -07:00
|
|
|
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()
|
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
|
|
|
set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ")
|
|
|
|
endif()
|
2017-01-17 08:32:41 -07:00
|
|
|
endif()
|
2015-03-26 20:30:45 -07:00
|
|
|
|
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.
|
2015-03-26 20:30:45 -07:00
|
|
|
set(USE_FNAME_CASE TRUE)
|
2014-11-08 14:16:39 -07:00
|
|
|
endif()
|
|
|
|
|
2014-11-09 05:52:15 -07:00
|
|
|
# Set default build type.
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
2015-09-28 03:14:38 -07:00
|
|
|
message(STATUS "CMAKE_BUILD_TYPE not given, defaulting to 'Dev'.")
|
|
|
|
set(CMAKE_BUILD_TYPE "Dev" CACHE STRING "Choose the type of build." FORCE)
|
2014-11-09 05:52:15 -07:00
|
|
|
endif()
|
|
|
|
|
2015-12-19 20:58:47 -07:00
|
|
|
# Set available build types for CMake GUIs.
|
|
|
|
# A different build type can still be set by -DCMAKE_BUILD_TYPE=...
|
|
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
|
|
|
|
STRINGS "Debug" "Dev" "Release" "MinSizeRel" "RelWithDebInfo")
|
|
|
|
|
2015-12-13 10:29:02 -07:00
|
|
|
# If not in a git repo (e.g., a tarball) these tokens define the complete
|
2016-10-26 06:20:00 -07:00
|
|
|
# version string, else they are combined with the result of `git describe`.
|
2014-10-04 15:32:47 -07:00
|
|
|
set(NVIM_VERSION_MAJOR 0)
|
2016-11-27 11:20:05 -07:00
|
|
|
set(NVIM_VERSION_MINOR 2)
|
|
|
|
set(NVIM_VERSION_PATCH 0)
|
|
|
|
set(NVIM_VERSION_PRERELEASE "-dev") # for package maintainers
|
2015-09-28 03:17:19 -07:00
|
|
|
|
2016-10-26 06:20:00 -07:00
|
|
|
# API level
|
2017-03-04 05:27:33 -07:00
|
|
|
set(NVIM_API_LEVEL 2) # Bump this after any API change.
|
2016-10-26 06:20:00 -07:00
|
|
|
set(NVIM_API_LEVEL_COMPAT 0) # Adjust this after a _breaking_ API change.
|
2017-03-04 05:27:33 -07:00
|
|
|
set(NVIM_API_PRERELEASE true)
|
api: Nvim version, API level #5386
The API level is disconnected from the NVIM version. The API metadata
holds the current API level, and the lowest backwards-compatible level
supported by this instance.
Release 0.1.6 will be the first release reporting the Nvim version and
API level.
metadata['version'] = {
major: 0,
minor: 1,
patch: 6,
prerelease: true,
api_level: 1,
api_compatible: 0,
}
The API level may remain unchanged across Neovim releases if the API has
not changed.
When changing the API the CMake variable NVIM_API_PRERELEASE is set to
true, and NVIM_API_CURRENT/NVIM_API_COMPATIBILITY are incremented
accordingly.
The functional tests check the API table against fixtures of past
versions of Neovim. It compares all the functions in the old table with
the new one, it does ignore some metadata attributes that do not alter
the function signature or were removed since 0.1.5. Currently the only
fixture is 0.mpack, generated from Neovim 0.1.5 with nvim --api-info.
2016-09-25 10:46:37 -07:00
|
|
|
|
2015-09-29 12:22:55 -07:00
|
|
|
file(TO_CMAKE_PATH ${CMAKE_CURRENT_LIST_DIR}/.git FORCED_GIT_DIR)
|
2015-09-28 03:17:19 -07:00
|
|
|
include(GetGitRevisionDescription)
|
2015-12-13 10:29:02 -07:00
|
|
|
get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT)
|
|
|
|
if(NVIM_VERSION_COMMIT) # is a git repo
|
|
|
|
git_describe(NVIM_VERSION_MEDIUM)
|
|
|
|
# `git describe` annotates the most recent tagged release; for pre-release
|
|
|
|
# builds we must replace that with the unreleased version.
|
|
|
|
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+"
|
|
|
|
"v${NVIM_VERSION_MAJOR}.${NVIM_VERSION_MINOR}.${NVIM_VERSION_PATCH}"
|
|
|
|
NVIM_VERSION_MEDIUM
|
|
|
|
${NVIM_VERSION_MEDIUM})
|
|
|
|
endif()
|
2015-09-28 03:17:19 -07:00
|
|
|
|
2014-11-09 05:52:15 -07:00
|
|
|
set(NVIM_VERSION_BUILD_TYPE "${CMAKE_BUILD_TYPE}")
|
|
|
|
# NVIM_VERSION_CFLAGS set further below.
|
2014-01-31 06:39:15 -07:00
|
|
|
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
2014-11-07 04:21:54 -07:00
|
|
|
# Default to -O2 on release builds.
|
2015-09-30 11:38:34 -07:00
|
|
|
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()
|
2014-11-07 04:21:54 -07:00
|
|
|
|
2015-09-28 03:15:55 -07:00
|
|
|
# Disable logging for release-type builds.
|
|
|
|
if(NOT CMAKE_C_FLAGS_RELEASE MATCHES DDISABLE_LOG)
|
|
|
|
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DDISABLE_LOG")
|
|
|
|
endif()
|
|
|
|
if(NOT CMAKE_C_FLAGS_MINSIZEREL MATCHES DDISABLE_LOG)
|
|
|
|
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DDISABLE_LOG")
|
|
|
|
endif()
|
|
|
|
if(NOT CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DDISABLE_LOG)
|
|
|
|
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDISABLE_LOG")
|
|
|
|
endif()
|
|
|
|
|
2015-09-28 03:14:38 -07:00
|
|
|
# Enable assertions for RelWithDebInfo.
|
|
|
|
if(CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DNDEBUG)
|
|
|
|
string(REPLACE "-DNDEBUG" "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Set build flags for custom Dev build type.
|
|
|
|
# -DNDEBUG purposely omitted because we want assertions.
|
|
|
|
if(MSVC)
|
|
|
|
SET(CMAKE_C_FLAGS_DEV ""
|
|
|
|
CACHE STRING "Flags used by the compiler during development (optimized, but with debug info and logging) builds."
|
|
|
|
FORCE)
|
|
|
|
else()
|
|
|
|
if(CMAKE_COMPILER_IS_GNUCC)
|
|
|
|
check_c_compiler_flag(-Og HAS_OG_FLAG)
|
|
|
|
else()
|
|
|
|
set(HAS_OG_FLAG 0)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(HAS_OG_FLAG)
|
|
|
|
set(CMAKE_C_FLAGS_DEV "-Og -g"
|
|
|
|
CACHE STRING "Flags used by the compiler during development (optimized, but with debug info and logging) builds."
|
|
|
|
FORCE)
|
|
|
|
else()
|
|
|
|
set(CMAKE_C_FLAGS_DEV "-O2 -g"
|
|
|
|
CACHE STRING "Flags used by the compiler during development (optimized, but with debug info and logging) builds."
|
|
|
|
FORCE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
SET(CMAKE_EXE_LINKER_FLAGS_DEV ""
|
|
|
|
CACHE STRING "Flags used for linking binaries during development (optimized, but with debug info and logging) builds."
|
|
|
|
FORCE)
|
|
|
|
SET(CMAKE_SHARED_LINKER_FLAGS_DEV ""
|
|
|
|
CACHE STRING "Flags used by the shared libraries linker during development (optimized, but with debug info and logging) builds."
|
|
|
|
FORCE)
|
|
|
|
|
|
|
|
MARK_AS_ADVANCED(
|
|
|
|
CMAKE_C_FLAGS_DEV
|
|
|
|
CMAKE_EXE_LINKER_FLAGS_DEV
|
|
|
|
CMAKE_SHARED_LINKER_FLAGS_DEV)
|
|
|
|
|
2014-11-18 06:01:24 -07:00
|
|
|
# Enable -Wconversion.
|
2015-08-27 19:00:09 -07:00
|
|
|
if(NOT MSVC)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion")
|
|
|
|
endif()
|
2014-11-18 06:01:24 -07:00
|
|
|
|
2017-02-11 17:02:54 -07:00
|
|
|
# gcc 4.0+ sets _FORTIFY_SOURCE=2 automatically. This currently
|
2014-11-04 15:06:18 -07:00
|
|
|
# does not work with Neovim due to some uses of dynamically-sized structures.
|
2017-02-11 17:02:54 -07:00
|
|
|
# https://github.com/neovim/neovim/issues/223
|
2014-11-21 01:42:59 -07:00
|
|
|
include(CheckCSourceCompiles)
|
2014-12-16 04:02:42 -07:00
|
|
|
|
|
|
|
# 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()
|
|
|
|
|
2016-02-09 14:22:30 -07:00
|
|
|
# Include <string.h> because some toolchains define _FORTIFY_SOURCE=2 in
|
|
|
|
# internal header files, which should in turn be #included by <string.h>.
|
2014-11-21 01:42:59 -07:00
|
|
|
check_c_source_compiles("
|
2016-02-09 14:22:30 -07:00
|
|
|
#include <string.h>
|
|
|
|
|
2014-11-21 01:42:59 -07:00
|
|
|
#if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 1
|
|
|
|
#error \"_FORTIFY_SOURCE > 1\"
|
|
|
|
#endif
|
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2015-06-04 02:08:26 -07:00
|
|
|
" HAS_ACCEPTABLE_FORTIFY)
|
2014-11-21 01:42:59 -07:00
|
|
|
|
2015-06-04 02:08:26 -07:00
|
|
|
if(NOT HAS_ACCEPTABLE_FORTIFY)
|
|
|
|
message(STATUS "Unsupported _FORTIFY_SOURCE found, forcing _FORTIFY_SOURCE=1.")
|
2014-12-12 10:45:21 -07:00
|
|
|
# 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}" )
|
2015-08-26 15:00:33 -07:00
|
|
|
if(NOT _FORTIFY_SOURCE_PREFIX STREQUAL "")
|
2015-06-04 02:08:26 -07:00
|
|
|
message(STATUS "Detected _FORTIFY_SOURCE Prefix=${_FORTIFY_SOURCE_PREFIX}.")
|
2014-12-12 10:45:21 -07:00
|
|
|
endif()
|
2014-11-04 15:06:18 -07:00
|
|
|
# -U in add_definitions doesn't end up in the correct spot, so we add it to
|
|
|
|
# the flags variable instead.
|
2014-12-12 10:45:21 -07:00
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FORTIFY_SOURCE_PREFIX}-U_FORTIFY_SOURCE ${_FORTIFY_SOURCE_PREFIX}-D_FORTIFY_SOURCE=1")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_FORTIFY_SOURCE_PREFIX}-U_FORTIFY_SOURCE ${_FORTIFY_SOURCE_PREFIX}-D_FORTIFY_SOURCE=1")
|
2014-11-04 15:06:18 -07:00
|
|
|
endif()
|
|
|
|
|
2015-09-30 11:38:34 -07:00
|
|
|
# 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")
|
|
|
|
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()
|
|
|
|
|
2015-08-27 19:00:09 -07:00
|
|
|
if(MSVC)
|
|
|
|
# XXX: /W4 gives too many warnings. #3241
|
|
|
|
add_definitions(/W3 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
|
|
|
|
else()
|
|
|
|
add_definitions(-Wall -Wextra -pedantic -Wno-unused-parameter
|
2015-10-02 09:51:45 -07:00
|
|
|
-Wstrict-prototypes -std=gnu99)
|
2016-02-27 18:20:27 -07:00
|
|
|
|
|
|
|
# On FreeBSD 64 math.h uses unguarded C11 extension, which taints clang
|
|
|
|
# 3.4.1 used there.
|
|
|
|
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
|
|
|
|
add_definitions(-Wno-c11-extensions)
|
|
|
|
endif()
|
2015-08-27 19:00:09 -07:00
|
|
|
endif()
|
|
|
|
|
2015-08-26 15:00:33 -07:00
|
|
|
if(MINGW)
|
2014-07-03 06:32:09 -07:00
|
|
|
# Use POSIX compatible stdio in Mingw
|
|
|
|
add_definitions(-D__USE_MINGW_ANSI_STDIO)
|
2015-02-03 06:31:33 -07:00
|
|
|
add_definitions(-D_WIN32_WINNT=0x0600)
|
2014-07-03 06:32:09 -07:00
|
|
|
endif()
|
2014-05-14 16:08:41 -07:00
|
|
|
|
2015-10-02 09:51:45 -07:00
|
|
|
# OpenBSD's GCC (4.2.1) doesn't have -Wvla
|
|
|
|
check_c_compiler_flag(-Wvla HAS_WVLA_FLAG)
|
|
|
|
if(HAS_WVLA_FLAG)
|
|
|
|
add_definitions(-Wvla)
|
|
|
|
endif()
|
|
|
|
|
2015-10-13 16:46:32 -07:00
|
|
|
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_definitions(-fstack-protector-strong)
|
|
|
|
elseif(HAS_FSTACK_PROTECTOR_FLAG)
|
|
|
|
add_definitions(-fstack-protector --param ssp-buffer-size=4)
|
|
|
|
endif()
|
2015-08-26 15:00:33 -07:00
|
|
|
endif()
|
|
|
|
|
2015-08-27 00:56:46 -07:00
|
|
|
check_c_compiler_flag(-fdiagnostics-color=auto HAS_DIAG_COLOR_FLAG)
|
|
|
|
if(HAS_DIAG_COLOR_FLAG)
|
|
|
|
add_definitions(-fdiagnostics-color=auto)
|
|
|
|
endif()
|
|
|
|
|
2017-01-31 00:53:16 -07:00
|
|
|
option(TRAVIS_CI_BUILD "Travis/QuickBuild CI. Extra flags will be set." OFF)
|
2014-05-14 16:08:41 -07:00
|
|
|
|
|
|
|
if(TRAVIS_CI_BUILD)
|
2017-01-31 00:53:16 -07:00
|
|
|
message(STATUS "Travis/QuickBuild CI build enabled.")
|
2014-05-14 16:08:41 -07:00
|
|
|
add_definitions(-Werror)
|
2016-10-09 10:55:08 -07:00
|
|
|
if(DEFINED ENV{BUILD_32BIT})
|
|
|
|
# Get some test coverage for unsigned char
|
|
|
|
add_definitions(-funsigned-char)
|
|
|
|
endif()
|
2014-05-14 16:08:41 -07:00
|
|
|
endif()
|
2014-02-27 05:27:20 -07:00
|
|
|
|
2014-01-31 06:39:15 -07:00
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
|
|
|
set(DEBUG 1)
|
|
|
|
else()
|
|
|
|
set(DEBUG 0)
|
|
|
|
endif()
|
|
|
|
|
2014-11-08 04:49:04 -07:00
|
|
|
add_definitions(-DINCLUDE_GENERATED_DECLARATIONS)
|
|
|
|
add_definitions(-DHAVE_CONFIG_H)
|
|
|
|
|
2014-05-14 18:14:28 -07:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined")
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined")
|
|
|
|
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined")
|
2016-01-24 19:16:00 -07:00
|
|
|
|
|
|
|
# For O_CLOEXEC, O_DIRECTORY, and O_NOFOLLOW flags on older systems
|
|
|
|
# (pre POSIX.1-2008: glibc 2.11 and earlier). #4042
|
|
|
|
add_definitions(-D_GNU_SOURCE)
|
2014-05-14 18:14:28 -07:00
|
|
|
endif()
|
|
|
|
|
2015-02-23 13:45:11 -07:00
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_NAME STREQUAL "SunOS")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined -lsocket")
|
|
|
|
endif()
|
|
|
|
|
2014-10-17 03:50:13 -07:00
|
|
|
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()
|
|
|
|
|
2014-04-03 12:00:43 -07:00
|
|
|
include_directories("${PROJECT_BINARY_DIR}/config")
|
|
|
|
include_directories("${PROJECT_SOURCE_DIR}/src")
|
|
|
|
|
|
|
|
find_package(LibUV REQUIRED)
|
2014-05-15 04:21:13 -07:00
|
|
|
include_directories(SYSTEM ${LIBUV_INCLUDE_DIRS})
|
2014-04-03 12:00:43 -07:00
|
|
|
|
2016-02-04 20:21:51 -07:00
|
|
|
find_package(Msgpack 1.0.0 REQUIRED)
|
2014-05-15 04:21:13 -07:00
|
|
|
include_directories(SYSTEM ${MSGPACK_INCLUDE_DIRS})
|
2014-04-10 11:39:34 -07:00
|
|
|
|
2017-03-30 08:05:48 -07:00
|
|
|
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)
|
|
|
|
|
|
|
|
if(MSGPACK_HAS_FLOAT32)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNVIM_MSGPACK_HAS_FLOAT32")
|
|
|
|
endif()
|
|
|
|
|
2016-05-23 14:16:39 -07:00
|
|
|
if(UNIX)
|
|
|
|
option(FEAT_TUI "Enable the Terminal UI" ON)
|
|
|
|
else()
|
|
|
|
option(FEAT_TUI "Enable the Terminal UI" OFF)
|
|
|
|
endif()
|
2015-02-13 08:06:05 -07:00
|
|
|
|
2016-05-23 14:16:39 -07:00
|
|
|
if(FEAT_TUI)
|
|
|
|
find_package(Unibilium REQUIRED)
|
|
|
|
include_directories(SYSTEM ${UNIBILIUM_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
find_package(LibTermkey REQUIRED)
|
|
|
|
include_directories(SYSTEM ${LIBTERMKEY_INCLUDE_DIRS})
|
|
|
|
endif()
|
2015-02-13 08:06:05 -07:00
|
|
|
|
2015-02-28 06:41:53 -07:00
|
|
|
find_package(LibVterm REQUIRED)
|
|
|
|
include_directories(SYSTEM ${LIBVTERM_INCLUDE_DIRS})
|
|
|
|
|
2015-06-09 01:43:22 -07:00
|
|
|
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)
|
2015-06-09 01:43:22 -07:00
|
|
|
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))
|
|
|
|
message(FATAL_ERROR "Sanitizers cannot be enabled simultaneously.")
|
2015-06-08 09:49:23 -07:00
|
|
|
endif()
|
2015-06-09 01:43:22 -07:00
|
|
|
|
|
|
|
if((CLANG_ASAN_UBSAN OR CLANG_MSAN OR CLANG_TSAN) AND NOT CMAKE_C_COMPILER_ID MATCHES "Clang")
|
2015-06-08 09:49:23 -07:00
|
|
|
message(FATAL_ERROR "Sanitizers are only supported for Clang.")
|
2015-04-12 07:40:08 -07:00
|
|
|
endif()
|
|
|
|
|
2017-01-26 05:07:30 -07:00
|
|
|
if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD|FreeBSD")
|
|
|
|
message(STATUS "detected OpenBSD/FreeBSD; disabled jemalloc. #5318")
|
2016-09-10 04:12:09 -07:00
|
|
|
option(ENABLE_JEMALLOC "enable jemalloc" OFF)
|
|
|
|
else()
|
|
|
|
option(ENABLE_JEMALLOC "enable jemalloc" ON)
|
|
|
|
endif()
|
2015-10-26 11:33:50 -07:00
|
|
|
|
|
|
|
if (ENABLE_JEMALLOC)
|
|
|
|
if(CLANG_ASAN_UBSAN OR CLANG_MSAN OR CLANG_TSAN)
|
|
|
|
message(STATUS "Sanitizers have been enabled; don't use jemalloc.")
|
|
|
|
else()
|
|
|
|
find_package(JeMalloc)
|
|
|
|
if(JEMALLOC_FOUND)
|
|
|
|
include_directories(SYSTEM ${JEMALLOC_INCLUDE_DIRS})
|
|
|
|
endif()
|
2015-04-12 07:40:08 -07:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2014-04-03 12:00:43 -07:00
|
|
|
find_package(LibIntl)
|
|
|
|
if(LibIntl_FOUND)
|
2014-11-08 14:09:47 -07:00
|
|
|
include_directories(SYSTEM ${LibIntl_INCLUDE_DIRS})
|
2014-04-03 12:00:43 -07:00
|
|
|
endif()
|
|
|
|
|
2014-11-08 14:18:04 -07:00
|
|
|
find_package(Iconv)
|
|
|
|
if(Iconv_FOUND)
|
|
|
|
include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
|
2014-04-03 12:00:43 -07:00
|
|
|
endif()
|
|
|
|
|
2014-02-24 11:52:12 -07:00
|
|
|
# Determine platform's threading library. Set CMAKE_THREAD_PREFER_PTHREAD
|
2014-06-25 14:47:27 -07:00
|
|
|
# explicitly to indicate a strong preference for pthread.
|
2014-02-24 11:52:12 -07:00
|
|
|
set(CMAKE_THREAD_PREFER_PTHREAD ON)
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
2016-01-08 19:40:57 -07:00
|
|
|
# Place targets in bin/ or lib/ for all build configurations
|
2014-03-03 08:09:06 -07:00
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
2014-11-30 19:22:46 -07:00
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
2016-01-08 19:40:57 -07:00
|
|
|
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()
|
2014-02-22 08:30:50 -07:00
|
|
|
|
2014-07-11 04:12:18 -07:00
|
|
|
# Find Lua interpreter
|
2014-07-11 04:12:10 -07:00
|
|
|
include(LuaHelpers)
|
2016-04-13 05:21:32 -07:00
|
|
|
set(LUA_DEPENDENCIES lpeg mpack bit)
|
2014-07-11 04:12:18 -07:00
|
|
|
if(NOT LUA_PRG)
|
2016-06-03 09:21:29 -07:00
|
|
|
foreach(CURRENT_LUA_PRG luajit lua5.1 lua5.2 lua)
|
2014-07-11 04:12:18 -07:00
|
|
|
# If LUA_PRG is set find_program() will not search
|
|
|
|
unset(LUA_PRG CACHE)
|
|
|
|
unset(LUA_PRG_WORKS)
|
|
|
|
find_program(LUA_PRG ${CURRENT_LUA_PRG})
|
|
|
|
|
|
|
|
if(LUA_PRG)
|
|
|
|
check_lua_deps(${LUA_PRG} "${LUA_DEPENDENCIES}" LUA_PRG_WORKS)
|
|
|
|
if(LUA_PRG_WORKS)
|
|
|
|
break()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
else()
|
|
|
|
check_lua_deps(${LUA_PRG} "${LUA_DEPENDENCIES}" LUA_PRG_WORKS)
|
|
|
|
endif()
|
2014-04-13 03:06:35 -07:00
|
|
|
|
2014-07-11 04:12:10 -07:00
|
|
|
if(NOT LUA_PRG_WORKS)
|
2015-09-30 11:38:34 -07:00
|
|
|
message(FATAL_ERROR "A suitable Lua interpreter was not found.")
|
2014-04-13 03:06:35 -07:00
|
|
|
endif()
|
|
|
|
|
2015-09-30 11:38:34 -07:00
|
|
|
message(STATUS "Using the Lua interpreter ${LUA_PRG}.")
|
2014-04-13 03:06:35 -07:00
|
|
|
|
build: install with the correct permissions
The install() command will create the parent directories, but it does so
with the user's umask. We want to do our best to make sure the correct
permissions are being set, without clobbering existing permissions.
To do this, this commit introduces an install_helper(), which is similar
in signature to the install() command, to help ensure that directories
are created ahead of the actual install() command. This will attempt to
use 0644 permissions for files and 0755 permissions for directories by
default--though they can be overridden.
To make this work correctly, without trying to introduce some mechanism
with setting the umask, it meant that there's a small portion that makes
use of an "internal" version of the file() command. It has been tested
on CMake 2.8.11, 2.8.12, and 3.0.2, and works correctly on all versions.
This fixes #1201 and #1086.
2014-09-19 04:37:22 -07:00
|
|
|
# Setup busted.
|
2016-03-19 10:54:14 -07:00
|
|
|
find_program(BUSTED_PRG NAMES busted busted.bat)
|
2016-03-06 20:42:49 -07:00
|
|
|
find_program(BUSTED_LUA_PRG busted-lua)
|
build: install with the correct permissions
The install() command will create the parent directories, but it does so
with the user's umask. We want to do our best to make sure the correct
permissions are being set, without clobbering existing permissions.
To do this, this commit introduces an install_helper(), which is similar
in signature to the install() command, to help ensure that directories
are created ahead of the actual install() command. This will attempt to
use 0644 permissions for files and 0755 permissions for directories by
default--though they can be overridden.
To make this work correctly, without trying to introduce some mechanism
with setting the umask, it meant that there's a small portion that makes
use of an "internal" version of the file() command. It has been tested
on CMake 2.8.11, 2.8.12, and 3.0.2, and works correctly on all versions.
This fixes #1201 and #1086.
2014-09-19 04:37:22 -07:00
|
|
|
if(NOT BUSTED_OUTPUT_TYPE)
|
2015-12-20 16:11:23 -07:00
|
|
|
if(WIN32)
|
|
|
|
set(BUSTED_OUTPUT_TYPE "plainTerminal")
|
|
|
|
else()
|
|
|
|
set(BUSTED_OUTPUT_TYPE "utfTerminal")
|
|
|
|
endif()
|
build: install with the correct permissions
The install() command will create the parent directories, but it does so
with the user's umask. We want to do our best to make sure the correct
permissions are being set, without clobbering existing permissions.
To do this, this commit introduces an install_helper(), which is similar
in signature to the install() command, to help ensure that directories
are created ahead of the actual install() command. This will attempt to
use 0644 permissions for files and 0755 permissions for directories by
default--though they can be overridden.
To make this work correctly, without trying to introduce some mechanism
with setting the umask, it meant that there's a small portion that makes
use of an "internal" version of the file() command. It has been tested
on CMake 2.8.11, 2.8.12, and 3.0.2, and works correctly on all versions.
This fixes #1201 and #1086.
2014-09-19 04:37:22 -07:00
|
|
|
endif()
|
2014-03-03 08:09:06 -07:00
|
|
|
|
2015-11-17 05:16:33 -07:00
|
|
|
find_program(LUACHECK_PRG luacheck)
|
2016-06-19 07:41:08 -07:00
|
|
|
find_program(GPERF_PRG gperf)
|
|
|
|
|
build: install with the correct permissions
The install() command will create the parent directories, but it does so
with the user's umask. We want to do our best to make sure the correct
permissions are being set, without clobbering existing permissions.
To do this, this commit introduces an install_helper(), which is similar
in signature to the install() command, to help ensure that directories
are created ahead of the actual install() command. This will attempt to
use 0644 permissions for files and 0755 permissions for directories by
default--though they can be overridden.
To make this work correctly, without trying to introduce some mechanism
with setting the umask, it meant that there's a small portion that makes
use of an "internal" version of the file() command. It has been tested
on CMake 2.8.11, 2.8.12, and 3.0.2, and works correctly on all versions.
This fixes #1201 and #1086.
2014-09-19 04:37:22 -07:00
|
|
|
include(InstallHelpers)
|
|
|
|
|
2015-05-17 11:45:30 -07:00
|
|
|
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)
|
2015-05-17 11:45:30 -07:00
|
|
|
|
|
|
|
install_helper(
|
|
|
|
FILES ${MANPAGES}
|
|
|
|
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
|
|
|
|
|
2014-12-08 13:00:54 -07:00
|
|
|
# MIN_LOG_LEVEL for log.h
|
|
|
|
if(DEFINED MIN_LOG_LEVEL)
|
|
|
|
if(NOT MIN_LOG_LEVEL MATCHES "^[0-3]$")
|
2017-02-24 03:03:56 -07:00
|
|
|
message(FATAL_ERROR "MIN_LOG_LEVEL must be a number 0-3")
|
2014-12-08 13:00:54 -07:00
|
|
|
endif()
|
2017-02-24 03:03:56 -07:00
|
|
|
message(STATUS "MIN_LOG_LEVEL set to ${MIN_LOG_LEVEL}")
|
2014-12-08 13:00:54 -07:00
|
|
|
else()
|
2017-02-24 03:03:56 -07:00
|
|
|
message(STATUS "MIN_LOG_LEVEL not specified, defaulting to INFO(1)")
|
2014-12-08 13:00:54 -07:00
|
|
|
endif()
|
|
|
|
|
build: install with the correct permissions
The install() command will create the parent directories, but it does so
with the user's umask. We want to do our best to make sure the correct
permissions are being set, without clobbering existing permissions.
To do this, this commit introduces an install_helper(), which is similar
in signature to the install() command, to help ensure that directories
are created ahead of the actual install() command. This will attempt to
use 0644 permissions for files and 0755 permissions for directories by
default--though they can be overridden.
To make this work correctly, without trying to introduce some mechanism
with setting the umask, it meant that there's a small portion that makes
use of an "internal" version of the file() command. It has been tested
on CMake 2.8.11, 2.8.12, and 3.0.2, and works correctly on all versions.
This fixes #1201 and #1086.
2014-09-19 04:37:22 -07:00
|
|
|
# Go down the tree.
|
2014-03-03 08:09:06 -07:00
|
|
|
|
build: install with the correct permissions
The install() command will create the parent directories, but it does so
with the user's umask. We want to do our best to make sure the correct
permissions are being set, without clobbering existing permissions.
To do this, this commit introduces an install_helper(), which is similar
in signature to the install() command, to help ensure that directories
are created ahead of the actual install() command. This will attempt to
use 0644 permissions for files and 0755 permissions for directories by
default--though they can be overridden.
To make this work correctly, without trying to introduce some mechanism
with setting the umask, it meant that there's a small portion that makes
use of an "internal" version of the file() command. It has been tested
on CMake 2.8.11, 2.8.12, and 3.0.2, and works correctly on all versions.
This fixes #1201 and #1086.
2014-09-19 04:37:22 -07:00
|
|
|
add_subdirectory(src/nvim)
|
2014-11-09 05:52:15 -07:00
|
|
|
# Read compilation flags from src/nvim,
|
|
|
|
# used in config subdirectory below.
|
|
|
|
include(GetCompileFlags)
|
|
|
|
get_compile_flags(NVIM_VERSION_CFLAGS)
|
|
|
|
|
build: install with the correct permissions
The install() command will create the parent directories, but it does so
with the user's umask. We want to do our best to make sure the correct
permissions are being set, without clobbering existing permissions.
To do this, this commit introduces an install_helper(), which is similar
in signature to the install() command, to help ensure that directories
are created ahead of the actual install() command. This will attempt to
use 0644 permissions for files and 0755 permissions for directories by
default--though they can be overridden.
To make this work correctly, without trying to introduce some mechanism
with setting the umask, it meant that there's a small portion that makes
use of an "internal" version of the file() command. It has been tested
on CMake 2.8.11, 2.8.12, and 3.0.2, and works correctly on all versions.
This fixes #1201 and #1086.
2014-09-19 04:37:22 -07:00
|
|
|
add_subdirectory(test/includes)
|
2014-11-09 05:52:15 -07:00
|
|
|
add_subdirectory(config)
|
2017-02-11 17:02:54 -07:00
|
|
|
add_subdirectory(test/functional/fixtures) # compile test programs
|
2015-04-02 09:45:34 -07:00
|
|
|
add_subdirectory(runtime)
|
2015-02-23 08:34:20 -07:00
|
|
|
|
build: install with the correct permissions
The install() command will create the parent directories, but it does so
with the user's umask. We want to do our best to make sure the correct
permissions are being set, without clobbering existing permissions.
To do this, this commit introduces an install_helper(), which is similar
in signature to the install() command, to help ensure that directories
are created ahead of the actual install() command. This will attempt to
use 0644 permissions for files and 0755 permissions for directories by
default--though they can be overridden.
To make this work correctly, without trying to introduce some mechanism
with setting the umask, it meant that there's a small portion that makes
use of an "internal" version of the file() command. It has been tested
on CMake 2.8.11, 2.8.12, and 3.0.2, and works correctly on all versions.
This fixes #1201 and #1086.
2014-09-19 04:37:22 -07:00
|
|
|
# Setup some test-related bits. We do this after going down the tree because we
|
|
|
|
# need some of the targets.
|
2014-03-22 04:14:55 -07:00
|
|
|
if(BUSTED_PRG)
|
2014-04-30 02:10:37 -07:00
|
|
|
get_property(TEST_INCLUDE_DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
PROPERTY INCLUDE_DIRECTORIES)
|
2014-07-15 14:35:08 -07:00
|
|
|
|
|
|
|
# Set policy CMP0026 to OLD so we avoid CMake warnings on newer
|
|
|
|
# versions of cmake.
|
|
|
|
if(POLICY CMP0026)
|
|
|
|
cmake_policy(SET CMP0026 OLD)
|
|
|
|
endif()
|
2016-01-08 18:36:42 -07:00
|
|
|
if(CMAKE_GENERATOR MATCHES "Visual Studio")
|
|
|
|
set(TEST_LIBNVIM_PATH ${CMAKE_BINARY_DIR}/lib/nvim-test.dll)
|
|
|
|
else()
|
|
|
|
get_target_property(TEST_LIBNVIM_PATH nvim-test LOCATION)
|
|
|
|
endif()
|
2014-04-30 02:10:37 -07:00
|
|
|
|
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()
|
|
|
|
|
2014-04-30 02:10:37 -07:00
|
|
|
configure_file(
|
|
|
|
test/config/paths.lua.in
|
|
|
|
${CMAKE_BINARY_DIR}/test/config/paths.lua)
|
|
|
|
|
2015-05-08 03:07:56 -07:00
|
|
|
set(UNITTEST_PREREQS nvim-test unittest-headers)
|
2016-08-25 09:28:54 -07:00
|
|
|
set(FUNCTIONALTEST_PREREQS nvim printargs-test shell-test)
|
|
|
|
if(NOT WIN32)
|
|
|
|
list(APPEND FUNCTIONALTEST_PREREQS tty-test)
|
2015-12-20 16:11:23 -07:00
|
|
|
endif()
|
2015-05-08 03:07:56 -07:00
|
|
|
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})
|
|
|
|
|
|
|
|
add_custom_target(functionaltest-prereqs
|
|
|
|
DEPENDS ${FUNCTIONALTEST_PREREQS})
|
|
|
|
|
|
|
|
add_custom_target(benchmark-prereqs
|
|
|
|
DEPENDS ${BENCHMARK_PREREQS})
|
|
|
|
|
2016-05-07 19:06:46 -07:00
|
|
|
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
|
2015-12-29 12:18:16 -07:00
|
|
|
-DSYSTEM_NAME=${CMAKE_SYSTEM_NAME}
|
2016-05-07 19:06:46 -07:00
|
|
|
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
|
|
|
|
DEPENDS ${UNITTEST_PREREQS}
|
|
|
|
${TEST_TARGET_ARGS})
|
|
|
|
else()
|
2017-02-11 17:02:54 -07:00
|
|
|
message(WARNING "disabling unit tests: no Luajit FFI in ${LUA_PRG}")
|
2016-05-07 19:06:46 -07:00
|
|
|
endif()
|
2014-09-29 05:43:52 -07:00
|
|
|
|
2014-11-05 03:54:20 -07:00
|
|
|
add_custom_target(functionaltest
|
2014-09-29 05:43:52 -07:00
|
|
|
COMMAND ${CMAKE_COMMAND}
|
2014-10-08 08:56:28 -07:00
|
|
|
-DBUSTED_PRG=${BUSTED_PRG}
|
2016-07-13 00:37:50 -07:00
|
|
|
-DLUA_PRG=${LUA_PRG}
|
2014-11-05 05:26:35 -07:00
|
|
|
-DNVIM_PRG=$<TARGET_FILE:nvim>
|
2014-09-29 05:43:52 -07:00
|
|
|
-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
|
2015-12-29 12:18:16 -07:00
|
|
|
-DSYSTEM_NAME=${CMAKE_SYSTEM_NAME}
|
2014-11-10 17:26:01 -07:00
|
|
|
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
|
2016-05-16 03:49:32 -07:00
|
|
|
DEPENDS ${FUNCTIONALTEST_PREREQS}
|
|
|
|
${TEST_TARGET_ARGS})
|
2015-03-28 14:28:37 -07:00
|
|
|
|
|
|
|
add_custom_target(benchmark
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
-DBUSTED_PRG=${BUSTED_PRG}
|
2016-07-13 00:37:50 -07:00
|
|
|
-DLUA_PRG=${LUA_PRG}
|
2015-03-28 14:28:37 -07:00
|
|
|
-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
|
2015-12-29 12:18:16 -07:00
|
|
|
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
|
2015-03-28 14:28:37 -07:00
|
|
|
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
|
2016-05-16 03:49:32 -07:00
|
|
|
DEPENDS ${BENCHMARK_PREREQS}
|
|
|
|
${TEST_TARGET_ARGS})
|
2014-03-22 04:14:55 -07:00
|
|
|
endif()
|
2015-11-17 05:16:33 -07:00
|
|
|
|
2016-03-06 20:42:49 -07:00
|
|
|
if(BUSTED_LUA_PRG)
|
|
|
|
add_custom_target(functionaltest-lua
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
-DBUSTED_PRG=${BUSTED_LUA_PRG}
|
2016-07-13 00:37:50 -07:00
|
|
|
-DLUA_PRG=${LUA_PRG}
|
2016-03-06 20:42:49 -07:00
|
|
|
-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
|
2015-12-29 12:18:16 -07:00
|
|
|
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
|
2016-03-06 20:42:49 -07:00
|
|
|
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
|
2016-05-16 03:49:32 -07:00
|
|
|
DEPENDS ${FUNCTIONALTEST_PREREQS}
|
|
|
|
${TEST_TARGET_ARGS})
|
2016-03-06 20:42:49 -07:00
|
|
|
endif()
|
|
|
|
|
2015-11-17 05:16:33 -07:00
|
|
|
if(LUACHECK_PRG)
|
|
|
|
add_custom_target(testlint
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
-DLUACHECK_PRG=${LUACHECK_PRG}
|
|
|
|
-DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
|
2015-12-29 12:18:16 -07:00
|
|
|
-DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
|
2015-11-17 05:16:33 -07:00
|
|
|
-P ${PROJECT_SOURCE_DIR}/cmake/RunTestsLint.cmake)
|
|
|
|
endif()
|
2016-01-08 17:14:26 -07:00
|
|
|
|
|
|
|
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)
|