aboutsummaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt87
1 files changed, 42 insertions, 45 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9c3c20d23f..a4e49ccfc5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,6 +6,13 @@
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()
+
# Point CMake at any custom modules we may ship
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
@@ -113,47 +120,32 @@ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
# 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)
-set(NVIM_VERSION_MINOR 4)
+set(NVIM_VERSION_MINOR 5)
set(NVIM_VERSION_PATCH 0)
-set(NVIM_VERSION_PRERELEASE "") # for package maintainers
+set(NVIM_VERSION_PRERELEASE "-dev") # for package maintainers
# API level
-set(NVIM_API_LEVEL 6) # Bump this after any API change.
+set(NVIM_API_LEVEL 7) # Bump this after any API change.
set(NVIM_API_LEVEL_COMPAT 0) # Adjust this after a _breaking_ API change.
-set(NVIM_API_PRERELEASE false)
-
-file(TO_CMAKE_PATH ${CMAKE_CURRENT_LIST_DIR}/.git FORCED_GIT_DIR)
-include(GetGitRevisionDescription)
-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()
+set(NVIM_API_PRERELEASE true)
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)")
+ # Minimize logging for release-type builds.
+ if(CMAKE_BUILD_TYPE STREQUAL "Release"
+ OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"
+ OR CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
+ message(STATUS "MIN_LOG_LEVEL not specified, default is 3 (ERROR) for release builds")
+ set(MIN_LOG_LEVEL 3)
+ else()
+ message(STATUS "MIN_LOG_LEVEL not specified, default is 1 (INFO)")
+ set(MIN_LOG_LEVEL 1)
+ endif()
else()
if(NOT MIN_LOG_LEVEL MATCHES "^[0-3]$")
message(FATAL_ERROR "invalid MIN_LOG_LEVEL: " ${MIN_LOG_LEVEL})
@@ -309,11 +301,18 @@ if(UNIX)
if(HAS_FSTACK_PROTECTOR_STRONG_FLAG)
add_compile_options(-fstack-protector-strong)
+ link_libraries(-fstack-protector-strong)
elseif(HAS_FSTACK_PROTECTOR_FLAG)
add_compile_options(-fstack-protector --param ssp-buffer-size=4)
+ link_libraries(-fstack-protector --param ssp-buffer-size=4)
endif()
endif()
+check_c_compiler_flag(-fno-common HAVE_FNO_COMMON)
+if (HAVE_FNO_COMMON)
+ add_compile_options(-fno-common)
+endif()
+
check_c_compiler_flag(-fdiagnostics-color=auto HAS_DIAG_COLOR_FLAG)
if(HAS_DIAG_COLOR_FLAG)
if(CMAKE_GENERATOR MATCHES "Ninja")
@@ -323,10 +322,10 @@ if(HAS_DIAG_COLOR_FLAG)
endif()
endif()
-option(TRAVIS_CI_BUILD "Travis/QuickBuild CI, extra flags will be set" OFF)
+option(TRAVIS_CI_BUILD "Travis/sourcehut CI, extra flags will be set" OFF)
if(TRAVIS_CI_BUILD)
- message(STATUS "Travis/QuickBuild CI build enabled")
+ message(STATUS "Travis/sourcehut CI build enabled")
add_compile_options(-Werror)
if(DEFINED ENV{BUILD_32BIT})
# Get some test coverage for unsigned char
@@ -454,17 +453,17 @@ if((CLANG_ASAN_UBSAN OR CLANG_MSAN OR CLANG_TSAN) AND NOT CMAKE_C_COMPILER_ID MA
message(FATAL_ERROR "Sanitizers are only supported for Clang")
endif()
+if(ENABLE_LIBICONV)
+ find_package(Iconv REQUIRED)
+ include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
+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)
@@ -486,18 +485,19 @@ include(LuaHelpers)
set(LUA_DEPENDENCIES lpeg mpack bit)
if(NOT LUA_PRG)
foreach(CURRENT_LUA_PRG luajit lua5.1 lua5.2 lua)
- # If LUA_PRG is set find_program() will not search
- unset(LUA_PRG CACHE)
+ unset(_CHECK_LUA_PRG CACHE)
unset(LUA_PRG_WORKS)
- find_program(LUA_PRG ${CURRENT_LUA_PRG})
+ find_program(_CHECK_LUA_PRG ${CURRENT_LUA_PRG})
- if(LUA_PRG)
- check_lua_deps(${LUA_PRG} "${LUA_DEPENDENCIES}" LUA_PRG_WORKS)
+ 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()
@@ -560,10 +560,7 @@ if(BUSTED_PRG)
endif()
set(UNITTEST_PREREQS nvim-test unittest-headers)
- set(FUNCTIONALTEST_PREREQS nvim printargs-test shell-test streams-test ${GENERATED_HELP_TAGS})
- if(NOT WIN32)
- list(APPEND FUNCTIONALTEST_PREREQS tty-test)
- endif()
+ 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.