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
|
|
|
|
2023-05-13 03:12:29 -07:00
|
|
|
include(ExternalProject)
|
2022-09-06 07:52:39 -07:00
|
|
|
include(CheckCCompilerFlag)
|
2023-05-13 03:12:29 -07:00
|
|
|
|
2023-05-18 07:27:47 -07:00
|
|
|
include(Deps)
|
2022-09-06 07:52:39 -07:00
|
|
|
include(Util)
|
|
|
|
|
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-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
|
|
|
|
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})
|
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()
|
|
|
|
|
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()
|
|
|
|
|
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()
|
|
|
|
|
2023-05-11 11:17:15 -07:00
|
|
|
set_directory_properties(PROPERTIES
|
|
|
|
EP_PREFIX "${DEPS_BUILD_DIR}"
|
|
|
|
CMAKE_CONFIGURE_DEPENDS deps.txt)
|
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)
|
2023-05-11 11:17:15 -07:00
|
|
|
if(NOT ${name})
|
2023-05-22 16:24:36 -07:00
|
|
|
# _URL variables must NOT be set when USE_EXISTING_SRC_DIR is set,
|
|
|
|
# otherwise ExternalProject will try to re-download the sources.
|
|
|
|
if(NOT USE_EXISTING_SRC_DIR)
|
|
|
|
set(${name} ${value})
|
|
|
|
endif()
|
2023-04-30 22:52:23 -07:00
|
|
|
endif()
|
|
|
|
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()
|
|
|
|
|
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
|
|
|
|
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()
|