Files
neovim/CMakeLists.txt
T
Justin M. Keyes 4b35336f6f NVIM v0.12.2
Following is a list of commits (fixes/features only) in this release.
See `:help news` in Nvim for release notes.

BREAKING
--------------------------------------------------------------------------------
- c76bbd0a54 diagnostics: restore `is_pull` namespace argument #38698
- 0a3add979a vim.pos: require `buf` param on vim.pos, vim.range #38665

REVERTED CHANGES
--------------------------------------------------------------------------------
- 5920a1d07f "fix(lsp): only resolve LSP configs once" #38990

BUILD
--------------------------------------------------------------------------------
- 26bcffda6c gen_char_blob.lua: "bad argument to format" if path contains "%" #39274

FEATURES
--------------------------------------------------------------------------------
- e767b4843b editor: ZR performs :restart #38967
- 6b86f5520d connect: filepath completion #38959
- ceaa8b648a filetype: `vim.filetype.inspect()` returns copy of registry
- 78234f2d54 vim.version: add __eq to vim.VersionRange #38881

FIXES
--------------------------------------------------------------------------------
- a7214c0719 don't make path empty when truncating trailing slashes (#38844)
- b3b5674ac7 :restart: --listen reusage on windows #39281
- 3e0ece4cde :restart: avoid ERR/WRN logging on Windows with --listen (#39287)
- eaa8cff0bd api: expose fg_indexed/bg_indexed in nvim_get_hl (#39240)
- 8669e34bba api: nvim_clear_autocmds() "event" type check
- 4053141cb3 api: nvim_get_hl drops groups defined with link_global #38492
- 319c031820 channel: fix Ctrl-C handling regression in terminal
- ba3de79ccb cmd: ++p, ++edit should match "word" boundary #39146
- c6c348471d cmdline: 'inccommand' preview after setcmdline() #38795
- 9e1c542b55 cmdline: avoid 'incsearch' recursion after redraw #39303
- 4a18c05f87 cmdline: avoid Ex-mode NULL cmdline_block event #39043
- e4dc08da1a completion: update CursorColumn during completion (#39159)
- 25170ca02d diagnostic: virtual_lines should anchor at end_lnum, not lnum #38701
- 6cb5012e36 difftool: ensure standardized locale for diff output parsing #38853
- 9966afbc9d drawline: hang while redrawing diff filler above fold #39219
- 1ebb9b16d2 eval: crash on some NULL ptr deref #39182
- 6ae6cf5d61 float: don't unload 'hidden' float buffer with :close! (#39304)
- d86d9759e5 gf: handle local `file:` URI paths #38915
- 11a4a0077c health: recognize Zig build optimization levels #38804
- 36bade7efb highlight: preserve inherited colors when update=true breaks links #38750
- 7ffee0dfbf lsp: apply_text_edits causes unwanted BufDelete events #38778
- df726644b8 lsp: check filetype registry in health (#38885)
- 18b1ff81a3 lsp: check stale context in hover/signature callback #38724
- fe09c71c34 lsp: send didOpen on save to all clients+groups #37454
- 34cbfeca9c lsp: show CompletionItem.detail in info popup #38904
- 6250019537 lsp: show_document can't position cursor past EOL in insert-mode #38566
- 5907307662 lsp: skip codelens refresh redraw for deleted buffer #39193
- 9aadbed770 lua: make `vim._with()` work with `buf=0` and `win=0` context #39151
- 0039785724 lua: make vim.deep_equal cycle-safe
- 53038d2c38 lua: not obvious which _meta/ files are generated #39035
- f2a5c90cbc marks: adjust marks when unloading "nofile" buffer #39118
- a358b9be64 message: flush messages before "empty" msg_show #38854
- 1b36b75832 messages: truncate warning messages only in display (#38901)
- f7e3cf127c move: avoid integer overflow with large 'scrolloff' (#39251)
- 452a9b895c normal: pass count to 'keywordprg' as arg1 #38965
- 4d4e196447 options: default 'titlestring' shows CWD #39233
- 6583833ee2 pack: GIT_DIR/GIT_WORK_TREE env vars may interfere #39279
- df3d7e36d0 pack: make 'stash' call compatible with older Git #38679
- 1a5d41a48f pack: more advice for out-of-sync lockfile #38931
- ca0e3818c0 pum: crash with 'pumborder' and wide item (#38852)
- 38be4475c6 pum: info float width grows on reselect with 'linebreak' #38680
- eee2d10fd2 rpc: trigger UILeave earlier on channel close (#38846)
- 898ccbc68a smoothscroll: crash when resizing to textoff with showbreak
- 5ac95da8ea statusline: no window-local highlights for last line 'ruler' #38879
- ffb0ebb752 substitute: don't crash with very large count (#39272)
- abcc5342ee terminal: do not reflow altscreen on resize #39024
- d3ef77639a terminal: forward streamed bracketed paste properly (#39152)
- 111c7f434e treesitter: TSNode:id() with NUL byte causes unreliable select()  #39134
- 2ea9ed32e4 treesitter: restore highlighting on 32 bit systems #39091
- c294bc397b tui: check background color on resume
- b08c289a45 ui2: dialog paging is inconsistent #39128
- c6b5eb30de ui2: don't dismiss expanded messages for non-typed key #39247
- c6578ea28b vim.filetype: match() fails if g:ft_ignore_pat is not defined #39158
- a15e27fbcf vim.pos: Range:intersect() drops `buf` #38898

VIM PATCHES
--------------------------------------------------------------------------------
- 27214645f6 450895d: runtime(make): fix wrong highlighting with $ inside double quotes (#39177)
- 891c6c9150 8.2.2440: documentation based on patches is outdated (#39144)
- e203257fff 9.2.0331: spellfile: stack buffer overflows in spell file generation (#38948)
- 8ba79b4601 9.2.0345: Wrong autoformatting with 'autocomplete' (#39060)
- 9c11229832 9.2.0357: [security]: command injection via backticks in tag files (#39102)
- 5153006747 9.2.0364: tests: test_smoothscroll_textoff_showbreak() fails
- 187a34d59b 9.2.0380: completion: a few issues in completion code (#39264)
- 15d824e5d6 9.2.0385: Integer overflow with "ze" and large 'sidescrolloff' (#39289)
- 19a54ad964 e666597: runtime(doc): make window option description a bit less vague (#39173)
- d672f0f494 partial:9.2.0348: potential buffer underrun when setting statusline like option (#39063)

OTHER
--------------------------------------------------------------------------------
- ed47b27ad4 feat(api): rename buffer to buf (#38899)
- 570d8fd128 feat(api): rename buffer to buf in retval #39015
- 15991abaa7 feat(events): trigger MarkSet autocmd in :delmarks (#39218)
- b6a3ad3979 fix(ui2): ensure msg window is visible after closing tab (#39245)
- 099489b985 refactor: update usages of deprecated "buffer" param #39090
- 55d3d1bbeb test(lsp): extract buf/util parts from lsp_spec.lua (#39170)
2026-04-22 16:05:55 +02:00

388 lines
14 KiB
CMake

# CMAKE REFERENCE
# - intro: https://codingnest.com/basic-cmake/
# - best practices (3.0+): https://gist.github.com/mbinna/c61dbb39bca0e4fb7d1f73b0d66a4fd1
# - pitfalls: https://izzys.casa/2019/02/everything-you-never-wanted-to-know-about-cmake/
# - troubleshooting:
# - variable_watch https://cmake.org/cmake/help/latest/command/variable_watch.html
# - verbose output: cmake --build build --verbose
# Version should match the tested CMAKE_URL in .github/workflows/build.yml.
cmake_minimum_required(VERSION 3.16)
project(nvim C)
if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()
if(XCODE)
message(FATAL_ERROR [[Xcode generator is not supported. Use "Ninja" or "Unix Makefiles" instead]])
endif()
# Point CMake at any custom modules we may ship
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
include(CheckCCompilerFlag)
include(CheckCSourceCompiles)
include(CheckLibraryExists)
include(ExternalProject)
include(FindPackageHandleStandardArgs)
include(GNUInstallDirs)
include(Deps)
include(Find)
include(InstallHelpers)
include(PreventInTreeBuilds)
include(Util)
if(NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
# Auto-create a .gitignore in the specified "build" directory.
file(GENERATE OUTPUT .gitignore CONTENT "*")
endif()
#-------------------------------------------------------------------------------
# User settings
#-------------------------------------------------------------------------------
set(DEPS_IGNORE_SHA FALSE)
#-------------------------------------------------------------------------------
# Variables
#-------------------------------------------------------------------------------
set(FUNCS_DATA ${PROJECT_BINARY_DIR}/funcs_data.mpack)
set(TOUCHES_DIR ${PROJECT_BINARY_DIR}/touches)
set(VTERM_TEST_FILE ${PROJECT_BINARY_DIR}/test/vterm_test_output)
file(GLOB DOCFILES CONFIGURE_DEPENDS ${PROJECT_SOURCE_DIR}/runtime/doc/*.txt)
if(NOT CI_BUILD)
set(CMAKE_INSTALL_MESSAGE NEVER)
endif()
if(${CMAKE_VERSION} VERSION_LESS 3.20)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
endif()
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.26)
set(COPY_DIRECTORY copy_directory_if_different)
else()
set(COPY_DIRECTORY copy_directory)
endif()
# Prefer our bundled versions of dependencies.
if(DEFINED ENV{DEPS_BUILD_DIR})
set(DEPS_PREFIX "$ENV{DEPS_BUILD_DIR}/usr" CACHE PATH "Path prefix for finding dependencies")
else()
set(DEPS_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/.deps/usr" CACHE PATH "Path prefix for finding dependencies")
# When running from within CLion or Visual Studio,
# build bundled dependencies automatically.
if(NOT EXISTS ${DEPS_PREFIX}
AND (DEFINED ENV{CLION_IDE}
OR DEFINED ENV{VisualStudioEdition}))
message(STATUS "Building dependencies...")
set(DEPS_BUILD_DIR ${PROJECT_BINARY_DIR}/.deps)
file(MAKE_DIRECTORY ${DEPS_BUILD_DIR})
execute_process(
COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR}
-D CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-D CMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-D CMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-D CMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}
-D CMAKE_C_FLAGS_MINSIZEREL=${CMAKE_C_FLAGS_MINSIZEREL}
-D CMAKE_C_FLAGS_RELWITHDEBINFO=${CMAKE_C_FLAGS_RELWITHDEBINFO}
-D CMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}
-D CMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
${PROJECT_SOURCE_DIR}/cmake.deps
WORKING_DIRECTORY ${DEPS_BUILD_DIR})
execute_process(
COMMAND ${CMAKE_COMMAND} --build ${DEPS_BUILD_DIR}
--config ${CMAKE_BUILD_TYPE})
set(DEPS_PREFIX ${DEPS_BUILD_DIR}/usr)
endif()
endif()
list(INSERT CMAKE_PREFIX_PATH 0 ${DEPS_PREFIX})
if(APPLE)
# If the macOS deployment target is not set manually (via $MACOSX_DEPLOYMENT_TARGET),
# fall back to local system version. Needs to be done both here and in cmake.deps.
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()
if(WIN32 OR APPLE)
# Handle case-insensitive filenames for Windows and Mac.
set(CASE_INSENSITIVE_FILENAME TRUE)
endif()
if (MINGW)
# Disable LTO by default as it may not compile
# See https://github.com/Alexpux/MINGW-packages/issues/3516
# and https://github.com/neovim/neovim/pull/8654#issuecomment-402316672
option(ENABLE_LTO "enable link time optimization" OFF)
else()
option(ENABLE_LTO "enable link time optimization" ON)
endif()
option(ENABLE_LIBINTL "enable libintl" ON)
option(ENABLE_UNIBILIUM "enable unibilium" ON)
option(ENABLE_WASMTIME "enable wasmtime" OFF)
message(STATUS "CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}")
set_default_buildtype(Debug)
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT isMultiConfig)
# Unlike build dependencies in cmake.deps, we want dev dependencies such as
# Uncrustify to always be built with Release.
list(APPEND DEPS_CMAKE_ARGS -D CMAKE_BUILD_TYPE=Release)
endif()
# If not in a git repo (e.g., a tarball) these tokens define the complete
# version string, else they are combined with the result of `git describe`.
set(NVIM_VERSION_MAJOR 0)
set(NVIM_VERSION_MINOR 12)
set(NVIM_VERSION_PATCH 2)
set(NVIM_VERSION_PRERELEASE "") # for package maintainers
# API level
set(NVIM_API_LEVEL 14) # Bump this after any API/stdlib change.
set(NVIM_API_LEVEL_COMPAT 0) # Adjust this after a _breaking_ API change.
set(NVIM_API_PRERELEASE false)
# We _want_ assertions in RelWithDebInfo build-type.
if(CMAKE_C_FLAGS_RELWITHDEBINFO MATCHES DNDEBUG)
string(REPLACE "-DNDEBUG" "-DRELDEBUG" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
string(REPLACE "/DNDEBUG" "/DRELDEBUG" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
string(REPLACE " " " " CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}") # Remove duplicate whitespace
endif()
option(ENABLE_ASAN_UBSAN "Enable Clang address & undefined behavior sanitizer for nvim binary." OFF)
option(ENABLE_MSAN "Enable Clang memory sanitizer for nvim binary." OFF)
# TSAN exists to test Luv threads.
option(ENABLE_TSAN "Enable Clang thread sanitizer for nvim binary." OFF)
if((ENABLE_ASAN_UBSAN AND ENABLE_MSAN)
OR (ENABLE_ASAN_UBSAN AND ENABLE_TSAN)
OR (ENABLE_MSAN AND ENABLE_TSAN))
message(FATAL_ERROR "Sanitizers cannot be enabled simultaneously")
endif()
# Place targets in bin/ or lib/ for all build configurations
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
foreach(CFGNAME ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${CFGNAME} CFGNAME)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFGNAME} ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFGNAME} ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFGNAME} ${CMAKE_BINARY_DIR}/lib)
endforeach()
if(NOT PREFER_LUA)
find_program(LUA_PRG NAMES luajit)
endif()
find_program(LUA_PRG NAMES lua5.1 lua5.2 lua)
mark_as_advanced(LUA_PRG)
if(NOT LUA_PRG)
message(FATAL_ERROR "Failed to find a Lua 5.1-compatible interpreter")
endif()
message(STATUS "Using Lua interpreter: ${LUA_PRG}")
# Some of the code generation still relies on stable table ordering in order to
# produce reproducible output - specifically the msgpack'ed data in
# funcs_metadata.generated.h and ui_events_metadata.generated.h. This should
# ideally be fixed in the generators, but until then as a workaround you may provide
# a specific lua implementation that provides the needed stability by setting LUA_GEN_PRG:
if(NOT LUA_GEN_PRG)
set(LUA_GEN_PRG "${LUA_PRG}" CACHE FILEPATH "Path to the lua used for code generation.")
endif()
mark_as_advanced(LUA_GEN_PRG)
message(STATUS "Using Lua interpreter for code generation: ${LUA_GEN_PRG}")
option(COMPILE_LUA "Pre-compile Lua sources into bytecode (for sources that are included in the binary)" ON)
if(COMPILE_LUA AND NOT WIN32)
if(PREFER_LUA)
foreach(CURRENT_LUAC_PRG luac5.1 luac)
find_program(_CHECK_LUAC_PRG ${CURRENT_LUAC_PRG})
if(_CHECK_LUAC_PRG)
# Escape "%" for string.format() (in gen_char_blob.lua). #39271
string(REPLACE "%" "%%" _LUAC_PRG_ESCAPED "${_CHECK_LUAC_PRG}")
set(LUAC_PRG "${_LUAC_PRG_ESCAPED} -s -o - %q" CACHE STRING "Format for compiling to Lua bytecode")
break()
endif()
endforeach()
elseif(LUA_PRG MATCHES "luajit")
check_lua_module(${LUA_PRG} "jit.bcsave" LUAJIT_HAS_JIT_BCSAVE)
if(LUAJIT_HAS_JIT_BCSAVE)
# Escape "%" for string.format() (in gen_char_blob.lua). #39271
string(REPLACE "%" "%%" _LUA_PRG_ESCAPED "${LUA_PRG}")
set(LUAC_PRG "${_LUA_PRG_ESCAPED} -b -s %q -" CACHE STRING "Format for compiling to Lua bytecode")
endif()
endif()
endif()
mark_as_advanced(LUAC_PRG)
if(LUAC_PRG)
message(STATUS "Using Lua compiler: ${LUAC_PRG}")
endif()
# Lint
option(CI_LINT "Abort if lint programs not found" OFF)
if(CI_LINT)
set(LINT_REQUIRED "REQUIRED")
endif()
find_program(SHELLCHECK_PRG shellcheck ${LINT_REQUIRED})
mark_as_advanced(SHELLCHECK_PRG)
find_program(STYLUA_PRG stylua ${LINT_REQUIRED})
mark_as_advanced(STYLUA_PRG)
find_program(TS_QUERY_LS_PRG ts_query_ls ${LINT_REQUIRED})
mark_as_advanced(TS_QUERY_LS_PRG)
set(STYLUA_DIRS runtime scripts src test contrib)
add_glob_target(
TARGET lintlua-stylua
COMMAND ${STYLUA_PRG}
FLAGS --color=always --check --respect-ignores
GLOB_DIRS ${STYLUA_DIRS}
GLOB_PAT *.lua
TOUCH_STRATEGY PER_DIR)
# Special handling of some files (which are ignored in .styluaignore).
# Workaround because stylua doesn't(?) support file-specific settings.
add_custom_target(lintlua-stylua2
COMMAND ${STYLUA_PRG} --config-path "${PROJECT_SOURCE_DIR}/.stylua2.toml"
--color=always --check
"${PROJECT_SOURCE_DIR}/test/functional/ui/decorations_spec.lua"
"${PROJECT_SOURCE_DIR}/test/functional/ui/float_spec.lua"
"${PROJECT_SOURCE_DIR}/test/functional/ui/multigrid_spec.lua"
)
add_dependencies(lintlua-stylua lintlua-stylua2)
add_custom_target(lintlua)
add_dependencies(lintlua lintlua-stylua)
add_glob_target(
TARGET lintsh
COMMAND ${SHELLCHECK_PRG}
FLAGS -x -a
GLOB_DIRS scripts
GLOB_PAT *.sh
TOUCH_STRATEGY PER_DIR)
add_custom_target(lintquery-compilation
COMMAND ${TS_QUERY_LS_PRG}
check ${PROJECT_SOURCE_DIR}/runtime/queries --config
'{"parser_install_directories": ["${DEPS_PREFIX}/lib/nvim/parser"]}')
add_custom_target(lintquery-format
COMMAND ${TS_QUERY_LS_PRG}
format ${PROJECT_SOURCE_DIR}/runtime/queries --check)
add_custom_target(lintquery)
add_dependencies(lintquery lintquery-compilation lintquery-format)
add_custom_target(lintcommit
COMMAND $<TARGET_FILE:nvim_bin> --clean -l ${PROJECT_SOURCE_DIR}/scripts/lintcommit.lua main)
add_dependencies(lintcommit nvim_bin)
add_custom_target(linterrcodes
COMMAND $<TARGET_FILE:nvim_bin> --clean -l ${PROJECT_SOURCE_DIR}/scripts/linterrcodes.lua
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
add_dependencies(linterrcodes nvim_bin)
add_custom_target(lint)
add_dependencies(lint lintc lintlua lintsh lintquery)
# Format
add_glob_target(
TARGET formatlua
COMMAND ${STYLUA_PRG}
FLAGS --respect-ignores
GLOB_DIRS ${STYLUA_DIRS}
GLOB_PAT *.lua
TOUCH_STRATEGY PER_DIR)
# Special handling of some files (which are ignored in .styluaignore).
# Workaround because stylua doesn't(?) support file-specific settings.
add_custom_target(formatlua2
COMMAND ${STYLUA_PRG} --config-path "${PROJECT_SOURCE_DIR}/.stylua2.toml"
"${PROJECT_SOURCE_DIR}/test/functional/ui/decorations_spec.lua"
"${PROJECT_SOURCE_DIR}/test/functional/ui/float_spec.lua"
"${PROJECT_SOURCE_DIR}/test/functional/ui/multigrid_spec.lua"
)
add_dependencies(formatlua formatlua2)
add_custom_target(formatquery
COMMAND ${TS_QUERY_LS_PRG}
format ${PROJECT_SOURCE_DIR}/runtime/queries)
add_custom_target(format)
add_dependencies(format formatc formatlua formatquery)
install_helper(
FILES ${CMAKE_SOURCE_DIR}/src/man/nvim.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
add_custom_target(nvim ALL)
add_dependencies(nvim nvim_bin nvim_runtime_deps nvim_runtime)
add_subdirectory(src/nvim)
add_subdirectory(src/tee)
add_subdirectory(src/xxd)
add_subdirectory(cmake.config)
add_subdirectory(runtime)
add_subdirectory(test)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/cmake/UninstallHelper.cmake)
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(cmake.packaging)
endif()
get_externalproject_options(uncrustify ${DEPS_IGNORE_SHA})
ExternalProject_Add(uncrustify
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/uncrustify
CMAKE_ARGS ${DEPS_CMAKE_ARGS}
-D CMAKE_RUNTIME_OUTPUT_DIRECTORY=${DEPS_BIN_DIR}
-D CMAKE_SKIP_RPATH=true
EXCLUDE_FROM_ALL TRUE
${EXTERNALPROJECT_OPTIONS})
if (CMAKE_SYSTEM_PROCESSOR MATCHES "arm|aarch")
set(LUALS_ARCH arm64)
else()
set(LUALS_ARCH x64)
endif()
set(LUALS_VERSION 3.15.0)
set(LUALS "lua-language-server-${LUALS_VERSION}-${CMAKE_SYSTEM_NAME}-${LUALS_ARCH}")
set(LUALS_TARBALL ${LUALS}.tar.gz)
set(LUALS_URL https://github.com/LuaLS/lua-language-server/releases/download/${LUALS_VERSION}/${LUALS_TARBALL})
ExternalProject_Add(download_luals
URL ${LUALS_URL}
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/luals
SOURCE_DIR ${DEPS_BIN_DIR}/luals
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
EXCLUDE_FROM_ALL TRUE
DOWNLOAD_NO_PROGRESS TRUE
CMAKE_CACHE_ARGS ${DEPS_CMAKE_CACHE_ARGS})
file(GLOB_RECURSE LUAFILES runtime/*.lua)
add_target(luals
COMMAND ${DEPS_BIN_DIR}/luals/bin/lua-language-server
--configpath=${PROJECT_SOURCE_DIR}/.luarc.json
--check=${PROJECT_SOURCE_DIR}/runtime
--checklevel=Hint
DEPENDS ${LUAFILES}
CUSTOM_COMMAND_ARGS USES_TERMINAL)
add_dependencies(luals download_luals)