2014-03-03 08:09:06 -07:00
|
|
|
cmake_minimum_required (VERSION 2.8.7)
|
2014-01-31 06:39:15 -07:00
|
|
|
project (NEOVIM)
|
|
|
|
|
2014-02-24 13:54:45 -07:00
|
|
|
# Point CMake at any custom modules we may ship
|
|
|
|
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
# Prefer our bundled versions of dependencies.
|
|
|
|
set(DEPS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.deps")
|
|
|
|
set(DEPS_BUILD_DIR "${DEPS_DIR}/build")
|
|
|
|
set(DEPS_INSTALL_DIR "${DEPS_DIR}/usr")
|
|
|
|
set(DEPS_BIN_DIR "${DEPS_INSTALL_DIR}/bin")
|
|
|
|
|
2014-03-28 02:05:00 -07:00
|
|
|
list(APPEND CMAKE_PREFIX_PATH ${DEPS_INSTALL_DIR})
|
2014-03-03 08:09:06 -07:00
|
|
|
|
2014-10-06 22:45:05 -07:00
|
|
|
# Version tokens
|
2014-10-04 15:32:47 -07:00
|
|
|
include(GetGitRevisionDescription)
|
2014-10-06 22:45:05 -07:00
|
|
|
get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT)
|
2014-10-15 11:40:18 -07:00
|
|
|
if (NOT NVIM_VERSION_COMMIT)
|
|
|
|
set(NVIM_VERSION_COMMIT "?")
|
|
|
|
endif()
|
2014-10-04 15:32:47 -07:00
|
|
|
set(NVIM_VERSION_MAJOR 0)
|
|
|
|
set(NVIM_VERSION_MINOR 0)
|
|
|
|
set(NVIM_VERSION_PATCH 0)
|
|
|
|
set(NVIM_VERSION_PRERELEASE "-alpha")
|
2014-10-06 22:45:05 -07:00
|
|
|
# TODO(justinmk): UTC time would be nice here #1071
|
|
|
|
git_timestamp(GIT_TIMESTAMP)
|
2014-10-04 15:32:47 -07:00
|
|
|
# TODO(justinmk): do not set this for "release" builds #1071
|
2014-10-15 11:40:18 -07:00
|
|
|
if (GIT_TIMESTAMP)
|
|
|
|
set(NVIM_VERSION_BUILD "+${GIT_TIMESTAMP}")
|
|
|
|
endif()
|
2014-01-31 06:39:15 -07:00
|
|
|
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
2014-06-25 03:33:36 -07:00
|
|
|
# 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(APPLE)
|
|
|
|
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()
|
|
|
|
endif()
|
|
|
|
|
2014-07-13 00:03:07 -07:00
|
|
|
add_definitions(-Wall -Wextra -pedantic -Wno-unused-parameter
|
|
|
|
-Wstrict-prototypes -std=gnu99)
|
2014-05-14 16:08:41 -07:00
|
|
|
|
|
|
|
option(
|
|
|
|
TRAVIS_CI_BUILD "Travis CI build. Extra compilation flags will be set." OFF)
|
|
|
|
|
|
|
|
if(TRAVIS_CI_BUILD)
|
|
|
|
message(STATUS "Travis CI build enabled.")
|
|
|
|
add_definitions(-Werror)
|
|
|
|
endif()
|
2014-02-27 05:27:20 -07:00
|
|
|
|
2014-05-10 06:24:13 -07:00
|
|
|
add_definitions(-DINCLUDE_GENERATED_DECLARATIONS)
|
|
|
|
|
2014-02-27 05:27:20 -07:00
|
|
|
add_definitions(-DHAVE_CONFIG_H)
|
2014-01-31 06:39:15 -07:00
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
|
|
|
# cmake automatically appends -g to the compiler flags
|
|
|
|
set(DEBUG 1)
|
|
|
|
else()
|
|
|
|
set(DEBUG 0)
|
|
|
|
endif()
|
|
|
|
|
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")
|
|
|
|
endif()
|
|
|
|
|
2014-03-30 04:57:23 -07:00
|
|
|
option(USE_GCOV "Enable gcov support" OFF)
|
|
|
|
|
|
|
|
if(USE_GCOV)
|
|
|
|
message(STATUS "Enabling gcov support")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
|
|
|
|
endif()
|
|
|
|
|
2014-04-03 12:00:43 -07:00
|
|
|
include_directories("${PROJECT_BINARY_DIR}/config")
|
|
|
|
include_directories("${PROJECT_SOURCE_DIR}/src")
|
|
|
|
|
2014-02-26 03:06:59 -07:00
|
|
|
# Modules used by platform auto-detection
|
|
|
|
include(CheckLibraryExists)
|
|
|
|
|
2014-04-03 12:00:43 -07:00
|
|
|
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
|
|
|
|
2014-04-10 11:39:34 -07:00
|
|
|
find_package(Msgpack REQUIRED)
|
2014-05-15 04:21:13 -07:00
|
|
|
include_directories(SYSTEM ${MSGPACK_INCLUDE_DIRS})
|
2014-04-10 11:39:34 -07:00
|
|
|
|
2014-04-03 12:00:43 -07:00
|
|
|
find_package(LuaJit REQUIRED)
|
2014-05-15 04:21:13 -07:00
|
|
|
include_directories(SYSTEM ${LUAJIT_INCLUDE_DIRS})
|
2014-04-03 12:00:43 -07:00
|
|
|
|
|
|
|
find_package(LibIntl)
|
|
|
|
if(LibIntl_FOUND)
|
2014-05-15 04:21:13 -07:00
|
|
|
include_directories(SYSTEM ${LibIntl_INCLUDE_DIR})
|
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)
|
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
|
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)
|
2014-09-16 10:12:58 -07:00
|
|
|
set(LUA_DEPENDENCIES lpeg MessagePack bit)
|
2014-07-11 04:12:18 -07:00
|
|
|
if(NOT LUA_PRG)
|
|
|
|
foreach(CURRENT_LUA_PRG luajit lua)
|
|
|
|
# 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)
|
|
|
|
message(FATAL_ERROR "A suitable Lua interpreter was not found")
|
2014-04-13 03:06:35 -07:00
|
|
|
endif()
|
|
|
|
|
2014-07-11 04:12:10 -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.
|
2014-03-03 08:09:06 -07:00
|
|
|
find_program(BUSTED_PRG busted)
|
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)
|
|
|
|
set(BUSTED_OUTPUT_TYPE "utfTerminal")
|
|
|
|
endif()
|
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
|
|
|
# Setup make.
|
2014-03-03 08:09:06 -07:00
|
|
|
find_program(MAKE_PRG NAMES gmake make)
|
|
|
|
if(MAKE_PRG)
|
|
|
|
execute_process(
|
|
|
|
COMMAND "${MAKE_PRG}" --version
|
|
|
|
OUTPUT_VARIABLE MAKE_VERSION_INFO)
|
|
|
|
if(NOT "${OUTPUT_VARIABLE}" MATCHES ".*GNU.*")
|
|
|
|
unset(MAKE_PRG)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if(NOT MAKE_PRG)
|
|
|
|
message(FATAL_ERROR "GNU Make is required to build the dependencies.")
|
|
|
|
else()
|
|
|
|
message(STATUS "Found GNU Make at ${MAKE_PRG}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# When using make, use the $(MAKE) variable to avoid warnings about the job
|
|
|
|
# server.
|
|
|
|
if(CMAKE_GENERATOR MATCHES "Makefiles")
|
|
|
|
set(MAKE_PRG "$(MAKE)")
|
|
|
|
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
|
|
|
# CMake is painful here. It will create the destination using the user's
|
|
|
|
# current umask, and we don't want that. And we don't just want to install
|
|
|
|
# the target directory, as it will mess with existing permissions. So this
|
|
|
|
# seems like the best compromise. If we create it, then everyone can see it.
|
|
|
|
# If it's preexisting, leave it alone.
|
|
|
|
include(InstallHelpers)
|
|
|
|
|
|
|
|
install_helper(
|
|
|
|
DIRECTORY runtime
|
|
|
|
DESTINATION share/nvim)
|
|
|
|
|
|
|
|
file(GLOB_RECURSE RUNTIME_PROGRAMS
|
|
|
|
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
runtime/*.pl runtime/*.awk runtime/*.sh
|
|
|
|
runtime/tools/ref
|
|
|
|
runtime/tools/vimm)
|
|
|
|
|
|
|
|
foreach(PROG ${RUNTIME_PROGRAMS})
|
|
|
|
get_filename_component(BASEDIR ${PROG} PATH)
|
|
|
|
install_helper(PROGRAMS ${PROG} DESTINATION share/nvim/${BASEDIR})
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
install(SCRIPT ${CMAKE_MODULE_PATH}/GenerateHelptags.cmake)
|
|
|
|
|
|
|
|
# Unfortunately, the below does not work under Ninja. Ninja doesn't use a
|
|
|
|
# pseudo-tty when launching processes, because it can put many jobs in parallel
|
|
|
|
# and eat-up all the available pseudo-ttys. Unfortunately, that doesn't work
|
|
|
|
# well with the legacy tests. I have a branch that converts them to run under
|
|
|
|
# CTest, but it needs a little more work.
|
|
|
|
# add_custom_target(test
|
|
|
|
# COMMAND ${MAKE_PRG} -C ${CMAKE_CURRENT_SOURCE_DIR}/src/nvim/testdir
|
|
|
|
# VIMPROG=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/nvim)
|
|
|
|
|
|
|
|
# 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(config)
|
|
|
|
add_subdirectory(src/nvim)
|
|
|
|
add_subdirectory(test/includes)
|
|
|
|
|
|
|
|
# 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()
|
2014-04-30 02:10:37 -07:00
|
|
|
get_target_property(TEST_LIBNVIM_PATH nvim-test LOCATION)
|
|
|
|
|
|
|
|
configure_file(
|
|
|
|
test/config/paths.lua.in
|
|
|
|
${CMAKE_BINARY_DIR}/test/config/paths.lua)
|
|
|
|
|
2014-03-22 04:14:55 -07:00
|
|
|
add_custom_target(unittest
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
-DBUSTED_PRG=${BUSTED_PRG}
|
2014-04-14 12:46:16 -07:00
|
|
|
-DLUA_PRG=${LUA_PRG}
|
2014-03-22 04:14:55 -07:00
|
|
|
-DWORKING_DIR=${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
-DBUSTED_OUTPUT_TYPE=${BUSTED_OUTPUT_TYPE}
|
|
|
|
-DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
|
2014-04-30 02:10:37 -07:00
|
|
|
-DBUILD_DIR=${CMAKE_BINARY_DIR}
|
2014-09-29 05:43:52 -07:00
|
|
|
-DTEST_TYPE=unit
|
|
|
|
-P ${CMAKE_MODULE_PATH}/RunTests.cmake
|
2014-03-22 04:14:55 -07:00
|
|
|
DEPENDS nvim-test unittest-headers)
|
2014-09-29 05:43:52 -07:00
|
|
|
|
|
|
|
add_custom_target(test
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
2014-10-08 08:56:28 -07:00
|
|
|
-DBUSTED_PRG=${BUSTED_PRG}
|
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
|
|
|
|
-P ${CMAKE_MODULE_PATH}/RunTests.cmake
|
|
|
|
DEPENDS nvim)
|
2014-03-22 04:14:55 -07:00
|
|
|
endif()
|