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-01-31 06:39:15 -07:00
|
|
|
set(NEOVIM_VERSION_MAJOR 0)
|
|
|
|
set(NEOVIM_VERSION_MINOR 0)
|
|
|
|
set(NEOVIM_VERSION_PATCH 0)
|
|
|
|
|
|
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
|
2014-03-13 08:11:03 -07:00
|
|
|
add_definitions(-Werror -Wall -Wextra -pedantic -Wno-unused-parameter -std=gnu99)
|
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-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)
|
|
|
|
include_directories(${LIBUV_INCLUDE_DIRS})
|
|
|
|
|
2014-04-10 11:39:34 -07:00
|
|
|
find_package(Msgpack REQUIRED)
|
|
|
|
include_directories(${MSGPACK_INCLUDE_DIRS})
|
|
|
|
|
2014-04-03 12:00:43 -07:00
|
|
|
find_package(LuaJit REQUIRED)
|
|
|
|
include_directories(${LUAJIT_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
find_package(LibIntl)
|
|
|
|
if(LibIntl_FOUND)
|
|
|
|
include_directories(${LibIntl_INCLUDE_DIR})
|
|
|
|
endif()
|
|
|
|
|
2014-02-24 11:52:12 -07:00
|
|
|
# Determine platform's threading library. Set CMAKE_THREAD_PREFER_PTHREAD
|
|
|
|
# explicitly to indicate a strong preference for pthread. It is an error to not
|
|
|
|
# have pthread installed even if, for example, the Win32 threading API is found.
|
|
|
|
set(CMAKE_THREAD_PREFER_PTHREAD ON)
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
if(NOT CMAKE_USE_PTHREADS_INIT)
|
|
|
|
message(SEND_ERROR "The pthread library must be installed on your system.")
|
|
|
|
endif(NOT CMAKE_USE_PTHREADS_INIT)
|
|
|
|
|
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-04-12 13:34:56 -07:00
|
|
|
find_program(LUA_PRG luajit)
|
|
|
|
|
|
|
|
# Need a lua interpreter for running the msgapck metadata/dispatch generator
|
|
|
|
if(NOT EXISTS ${LUA_PRG})
|
|
|
|
find_program(LUA_PRG lua)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(EXISTS ${LUA_PRG})
|
|
|
|
message(STATUS "Using the lua interpreter ${LUA_PRG}")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "A lua interpreter is required for building the Neovim")
|
|
|
|
endif()
|
|
|
|
|
2014-01-31 06:39:15 -07:00
|
|
|
add_subdirectory(config)
|
2014-02-23 06:48:03 -07:00
|
|
|
add_subdirectory(src)
|
2014-03-03 08:09:06 -07:00
|
|
|
add_subdirectory(test/includes)
|
|
|
|
|
|
|
|
find_program(BUSTED_PRG busted)
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
if(NOT BUSTED_OUTPUT_TYPE)
|
|
|
|
set(BUSTED_OUTPUT_TYPE "utf_terminal")
|
|
|
|
endif()
|
|
|
|
|
2014-03-22 04:14:55 -07:00
|
|
|
if(BUSTED_PRG)
|
|
|
|
get_target_property(NVIM_TEST_LIB nvim-test LOCATION)
|
|
|
|
add_custom_target(unittest
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
-DBUSTED_PRG=${BUSTED_PRG}
|
|
|
|
-DLUAJIT_PRG=${LUAJIT_PRG}
|
|
|
|
-DWORKING_DIR=${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
-DNVIM_TEST_LIB=${NVIM_TEST_LIB}
|
|
|
|
-DBUSTED_OUTPUT_TYPE=${BUSTED_OUTPUT_TYPE}
|
|
|
|
-DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
|
|
|
|
-DTEST_INCLUDES=${CMAKE_BINARY_DIR}/test/includes/post
|
|
|
|
-P ${CMAKE_MODULE_PATH}/RunUnittests.cmake
|
|
|
|
DEPENDS nvim-test unittest-headers)
|
|
|
|
endif()
|
2014-03-03 08:09:06 -07:00
|
|
|
|
|
|
|
# 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/testdir
|
|
|
|
# VIMPROG=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/nvim)
|