Home Explore Blog CI



neovim

2nd chunk of `cmake.deps/CMakeLists.txt`
4efb300aa4b2e88ae4416a8b8b2d32d648171abc43af3e290000000100000d17
 unibilium." ${USE_BUNDLED})
option(USE_BUNDLED_UTF8PROC "Use the bundled utf8proc library." ${USE_BUNDLED})

if(USE_BUNDLED AND MSVC)
  option(USE_BUNDLED_GETTEXT "Use the bundled version of gettext." ON)
  option(USE_BUNDLED_LIBICONV "Use the bundled version of libiconv." ON)
else()
  option(USE_BUNDLED_GETTEXT "Use the bundled version of gettext." OFF)
  option(USE_BUNDLED_LIBICONV "Use the bundled version of libiconv." OFF)
endif()

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()

option(USE_EXISTING_SRC_DIR "Skip download of deps sources in case of existing source directory." OFF)

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")

# 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.
if(APPLE)
  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(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()

if(USE_BUNDLED_UNIBILIUM)
  include(BuildUnibilium)
endif()

if(USE_BUNDLED_LIBUV)
  include(BuildLibuv)
endif()

if(USE_BUNDLED_LUAJIT)
  include(BuildLuajit)
endif()

if(USE_BUNDLED_LUA)
  include(BuildLua)
endif()

if(USE_BUNDLED_LUV)
  include(BuildLuv)
endif()

if(USE_BUNDLED_LPEG)
  include(BuildLpeg)
endif()

if(USE_BUNDLED_GETTEXT)
  include(BuildGettext)
endif()

if(USE_BUNDLED_LIBICONV)
  include(BuildLibiconv)
endif()

if(USE_BUNDLED_TS_PARSERS)
  include(BuildTreesitterParsers)
endif()

if(USE_BUNDLED_WASMTIME)
  include(BuildWasmtime)
endif()

if(USE_BUNDLED_TS)
  include(BuildTreesitter)
endif()

if(USE_BUNDLED_UTF8PROC)
  include(BuildUTF8proc)
endif()

if(WIN32)
  include(GetBinaryDeps)

  GetExecutable(TARGET xxd)

  GetBinaryDep(TARGET win32yank_X86_64
    INSTALL_COMMAND ${CMAKE_COMMAND} -E copy win32yank.exe ${DEPS_BIN_DIR})
endif()

Title: CMake Script: Dependency Configuration and Build Instructions
Summary
This section configures various dependency options, including whether to use bundled versions of libraries. It sets compiler flags, macOS deployment target, and determines the Lua engine to use (LuaJit or Lua). Based on the bundled options, it includes specific build files for unibilium, libuv, luajit, lua, luv, lpeg, gettext, libiconv, treesitter parsers, wasmtime, treesitter, and utf8proc. It also includes platform-specific handling for Windows, including fetching binary dependencies like xxd and win32yank.