mirror of
https://github.com/neovim/neovim.git
synced 2024-12-23 20:55:18 -07:00
9909668111
The cmake.deps build will read this file and set the left part of the text as the variable name and the right part as the variable value. The benefit of doing this is that it becomes much easier to parse which dependencies are required, as well as to bump dependencies with scripts/bump_deps.lua. Adjust bump_deps.lua script to work with this new format.
231 lines
6.6 KiB
CMake
231 lines
6.6 KiB
CMake
# This is not meant to be included by the top-level.
|
|
cmake_minimum_required (VERSION 3.10)
|
|
project(NVIM_DEPS C)
|
|
|
|
if(POLICY CMP0135)
|
|
cmake_policy(SET CMP0135 NEW)
|
|
endif()
|
|
|
|
# Point CMake at any custom modules we may ship
|
|
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" "${PROJECT_SOURCE_DIR}/../cmake")
|
|
|
|
include(CheckCCompilerFlag)
|
|
include(Util)
|
|
|
|
set(DEPS_CMAKE_ARGS
|
|
-D CMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
|
-D CMAKE_C_STANDARD=99
|
|
-D CMAKE_GENERATOR=${CMAKE_GENERATOR}
|
|
-D CMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
|
|
-D CMAKE_POSITION_INDEPENDENT_CODE=ON
|
|
-D CMAKE_FIND_FRAMEWORK=${CMAKE_FIND_FRAMEWORK})
|
|
|
|
set(DEPS_CMAKE_CACHE_ARGS -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES})
|
|
|
|
set_default_buildtype()
|
|
|
|
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
|
if(NOT isMultiConfig)
|
|
list(APPEND DEPS_CMAKE_ARGS -D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
|
|
endif()
|
|
|
|
set(DEFAULT_MAKE_CFLAGS CFLAGS+=-g)
|
|
|
|
check_c_compiler_flag(-Og HAS_OG_FLAG)
|
|
if(HAS_OG_FLAG)
|
|
set(DEFAULT_MAKE_CFLAGS CFLAGS+=-Og ${DEFAULT_MAKE_CFLAGS})
|
|
endif()
|
|
|
|
set(DEPS_INSTALL_DIR "${CMAKE_BINARY_DIR}/usr")
|
|
set(DEPS_BIN_DIR "${DEPS_INSTALL_DIR}/bin")
|
|
set(DEPS_LIB_DIR "${DEPS_INSTALL_DIR}/lib")
|
|
set(DEPS_BUILD_DIR "${CMAKE_BINARY_DIR}/build")
|
|
set(DEPS_DOWNLOAD_DIR "${DEPS_BUILD_DIR}/downloads")
|
|
set(DEPS_INCLUDE_FLAGS "-I${DEPS_INSTALL_DIR}/include -I${DEPS_INSTALL_DIR}/include/luajit-2.1")
|
|
|
|
list(APPEND DEPS_CMAKE_ARGS -D CMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR})
|
|
|
|
option(USE_BUNDLED "Use bundled dependencies." ON)
|
|
|
|
option(USE_BUNDLED_UNIBILIUM "Use the bundled unibilium." ${USE_BUNDLED})
|
|
option(USE_BUNDLED_LIBTERMKEY "Use the bundled libtermkey." ${USE_BUNDLED})
|
|
option(USE_BUNDLED_LIBVTERM "Use the bundled libvterm." ${USE_BUNDLED})
|
|
option(USE_BUNDLED_LIBUV "Use the bundled libuv." ${USE_BUNDLED})
|
|
option(USE_BUNDLED_MSGPACK "Use the bundled msgpack." ${USE_BUNDLED})
|
|
option(USE_BUNDLED_LUAJIT "Use the bundled version of luajit." ${USE_BUNDLED})
|
|
option(USE_BUNDLED_LUAROCKS "Use the bundled version of luarocks." ${USE_BUNDLED})
|
|
option(USE_BUNDLED_LUV "Use the bundled version of luv." ${USE_BUNDLED})
|
|
option(USE_BUNDLED_LPEG "Use the bundled lpeg." ${USE_BUNDLED})
|
|
#XXX(tarruda): Lua is only used for debugging the functional test client, don't
|
|
# build it unless explicitly requested
|
|
option(USE_BUNDLED_LUA "Use the bundled version of lua." OFF)
|
|
option(USE_BUNDLED_TS_PARSERS "Use the bundled treesitter parsers." ${USE_BUNDLED})
|
|
option(USE_BUNDLED_TS "Use the bundled treesitter runtime." ${USE_BUNDLED})
|
|
|
|
if(USE_BUNDLED AND MSVC)
|
|
option(USE_BUNDLED_GETTEXT "Use the bundled version of gettext." ON)
|
|
option(USE_BUNDLED_LIBICONV "Use the bundled version of libiconv." ON)
|
|
else()
|
|
option(USE_BUNDLED_GETTEXT "Use the bundled version of gettext." OFF)
|
|
option(USE_BUNDLED_LIBICONV "Use the bundled version of libiconv." OFF)
|
|
endif()
|
|
|
|
if(WIN32)
|
|
option(USE_BUNDLED_NVIMQT "Bundle neovim-qt" ON)
|
|
endif()
|
|
|
|
option(USE_EXISTING_SRC_DIR "Skip download of deps sources in case of existing source directory." OFF)
|
|
|
|
find_package(Git)
|
|
if(NOT Git_FOUND)
|
|
message(FATAL_ERROR "Git is required to apply patches.")
|
|
endif()
|
|
|
|
if(UNIX)
|
|
find_program(MAKE_PRG NAMES gmake make)
|
|
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()
|
|
endif()
|
|
|
|
# When using make, use the $(MAKE) variable to avoid warning about the job
|
|
# server.
|
|
if(CMAKE_GENERATOR MATCHES "Makefiles")
|
|
set(MAKE_PRG "$(MAKE)")
|
|
endif()
|
|
|
|
if(MINGW AND CMAKE_GENERATOR MATCHES "Ninja")
|
|
find_program(MAKE_PRG NAMES mingw32-make)
|
|
if(NOT MAKE_PRG)
|
|
message(FATAL_ERROR "GNU Make for mingw32 is required to build the dependencies.")
|
|
else()
|
|
message(STATUS "Found GNU Make for mingw32: ${MAKE_PRG}")
|
|
endif()
|
|
endif()
|
|
|
|
set(DEPS_C_COMPILER "${CMAKE_C_COMPILER}")
|
|
|
|
if(CMAKE_OSX_SYSROOT)
|
|
set(DEPS_C_COMPILER "${DEPS_C_COMPILER} -isysroot${CMAKE_OSX_SYSROOT}")
|
|
endif()
|
|
|
|
if(CMAKE_OSX_ARCHITECTURES)
|
|
# The LuaJIT build does not like being passed multiple `-arch` flags
|
|
# so we handle a universal build the old-fashioned way.
|
|
set(LUAJIT_C_COMPILER "${DEPS_C_COMPILER}")
|
|
foreach(ARCH IN LISTS CMAKE_OSX_ARCHITECTURES)
|
|
set(DEPS_C_COMPILER "${DEPS_C_COMPILER} -arch ${ARCH}")
|
|
endforeach()
|
|
endif()
|
|
|
|
# If the macOS deployment target is not set manually (via $MACOSX_DEPLOYMENT_TARGET),
|
|
# fall back to local system version. Needs to be done here and in top-level CMakeLists.txt.
|
|
if(APPLE)
|
|
if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
|
|
execute_process(COMMAND sw_vers -productVersion
|
|
OUTPUT_VARIABLE MACOS_VERSION
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
|
set(CMAKE_OSX_DEPLOYMENT_TARGET "${MACOS_VERSION}")
|
|
endif()
|
|
message(STATUS "Using deployment target ${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
|
endif()
|
|
|
|
include(ExternalProject)
|
|
set_directory_properties(PROPERTIES EP_PREFIX "${DEPS_BUILD_DIR}")
|
|
|
|
file(READ deps.txt DEPENDENCIES)
|
|
STRING(REGEX REPLACE "\n" ";" DEPENDENCIES "${DEPENDENCIES}")
|
|
foreach(dep ${DEPENDENCIES})
|
|
STRING(REGEX REPLACE " " ";" dep "${dep}")
|
|
list(GET dep 0 name)
|
|
list(GET dep 1 value)
|
|
|
|
if(name MATCHES "^.*URL$")
|
|
mark_as_advanced(${name})
|
|
if(NOT USE_EXISTING_SRC_DIR)
|
|
set(${name} ${value} CACHE STRING "")
|
|
endif()
|
|
elseif(name MATCHES "^.*SHA256$")
|
|
set(${name} ${value})
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
if(USE_BUNDLED_UNIBILIUM)
|
|
include(BuildUnibilium)
|
|
endif()
|
|
|
|
if(USE_BUNDLED_LIBTERMKEY)
|
|
include(BuildLibtermkey)
|
|
if(USE_BUNDLED_UNIBILIUM)
|
|
add_dependencies(libtermkey unibilium)
|
|
endif()
|
|
endif()
|
|
|
|
if(USE_BUNDLED_LIBVTERM)
|
|
include(BuildLibvterm)
|
|
endif()
|
|
|
|
if(USE_BUNDLED_LIBUV)
|
|
include(BuildLibuv)
|
|
endif()
|
|
|
|
if(USE_BUNDLED_MSGPACK)
|
|
include(BuildMsgpack)
|
|
endif()
|
|
|
|
if(USE_BUNDLED_LUAJIT)
|
|
include(BuildLuajit)
|
|
endif()
|
|
|
|
if(USE_BUNDLED_LUA)
|
|
include(BuildLua)
|
|
endif()
|
|
|
|
if(USE_BUNDLED_LUAROCKS)
|
|
include(BuildLuarocks)
|
|
endif()
|
|
|
|
if(USE_BUNDLED_LUV)
|
|
include(BuildLuv)
|
|
endif()
|
|
|
|
if(USE_BUNDLED_LPEG)
|
|
include(BuildLpeg)
|
|
endif()
|
|
|
|
if(USE_BUNDLED_GETTEXT)
|
|
include(BuildGettext)
|
|
endif()
|
|
|
|
if(USE_BUNDLED_LIBICONV)
|
|
include(BuildLibiconv)
|
|
endif()
|
|
|
|
if(USE_BUNDLED_TS_PARSERS)
|
|
include(BuildTreesitterParsers)
|
|
endif()
|
|
|
|
if(USE_BUNDLED_TS)
|
|
include(BuildTreesitter)
|
|
endif()
|
|
|
|
if(WIN32)
|
|
include(GetBinaryDeps)
|
|
|
|
GetExecutable(TARGET cat)
|
|
GetExecutable(TARGET tee)
|
|
GetExecutable(TARGET xxd)
|
|
|
|
if(USE_BUNDLED_NVIMQT)
|
|
GetBinaryDep(TARGET wingui
|
|
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory bin ${DEPS_BIN_DIR}
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory share ${DEPS_INSTALL_DIR}/share)
|
|
endif()
|
|
|
|
GetBinaryDep(TARGET win32yank_X86_64
|
|
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy win32yank.exe ${DEPS_BIN_DIR})
|
|
endif()
|