2014-03-03 08:09:06 -07:00
|
|
|
# This is not meant to be included by the top-level.
|
2022-07-19 04:01:41 -07:00
|
|
|
cmake_minimum_required (VERSION 3.10)
|
2019-07-15 13:27:29 -07:00
|
|
|
project(NVIM_DEPS C)
|
2015-03-20 12:31:39 -07:00
|
|
|
|
2022-09-29 12:46:14 -07:00
|
|
|
if(POLICY CMP0135)
|
|
|
|
cmake_policy(SET CMP0135 NEW)
|
|
|
|
endif()
|
|
|
|
|
2015-03-09 06:24:21 -07:00
|
|
|
# Point CMake at any custom modules we may ship
|
2019-06-25 08:34:28 -07:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" "${PROJECT_SOURCE_DIR}/../cmake")
|
2014-03-03 08:09:06 -07:00
|
|
|
|
2022-09-06 07:52:39 -07:00
|
|
|
include(CheckCCompilerFlag)
|
|
|
|
include(Util)
|
|
|
|
|
2023-01-25 06:36:17 -07:00
|
|
|
set(DEPS_CMAKE_ARGS
|
2023-02-08 03:00:16 -07:00
|
|
|
-D CMAKE_C_COMPILER=${CMAKE_C_COMPILER}
|
2023-03-24 02:22:15 -07:00
|
|
|
-D CMAKE_C_STANDARD=99
|
2023-02-08 03:00:16 -07:00
|
|
|
-D CMAKE_GENERATOR=${CMAKE_GENERATOR}
|
|
|
|
-D CMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
|
2023-04-09 11:31:13 -07:00
|
|
|
-D CMAKE_POSITION_INDEPENDENT_CODE=ON
|
|
|
|
-D CMAKE_FIND_FRAMEWORK=${CMAKE_FIND_FRAMEWORK})
|
2023-01-25 06:36:17 -07:00
|
|
|
|
|
|
|
set(DEPS_CMAKE_CACHE_ARGS -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES})
|
|
|
|
|
2023-01-20 15:48:46 -07:00
|
|
|
set_default_buildtype()
|
|
|
|
|
2022-08-05 15:20:10 -07:00
|
|
|
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
|
|
|
if(NOT isMultiConfig)
|
2023-02-08 03:00:16 -07:00
|
|
|
list(APPEND DEPS_CMAKE_ARGS -D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
|
2022-08-05 15:20:10 -07:00
|
|
|
endif()
|
|
|
|
|
2018-03-01 02:23:21 -07:00
|
|
|
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()
|
|
|
|
|
2023-03-10 14:40:41 -07:00
|
|
|
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")
|
2023-04-20 04:19:38 -07:00
|
|
|
set(DEPS_INCLUDE_FLAGS "-I${DEPS_INSTALL_DIR}/include -I${DEPS_INSTALL_DIR}/include/luajit-2.1")
|
2014-03-03 08:09:06 -07:00
|
|
|
|
2023-02-26 14:32:08 -07:00
|
|
|
list(APPEND DEPS_CMAKE_ARGS -D CMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR})
|
|
|
|
|
2014-05-31 07:24:02 -07:00
|
|
|
option(USE_BUNDLED "Use bundled dependencies." ON)
|
|
|
|
|
2015-03-10 15:38:41 -07:00
|
|
|
option(USE_BUNDLED_UNIBILIUM "Use the bundled unibilium." ${USE_BUNDLED})
|
2014-12-01 15:46:11 -07:00
|
|
|
option(USE_BUNDLED_LIBTERMKEY "Use the bundled libtermkey." ${USE_BUNDLED})
|
2015-02-28 06:41:53 -07:00
|
|
|
option(USE_BUNDLED_LIBVTERM "Use the bundled libvterm." ${USE_BUNDLED})
|
2014-05-31 07:24:02 -07:00
|
|
|
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})
|
2016-04-10 19:49:23 -07:00
|
|
|
option(USE_BUNDLED_LUV "Use the bundled version of luv." ${USE_BUNDLED})
|
2023-04-20 04:19:38 -07:00
|
|
|
option(USE_BUNDLED_LPEG "Use the bundled lpeg." ${USE_BUNDLED})
|
2023-02-20 00:12:59 -07:00
|
|
|
#XXX(tarruda): Lua is only used for debugging the functional test client, don't
|
2016-03-06 20:42:49 -07:00
|
|
|
# build it unless explicitly requested
|
|
|
|
option(USE_BUNDLED_LUA "Use the bundled version of lua." OFF)
|
2020-01-31 15:40:02 -07:00
|
|
|
option(USE_BUNDLED_TS_PARSERS "Use the bundled treesitter parsers." ${USE_BUNDLED})
|
2020-09-17 02:25:22 -07:00
|
|
|
option(USE_BUNDLED_TS "Use the bundled treesitter runtime." ${USE_BUNDLED})
|
2014-03-03 08:09:06 -07:00
|
|
|
|
2018-03-24 09:58:32 -07:00
|
|
|
if(USE_BUNDLED AND MSVC)
|
|
|
|
option(USE_BUNDLED_GETTEXT "Use the bundled version of gettext." ON)
|
2018-06-06 18:39:17 -07:00
|
|
|
option(USE_BUNDLED_LIBICONV "Use the bundled version of libiconv." ON)
|
2018-03-24 09:58:32 -07:00
|
|
|
else()
|
|
|
|
option(USE_BUNDLED_GETTEXT "Use the bundled version of gettext." OFF)
|
2018-06-06 18:39:17 -07:00
|
|
|
option(USE_BUNDLED_LIBICONV "Use the bundled version of libiconv." OFF)
|
2018-03-24 09:58:32 -07:00
|
|
|
endif()
|
|
|
|
|
2023-02-08 02:08:18 -07:00
|
|
|
if(WIN32)
|
|
|
|
option(USE_BUNDLED_NVIMQT "Bundle neovim-qt" ON)
|
|
|
|
endif()
|
|
|
|
|
2022-10-06 06:14:38 -07:00
|
|
|
option(USE_EXISTING_SRC_DIR "Skip download of deps sources in case of existing source directory." OFF)
|
|
|
|
|
2022-08-12 08:59:40 -07:00
|
|
|
find_package(Git)
|
|
|
|
if(NOT Git_FOUND)
|
|
|
|
message(FATAL_ERROR "Git is required to apply patches.")
|
2018-03-06 19:38:10 -07:00
|
|
|
endif()
|
|
|
|
|
2014-11-05 17:41:14 -07:00
|
|
|
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}")
|
2014-03-03 08:09:06 -07:00
|
|
|
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()
|
|
|
|
|
2022-05-17 06:08:24 -07:00
|
|
|
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()
|
|
|
|
|
2022-09-11 04:39:49 -07:00
|
|
|
set(DEPS_C_COMPILER "${CMAKE_C_COMPILER}")
|
2014-03-03 08:09:06 -07:00
|
|
|
|
2018-10-15 17:52:04 -07:00
|
|
|
if(CMAKE_OSX_SYSROOT)
|
|
|
|
set(DEPS_C_COMPILER "${DEPS_C_COMPILER} -isysroot${CMAKE_OSX_SYSROOT}")
|
|
|
|
endif()
|
|
|
|
|
2022-06-24 08:43:11 -07:00
|
|
|
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()
|
|
|
|
|
2022-07-19 07:10:59 -07:00
|
|
|
# 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.
|
2023-03-02 14:50:43 -07:00
|
|
|
if(APPLE)
|
2022-07-19 07:10:59 -07:00
|
|
|
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()
|
2023-01-20 15:48:46 -07:00
|
|
|
message(STATUS "Using deployment target ${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
2022-07-19 07:10:59 -07:00
|
|
|
endif()
|
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
include(ExternalProject)
|
2022-10-01 05:54:58 -07:00
|
|
|
set_directory_properties(PROPERTIES EP_PREFIX "${DEPS_BUILD_DIR}")
|
2014-03-03 08:09:06 -07:00
|
|
|
|
2023-05-02 15:31:07 -07:00
|
|
|
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 "")
|
2023-03-03 16:30:07 -07:00
|
|
|
endif()
|
2023-05-02 15:31:07 -07:00
|
|
|
elseif(name MATCHES "^.*SHA256$")
|
|
|
|
set(${name} ${value})
|
2023-04-30 22:52:23 -07:00
|
|
|
endif()
|
2023-05-02 15:31:07 -07:00
|
|
|
|
2023-04-30 22:52:23 -07:00
|
|
|
endforeach()
|
2023-03-03 16:30:07 -07:00
|
|
|
|
2015-03-10 15:38:41 -07:00
|
|
|
if(USE_BUNDLED_UNIBILIUM)
|
|
|
|
include(BuildUnibilium)
|
2014-12-01 15:46:11 -07:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_BUNDLED_LIBTERMKEY)
|
2015-03-09 06:24:21 -07:00
|
|
|
include(BuildLibtermkey)
|
2019-07-04 06:17:59 -07:00
|
|
|
if(USE_BUNDLED_UNIBILIUM)
|
|
|
|
add_dependencies(libtermkey unibilium)
|
|
|
|
endif()
|
2014-12-01 15:46:11 -07:00
|
|
|
endif()
|
|
|
|
|
2015-02-28 06:41:53 -07:00
|
|
|
if(USE_BUNDLED_LIBVTERM)
|
2015-03-09 06:24:21 -07:00
|
|
|
include(BuildLibvterm)
|
2015-02-28 06:41:53 -07:00
|
|
|
endif()
|
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
if(USE_BUNDLED_LIBUV)
|
2015-03-09 06:24:21 -07:00
|
|
|
include(BuildLibuv)
|
2014-03-03 08:09:06 -07:00
|
|
|
endif()
|
|
|
|
|
2014-04-10 11:47:13 -07:00
|
|
|
if(USE_BUNDLED_MSGPACK)
|
2015-03-09 06:24:21 -07:00
|
|
|
include(BuildMsgpack)
|
2014-04-10 11:47:13 -07:00
|
|
|
endif()
|
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
if(USE_BUNDLED_LUAJIT)
|
2015-03-09 06:24:21 -07:00
|
|
|
include(BuildLuajit)
|
2014-03-03 08:09:06 -07:00
|
|
|
endif()
|
|
|
|
|
2022-06-12 15:11:14 -07:00
|
|
|
if(USE_BUNDLED_LUA)
|
2016-03-06 20:42:49 -07:00
|
|
|
include(BuildLua)
|
|
|
|
endif()
|
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
if(USE_BUNDLED_LUAROCKS)
|
2015-03-09 06:24:21 -07:00
|
|
|
include(BuildLuarocks)
|
2014-03-03 08:09:06 -07:00
|
|
|
endif()
|
|
|
|
|
2016-04-10 19:49:23 -07:00
|
|
|
if(USE_BUNDLED_LUV)
|
|
|
|
include(BuildLuv)
|
|
|
|
endif()
|
|
|
|
|
2023-04-20 04:19:38 -07:00
|
|
|
if(USE_BUNDLED_LPEG)
|
|
|
|
include(BuildLpeg)
|
|
|
|
endif()
|
|
|
|
|
2018-03-24 09:58:32 -07:00
|
|
|
if(USE_BUNDLED_GETTEXT)
|
|
|
|
include(BuildGettext)
|
|
|
|
endif()
|
|
|
|
|
2018-06-06 18:39:17 -07:00
|
|
|
if(USE_BUNDLED_LIBICONV)
|
|
|
|
include(BuildLibiconv)
|
|
|
|
endif()
|
|
|
|
|
2020-01-31 15:40:02 -07:00
|
|
|
if(USE_BUNDLED_TS_PARSERS)
|
|
|
|
include(BuildTreesitterParsers)
|
|
|
|
endif()
|
|
|
|
|
2020-09-17 02:25:22 -07:00
|
|
|
if(USE_BUNDLED_TS)
|
|
|
|
include(BuildTreesitter)
|
|
|
|
endif()
|
|
|
|
|
2015-12-18 18:30:29 -07:00
|
|
|
if(WIN32)
|
2019-07-22 11:50:30 -07:00
|
|
|
include(GetBinaryDeps)
|
|
|
|
|
2023-03-23 00:37:00 -07:00
|
|
|
GetExecutable(TARGET cat)
|
|
|
|
GetExecutable(TARGET tee)
|
|
|
|
GetExecutable(TARGET xxd)
|
2017-02-09 16:53:36 -07:00
|
|
|
|
2023-02-08 02:08:18 -07:00
|
|
|
if(USE_BUNDLED_NVIMQT)
|
|
|
|
GetBinaryDep(TARGET wingui
|
2023-03-05 07:21:46 -07:00
|
|
|
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory bin ${DEPS_BIN_DIR}
|
2018-05-20 09:50:07 -07:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_directory share ${DEPS_INSTALL_DIR}/share)
|
2023-02-08 02:08:18 -07:00
|
|
|
endif()
|
2017-02-15 10:13:49 -07:00
|
|
|
|
2022-09-14 03:20:10 -07:00
|
|
|
GetBinaryDep(TARGET win32yank_X86_64
|
2023-03-05 07:21:46 -07:00
|
|
|
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy win32yank.exe ${DEPS_BIN_DIR})
|
2015-12-18 18:30:29 -07:00
|
|
|
endif()
|