neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

CMakeLists.txt (4900B)


      1 # This is not meant to be included by the top-level.
      2 cmake_minimum_required(VERSION 3.16)
      3 project(NVIM_DEPS C)
      4 
      5 if(POLICY CMP0135)
      6  cmake_policy(SET CMP0135 NEW)
      7 endif()
      8 
      9 # Point CMake at any custom modules we may ship
     10 list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" "${PROJECT_SOURCE_DIR}/../cmake")
     11 
     12 include(CheckCCompilerFlag)
     13 include(ExternalProject)
     14 include(FindPackageHandleStandardArgs)
     15 
     16 include(Deps)
     17 include(Find)
     18 include(Util)
     19 
     20 #-------------------------------------------------------------------------------
     21 # User settings
     22 #-------------------------------------------------------------------------------
     23 
     24 set(DEPS_IGNORE_SHA FALSE)
     25 
     26 # Options
     27 option(USE_BUNDLED "Use bundled dependencies." ON)
     28 
     29 option(USE_BUNDLED_LIBUV "Use the bundled libuv." ${USE_BUNDLED})
     30 option(USE_BUNDLED_LPEG "Use the bundled lpeg." ${USE_BUNDLED})
     31 # PUC Lua is only used for tests, unless explicitly requested.
     32 option(USE_BUNDLED_LUA "Use the bundled version of lua." OFF)
     33 option(USE_BUNDLED_LUAJIT "Use the bundled version of luajit." ${USE_BUNDLED})
     34 option(USE_BUNDLED_LUV "Use the bundled version of luv." ${USE_BUNDLED})
     35 option(USE_BUNDLED_TS "Use the bundled treesitter runtime." ${USE_BUNDLED})
     36 option(USE_BUNDLED_TS_PARSERS "Use the bundled treesitter parsers." ${USE_BUNDLED})
     37 option(USE_BUNDLED_UNIBILIUM "Use the bundled unibilium." ${USE_BUNDLED})
     38 option(USE_BUNDLED_UTF8PROC "Use the bundled utf8proc library." ${USE_BUNDLED})
     39 
     40 if(USE_BUNDLED AND MSVC)
     41  option(USE_BUNDLED_GETTEXT "Use the bundled version of gettext." ON)
     42  option(USE_BUNDLED_LIBICONV "Use the bundled version of libiconv." ON)
     43 else()
     44  option(USE_BUNDLED_GETTEXT "Use the bundled version of gettext." OFF)
     45  option(USE_BUNDLED_LIBICONV "Use the bundled version of libiconv." OFF)
     46 endif()
     47 
     48 option(ENABLE_WASMTIME "Use treesitter with wasmtime support." OFF)
     49 if(ENABLE_WASMTIME)
     50  if(USE_BUNDLED)
     51    option(USE_BUNDLED_WASMTIME "Use the bundled wasmtime." ON)
     52  else()
     53    option(USE_BUNDLED_WASMTIME "Use the bundled wasmtime." OFF)
     54  endif()
     55 endif()
     56 if(NOT ENABLE_WASMTIME AND USE_BUNDLED_WASMTIME)
     57  message(FATAL_ERROR "ENABLE_WASMTIME is set to OFF while USE_BUNDLED_WASMTIME is set to ON.\
     58  You need set ENABLE_WASMTIME to ON if you want to use wasmtime.")
     59 endif()
     60 
     61 option(USE_EXISTING_SRC_DIR "Skip download of deps sources in case of existing source directory." OFF)
     62 
     63 set_default_buildtype(Release)
     64 get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
     65 
     66 if (NOT DEFINED DEPS_CMAKE_ARGS) 
     67  set(DEPS_CMAKE_ARGS) 
     68 endif() 
     69 
     70 if(NOT isMultiConfig)
     71  list(APPEND DEPS_CMAKE_ARGS -D CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE})
     72 endif()
     73 
     74 set(DEFAULT_MAKE_CFLAGS CFLAGS+=-g)
     75 
     76 check_c_compiler_flag(-Og HAS_OG_FLAG)
     77 if(HAS_OG_FLAG)
     78  set(DEFAULT_MAKE_CFLAGS CFLAGS+=-Og ${DEFAULT_MAKE_CFLAGS})
     79 endif()
     80 
     81 # Always pass the toolchain if it exists
     82 if(CMAKE_TOOLCHAIN_FILE)
     83  list(APPEND DEPS_CMAKE_ARGS
     84    -D CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
     85  )
     86 endif()
     87 
     88 set(DEPS_INCLUDE_FLAGS "-I\"${DEPS_INSTALL_DIR}/include\" -I\"${DEPS_INSTALL_DIR}/include/luajit-2.1\"")
     89 
     90 # If the macOS deployment target is not set manually (via $MACOSX_DEPLOYMENT_TARGET),
     91 # fall back to local system version. Needs to be done here and in top-level CMakeLists.txt.
     92 if(APPLE)
     93  if(NOT CMAKE_OSX_DEPLOYMENT_TARGET)
     94    execute_process(COMMAND sw_vers -productVersion
     95                    OUTPUT_VARIABLE MACOS_VERSION
     96                    OUTPUT_STRIP_TRAILING_WHITESPACE)
     97    set(CMAKE_OSX_DEPLOYMENT_TARGET "${MACOS_VERSION}")
     98  endif()
     99  message(STATUS "Using deployment target ${CMAKE_OSX_DEPLOYMENT_TARGET}")
    100 endif()
    101 
    102 if(USE_BUNDLED_LUAJIT)
    103  set(LUA_ENGINE LuaJit)
    104 elseif(USE_BUNDLED_LUA)
    105  set(LUA_ENGINE Lua)
    106 else()
    107  find_package(Luajit)
    108  find_package(Lua 5.1 EXACT)
    109  if(LUAJIT_FOUND)
    110    set(LUA_ENGINE LuaJit)
    111    string(APPEND DEPS_INCLUDE_FLAGS " -I\"${LUAJIT_INCLUDE_DIR}\"")
    112  elseif(LUA_FOUND)
    113    set(LUA_ENGINE Lua)
    114    string(APPEND DEPS_INCLUDE_FLAGS " -I\"${LUA_INCLUDE_DIR}\"")
    115  else()
    116    message(FATAL_ERROR "Could not find system lua or luajit")
    117  endif()
    118 endif()
    119 
    120 if(USE_BUNDLED_UNIBILIUM)
    121  include(BuildUnibilium)
    122 endif()
    123 
    124 if(USE_BUNDLED_LIBUV)
    125  include(BuildLibuv)
    126 endif()
    127 
    128 if(USE_BUNDLED_LUAJIT)
    129  include(BuildLuajit)
    130 endif()
    131 
    132 if(USE_BUNDLED_LUA)
    133  include(BuildLua)
    134 endif()
    135 
    136 if(USE_BUNDLED_LUV)
    137  include(BuildLuv)
    138 endif()
    139 
    140 if(USE_BUNDLED_LPEG)
    141  include(BuildLpeg)
    142 endif()
    143 
    144 if(USE_BUNDLED_GETTEXT)
    145  include(BuildGettext)
    146 endif()
    147 
    148 if(USE_BUNDLED_LIBICONV)
    149  include(BuildLibiconv)
    150 endif()
    151 
    152 if(USE_BUNDLED_TS_PARSERS)
    153  include(BuildTreesitterParsers)
    154 endif()
    155 
    156 if(USE_BUNDLED_WASMTIME)
    157  include(BuildWasmtime)
    158 endif()
    159 
    160 if(USE_BUNDLED_TS)
    161  include(BuildTreesitter)
    162 endif()
    163 
    164 if(USE_BUNDLED_UTF8PROC)
    165  include(BuildUTF8proc)
    166 endif()
    167 
    168 if(WIN32)
    169  include(GetBinaryDeps)
    170 
    171  GetBinaryDep(TARGET win32yank_X86_64
    172    INSTALL_COMMAND ${CMAKE_COMMAND} -E copy win32yank.exe ${DEPS_BIN_DIR})
    173 endif()