2014-03-03 10:09:06 -05:00
|
|
|
# This is not meant to be included by the top-level.
|
2023-10-14 07:12:48 -04:00
|
|
|
cmake_minimum_required (VERSION 3.13)
|
2019-07-15 16:27:29 -04:00
|
|
|
project(NVIM_DEPS C)
|
2015-03-20 15:31:39 -04:00
|
|
|
|
2022-09-29 15:46:14 -04:00
|
|
|
if(POLICY CMP0135)
|
|
|
|
cmake_policy(SET CMP0135 NEW)
|
|
|
|
endif()
|
|
|
|
|
2015-03-09 09:24:21 -04:00
|
|
|
# Point CMake at any custom modules we may ship
|
2019-06-25 11:34:28 -04:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" "${PROJECT_SOURCE_DIR}/../cmake")
|
2014-03-03 10:09:06 -05:00
|
|
|
|
2022-09-06 10:52:39 -04:00
|
|
|
include(CheckCCompilerFlag)
|
2023-11-07 03:52:20 -05:00
|
|
|
include(ExternalProject)
|
2023-11-06 11:34:54 -05:00
|
|
|
include(FindPackageHandleStandardArgs)
|
2023-05-13 06:12:29 -04:00
|
|
|
|
2023-05-18 10:27:47 -04:00
|
|
|
include(Deps)
|
2023-10-18 16:41:26 -04:00
|
|
|
include(Find)
|
2023-10-26 16:30:00 -04:00
|
|
|
include(Util)
|
2022-09-06 10:52:39 -04:00
|
|
|
|
2024-03-18 08:29:24 -04:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
# User settings
|
|
|
|
#-------------------------------------------------------------------------------
|
2022-08-05 18:20:10 -04:00
|
|
|
|
2024-03-18 08:29:24 -04:00
|
|
|
set(DEPS_IGNORE_SHA FALSE)
|
2014-03-03 10:09:06 -05:00
|
|
|
|
2024-03-18 08:29:24 -04:00
|
|
|
# Options
|
2014-05-31 10:24:02 -04:00
|
|
|
option(USE_BUNDLED "Use bundled dependencies." ON)
|
|
|
|
|
|
|
|
option(USE_BUNDLED_LIBUV "Use the bundled libuv." ${USE_BUNDLED})
|
2023-04-20 07:19:38 -04:00
|
|
|
option(USE_BUNDLED_LPEG "Use the bundled lpeg." ${USE_BUNDLED})
|
2024-01-18 03:14:48 -05:00
|
|
|
# PUC Lua is only used for tests, unless explicitly requested.
|
2016-03-06 22:42:49 -05:00
|
|
|
option(USE_BUNDLED_LUA "Use the bundled version of lua." OFF)
|
2023-11-24 07:28:15 -05: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 05:25:22 -04:00
|
|
|
option(USE_BUNDLED_TS "Use the bundled treesitter runtime." ${USE_BUNDLED})
|
2023-11-24 07:28:15 -05: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 11:04:58 -04:00
|
|
|
option(USE_BUNDLED_UTF8PROC "Use the bundled utf8proc library." ${USE_BUNDLED})
|
2024-04-19 11:04:57 -04:00
|
|
|
|
2018-03-24 12:58:32 -04:00
|
|
|
if(USE_BUNDLED AND MSVC)
|
|
|
|
option(USE_BUNDLED_GETTEXT "Use the bundled version of gettext." ON)
|
2018-06-06 21:39:17 -04:00
|
|
|
option(USE_BUNDLED_LIBICONV "Use the bundled version of libiconv." ON)
|
2018-03-24 12:58:32 -04:00
|
|
|
else()
|
|
|
|
option(USE_BUNDLED_GETTEXT "Use the bundled version of gettext." OFF)
|
2018-06-06 21:39:17 -04:00
|
|
|
option(USE_BUNDLED_LIBICONV "Use the bundled version of libiconv." OFF)
|
2018-03-24 12:58:32 -04:00
|
|
|
endif()
|
|
|
|
|
2024-04-19 11:04:57 -04: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 09:14:38 -04:00
|
|
|
option(USE_EXISTING_SRC_DIR "Skip download of deps sources in case of existing source directory." OFF)
|
|
|
|
|
2024-03-18 08:29:24 -04: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 10:10:59 -04: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 16:50:43 -05:00
|
|
|
if(APPLE)
|
2022-07-19 10:10:59 -04: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 17:48:46 -05:00
|
|
|
message(STATUS "Using deployment target ${CMAKE_OSX_DEPLOYMENT_TARGET}")
|
2022-07-19 10:10:59 -04:00
|
|
|
endif()
|
|
|
|
|
2024-01-01 07:08:56 -05: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 18:38:41 -04:00
|
|
|
if(USE_BUNDLED_UNIBILIUM)
|
|
|
|
include(BuildUnibilium)
|
2014-12-01 17:46:11 -05:00
|
|
|
endif()
|
|
|
|
|
2014-03-03 10:09:06 -05:00
|
|
|
if(USE_BUNDLED_LIBUV)
|
2015-03-09 09:24:21 -04:00
|
|
|
include(BuildLibuv)
|
2014-03-03 10:09:06 -05:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(USE_BUNDLED_LUAJIT)
|
2015-03-09 09:24:21 -04:00
|
|
|
include(BuildLuajit)
|
2014-03-03 10:09:06 -05:00
|
|
|
endif()
|
|
|
|
|
2022-06-12 18:11:14 -04:00
|
|
|
if(USE_BUNDLED_LUA)
|
2016-03-06 22:42:49 -05:00
|
|
|
include(BuildLua)
|
|
|
|
endif()
|
|
|
|
|
2016-04-10 22:49:23 -04:00
|
|
|
if(USE_BUNDLED_LUV)
|
|
|
|
include(BuildLuv)
|
|
|
|
endif()
|
|
|
|
|
2023-04-20 07:19:38 -04:00
|
|
|
if(USE_BUNDLED_LPEG)
|
|
|
|
include(BuildLpeg)
|
|
|
|
endif()
|
|
|
|
|
2018-03-24 12:58:32 -04:00
|
|
|
if(USE_BUNDLED_GETTEXT)
|
|
|
|
include(BuildGettext)
|
|
|
|
endif()
|
|
|
|
|
2018-06-06 21:39:17 -04:00
|
|
|
if(USE_BUNDLED_LIBICONV)
|
|
|
|
include(BuildLibiconv)
|
|
|
|
endif()
|
|
|
|
|
2020-01-31 17:40:02 -05:00
|
|
|
if(USE_BUNDLED_TS_PARSERS)
|
|
|
|
include(BuildTreesitterParsers)
|
|
|
|
endif()
|
|
|
|
|
2024-04-19 11:04:57 -04:00
|
|
|
if(USE_BUNDLED_WASMTIME)
|
|
|
|
include(BuildWasmtime)
|
|
|
|
endif()
|
|
|
|
|
2020-09-17 05:25:22 -04:00
|
|
|
if(USE_BUNDLED_TS)
|
|
|
|
include(BuildTreesitter)
|
|
|
|
endif()
|
|
|
|
|
2024-06-12 11:04:58 -04:00
|
|
|
if(USE_BUNDLED_UTF8PROC)
|
|
|
|
include(BuildUTF8proc)
|
|
|
|
endif()
|
|
|
|
|
2015-12-18 20:30:29 -05:00
|
|
|
if(WIN32)
|
2019-07-22 14:50:30 -04:00
|
|
|
include(GetBinaryDeps)
|
|
|
|
|
2023-03-23 03:37:00 -04:00
|
|
|
GetExecutable(TARGET cat)
|
|
|
|
GetExecutable(TARGET tee)
|
|
|
|
GetExecutable(TARGET xxd)
|
2017-02-09 18:53:36 -05:00
|
|
|
|
2022-09-14 06:20:10 -04:00
|
|
|
GetBinaryDep(TARGET win32yank_X86_64
|
2023-03-05 09:21:46 -05:00
|
|
|
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy win32yank.exe ${DEPS_BIN_DIR})
|
2015-12-18 20:30:29 -05:00
|
|
|
endif()
|