2014-03-03 08:09:06 -07:00
|
|
|
# This is not meant to be included by the top-level.
|
2024-09-22 08:00:38 -07:00
|
|
|
cmake_minimum_required(VERSION 3.16)
|
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)
|
2023-11-07 01:52:20 -07:00
|
|
|
include(ExternalProject)
|
2023-11-06 09:34:54 -07:00
|
|
|
include(FindPackageHandleStandardArgs)
|
2023-05-13 03:12:29 -07:00
|
|
|
|
2023-05-18 07:27:47 -07:00
|
|
|
include(Deps)
|
2023-10-18 13:41:26 -07:00
|
|
|
include(Find)
|
2023-10-26 13:30:00 -07:00
|
|
|
include(Util)
|
2022-09-06 07:52:39 -07:00
|
|
|
|
2024-03-18 05:29:24 -07:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# User settings
|
|
|
|
#-------------------------------------------------------------------------------
|
2022-08-05 15:20:10 -07:00
|
|
|
|
2024-03-18 05:29:24 -07:00
|
|
|
set(DEPS_IGNORE_SHA FALSE)
|
2014-03-03 08:09:06 -07:00
|
|
|
|
2024-03-18 05:29:24 -07:00
|
|
|
# Options
|
2014-05-31 07:24:02 -07:00
|
|
|
option(USE_BUNDLED "Use bundled dependencies." ON)
|
|
|
|
|
|
|
|
option(USE_BUNDLED_LIBUV "Use the bundled libuv." ${USE_BUNDLED})
|
2023-04-20 04:19:38 -07:00
|
|
|
option(USE_BUNDLED_LPEG "Use the bundled lpeg." ${USE_BUNDLED})
|
2024-01-18 01:14:48 -07:00
|
|
|
# PUC Lua is only used for tests, unless explicitly requested.
|
2016-03-06 20:42:49 -07:00
|
|
|
option(USE_BUNDLED_LUA "Use the bundled version of lua." OFF)
|
2023-11-24 05:28:15 -07:00
|
|
|
option(USE_BUNDLED_LUAJIT "Use the bundled version of luajit." ${USE_BUNDLED})
|
|
|
|
option(USE_BUNDLED_LUV "Use the bundled version of luv." ${USE_BUNDLED})
|
2020-09-17 02:25:22 -07:00
|
|
|
option(USE_BUNDLED_TS "Use the bundled treesitter runtime." ${USE_BUNDLED})
|
2023-11-24 05:28:15 -07:00
|
|
|
option(USE_BUNDLED_TS_PARSERS "Use the bundled treesitter parsers." ${USE_BUNDLED})
|
|
|
|
option(USE_BUNDLED_UNIBILIUM "Use the bundled unibilium." ${USE_BUNDLED})
|
2024-06-12 08:04:58 -07:00
|
|
|
option(USE_BUNDLED_UTF8PROC "Use the bundled utf8proc library." ${USE_BUNDLED})
|
2024-04-19 08:04:57 -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()
|
|
|
|
|
2024-04-19 08:04:57 -07:00
|
|
|
option(ENABLE_WASMTIME "Use treesitter with wasmtime support." OFF)
|
|
|
|
if(ENABLE_WASMTIME)
|
|
|
|
if(USE_BUNDLED)
|
|
|
|
option(USE_BUNDLED_WASMTIME "Use the bundled wasmtime." ON)
|
|
|
|
else()
|
|
|
|
option(USE_BUNDLED_WASMTIME "Use the bundled wasmtime." OFF)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if(NOT ENABLE_WASMTIME AND USE_BUNDLED_WASMTIME)
|
|
|
|
message(FATAL_ERROR "ENABLE_WASMTIME is set to OFF while USE_BUNDLED_WASMTIME is set to ON.\
|
|
|
|
You need set ENABLE_WASMTIME to ON if you want to use wasmtime.")
|
|
|
|
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)
|
|
|
|
|
2024-03-18 05:29:24 -07:00
|
|
|
set_default_buildtype(Release)
|
|
|
|
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_INCLUDE_FLAGS "-I${DEPS_INSTALL_DIR}/include -I${DEPS_INSTALL_DIR}/include/luajit-2.1")
|
|
|
|
|
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()
|
|
|
|
|
2024-01-01 05:08:56 -07:00
|
|
|
if(USE_BUNDLED_LUAJIT)
|
|
|
|
set(LUA_ENGINE LuaJit)
|
|
|
|
elseif(USE_BUNDLED_LUA)
|
|
|
|
set(LUA_ENGINE Lua)
|
|
|
|
else()
|
|
|
|
find_package(Luajit)
|
|
|
|
find_package(Lua 5.1 EXACT)
|
|
|
|
if(LUAJIT_FOUND)
|
|
|
|
set(LUA_ENGINE LuaJit)
|
|
|
|
string(APPEND DEPS_INCLUDE_FLAGS " -I${LUAJIT_INCLUDE_DIR}")
|
|
|
|
elseif(LUA_FOUND)
|
|
|
|
set(LUA_ENGINE Lua)
|
|
|
|
string(APPEND DEPS_INCLUDE_FLAGS " -I${LUA_INCLUDE_DIR}")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Could not find system lua or luajit")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2015-03-10 15:38:41 -07:00
|
|
|
if(USE_BUNDLED_UNIBILIUM)
|
|
|
|
include(BuildUnibilium)
|
2014-12-01 15:46:11 -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()
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
2024-04-19 08:04:57 -07:00
|
|
|
if(USE_BUNDLED_WASMTIME)
|
|
|
|
include(BuildWasmtime)
|
|
|
|
endif()
|
|
|
|
|
2020-09-17 02:25:22 -07:00
|
|
|
if(USE_BUNDLED_TS)
|
|
|
|
include(BuildTreesitter)
|
|
|
|
endif()
|
|
|
|
|
2024-06-12 08:04:58 -07:00
|
|
|
if(USE_BUNDLED_UTF8PROC)
|
|
|
|
include(BuildUTF8proc)
|
|
|
|
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()
|