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