aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-11-30 20:35:25 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-11-30 20:35:25 +0000
commit1b7b916b7631ddf73c38e3a0070d64e4636cb2f3 (patch)
treecd08258054db80bb9a11b1061bb091c70b76926a /cmake
parenteaa89c11d0f8aefbb512de769c6c82f61a8baca3 (diff)
parent4a8bf24ac690004aedf5540fa440e788459e5e34 (diff)
downloadrneovim-aucmd_textputpost.tar.gz
rneovim-aucmd_textputpost.tar.bz2
rneovim-aucmd_textputpost.zip
Merge remote-tracking branch 'upstream/master' into aucmd_textputpostaucmd_textputpost
Diffstat (limited to 'cmake')
-rw-r--r--cmake/CheckUncrustifyVersion.cmake13
-rw-r--r--cmake/ConvertPo.cmake2
-rw-r--r--cmake/Deps.cmake56
-rw-r--r--cmake/Find.cmake39
-rw-r--r--cmake/FindIconv.cmake25
-rw-r--r--cmake/FindLibLUV.cmake32
-rw-r--r--cmake/FindLibTermkey.cmake31
-rw-r--r--cmake/FindLibintl.cmake (renamed from cmake/FindLibIntl.cmake)53
-rw-r--r--cmake/FindLibtermkey.cmake9
-rw-r--r--cmake/FindLibuv.cmake (renamed from cmake/FindLibUV.cmake)40
-rw-r--r--cmake/FindLibvterm.cmake (renamed from cmake/Findlibvterm.cmake)21
-rw-r--r--cmake/FindLpeg.cmake9
-rw-r--r--cmake/FindLuaJit.cmake38
-rw-r--r--cmake/FindLuajit.cmake17
-rw-r--r--cmake/FindLuv.cmake6
-rw-r--r--cmake/FindMsgpack.cmake41
-rw-r--r--cmake/FindTreeSitter.cmake11
-rw-r--r--cmake/FindTreesitter.cmake29
-rw-r--r--cmake/FindUnibilium.cmake11
-rw-r--r--cmake/Findunibilium.cmake27
-rw-r--r--cmake/Format.cmake10
-rw-r--r--cmake/GenerateVersion.cmake7
-rw-r--r--cmake/GetCompileFlags.cmake57
-rw-r--r--cmake/InstallHelpers.cmake12
-rw-r--r--cmake/LibFindMacros.cmake269
-rw-r--r--cmake/LuaHelpers.cmake37
-rw-r--r--cmake/RunTests.cmake24
-rw-r--r--cmake/Util.cmake28
-rw-r--r--cmake/WindowsDllCopy.cmake11
29 files changed, 272 insertions, 693 deletions
diff --git a/cmake/CheckUncrustifyVersion.cmake b/cmake/CheckUncrustifyVersion.cmake
deleted file mode 100644
index 4812c24ace..0000000000
--- a/cmake/CheckUncrustifyVersion.cmake
+++ /dev/null
@@ -1,13 +0,0 @@
-if(UNCRUSTIFY_PRG)
- execute_process(COMMAND uncrustify --version
- OUTPUT_VARIABLE user_version
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- string(REGEX REPLACE "[A-Za-z_#-]" "" user_version ${user_version})
-
- file(STRINGS ${CONFIG_FILE} required_version LIMIT_COUNT 1)
- string(REGEX REPLACE "[A-Za-z_# -]" "" required_version ${required_version})
-
- if(NOT user_version STREQUAL required_version)
- message(FATAL_ERROR "Wrong uncrustify version! Required version is ${required_version} but found ${user_version}")
- endif()
-endif()
diff --git a/cmake/ConvertPo.cmake b/cmake/ConvertPo.cmake
index 2282b96f56..202cd3fbb3 100644
--- a/cmake/ConvertPo.cmake
+++ b/cmake/ConvertPo.cmake
@@ -6,7 +6,7 @@ execute_process(
OUTPUT_VARIABLE trans
ERROR_VARIABLE err
RESULT_VARIABLE res)
-if(NOT res EQUAL 0)
+if(res)
message(FATAL_ERROR "iconv failed to run correctly: ${err}")
endif()
diff --git a/cmake/Deps.cmake b/cmake/Deps.cmake
new file mode 100644
index 0000000000..9966e42084
--- /dev/null
+++ b/cmake/Deps.cmake
@@ -0,0 +1,56 @@
+set(DEPS_INSTALL_DIR "${CMAKE_BINARY_DIR}/usr")
+set(DEPS_BIN_DIR "${DEPS_INSTALL_DIR}/bin")
+set(DEPS_LIB_DIR "${DEPS_INSTALL_DIR}/lib")
+set(DEPS_SHARE_DIR "${DEPS_INSTALL_DIR}/share/lua/5.1")
+
+set(DEPS_BUILD_DIR "${CMAKE_BINARY_DIR}/build")
+set(DEPS_DOWNLOAD_DIR "${DEPS_BUILD_DIR}/downloads")
+
+set(DEPS_CMAKE_ARGS
+ -D CMAKE_C_COMPILER=${CMAKE_C_COMPILER}
+ -D CMAKE_C_STANDARD=99
+ -D CMAKE_GENERATOR=${CMAKE_GENERATOR}
+ -D CMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
+ -D BUILD_SHARED_LIBS=OFF
+ -D CMAKE_POSITION_INDEPENDENT_CODE=ON
+ -D CMAKE_INSTALL_PREFIX=${DEPS_INSTALL_DIR})
+if(APPLE)
+ list(APPEND DEPS_CMAKE_ARGS -D CMAKE_FIND_FRAMEWORK=${CMAKE_FIND_FRAMEWORK})
+endif()
+
+set(DEPS_CMAKE_CACHE_ARGS -DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES})
+set(EXTERNALPROJECT_OPTIONS DOWNLOAD_NO_PROGRESS TRUE)
+
+# MAKE_PRG
+if(UNIX)
+ find_program(MAKE_PRG NAMES gmake make)
+ if(NOT MAKE_PRG)
+ message(FATAL_ERROR "GNU Make is required to build the dependencies.")
+ else()
+ message(STATUS "Found GNU Make at ${MAKE_PRG}")
+ endif()
+endif()
+# When using make, use the $(MAKE) variable to avoid warning about the job
+# server.
+if(CMAKE_GENERATOR MATCHES "Makefiles")
+ set(MAKE_PRG "$(MAKE)")
+endif()
+if(MINGW AND CMAKE_GENERATOR MATCHES "Ninja")
+ find_program(MAKE_PRG NAMES mingw32-make)
+ if(NOT MAKE_PRG)
+ message(FATAL_ERROR "GNU Make for mingw32 is required to build the dependencies.")
+ else()
+ message(STATUS "Found GNU Make for mingw32: ${MAKE_PRG}")
+ endif()
+endif()
+
+# DEPS_C_COMPILER
+set(DEPS_C_COMPILER "${CMAKE_C_COMPILER}")
+if(CMAKE_OSX_SYSROOT)
+ set(DEPS_C_COMPILER "${DEPS_C_COMPILER} -isysroot${CMAKE_OSX_SYSROOT}")
+endif()
+if(CMAKE_OSX_ARCHITECTURES)
+ foreach(ARCH IN LISTS CMAKE_OSX_ARCHITECTURES)
+ set(DEPS_C_COMPILER "${DEPS_C_COMPILER} -arch ${ARCH}")
+ endforeach()
+endif()
diff --git a/cmake/Find.cmake b/cmake/Find.cmake
new file mode 100644
index 0000000000..b363052510
--- /dev/null
+++ b/cmake/Find.cmake
@@ -0,0 +1,39 @@
+# Functions to aid the built-in find_ functions
+
+# Same as find_path, but always search in .deps directory first and then everything else.
+function(find_path2)
+ find_path_nvim(${ARGV})
+ find_path(${ARGV})
+endfunction()
+
+function(find_path_nvim)
+ set(CMAKE_FIND_FRAMEWORK NEVER)
+ set(CMAKE_FIND_APPBUNDLE NEVER)
+ find_path(${ARGV} NO_CMAKE_SYSTEM_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH)
+endfunction()
+
+# Same as find_library, but with the following search order:
+# 1. Only search in .deps directory. Only search for static libraries.
+# 2. Only search in .deps directory. Search all libraries
+# 3. Search everywhere, all libraries
+function(find_library2)
+ find_library_nvim(STATIC ${ARGV})
+ find_library_nvim(${ARGV})
+ find_library(${ARGV})
+endfunction()
+
+function(find_library_nvim)
+ cmake_parse_arguments(ARG
+ "STATIC"
+ ""
+ ""
+ ${ARGN})
+ list(REMOVE_ITEM ARGN STATIC)
+
+ if(ARG_STATIC)
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
+ endif()
+ set(CMAKE_FIND_FRAMEWORK NEVER)
+ set(CMAKE_FIND_APPBUNDLE NEVER)
+ find_library(${ARGN} NO_CMAKE_SYSTEM_PATH NO_CMAKE_ENVIRONMENT_PATH NO_SYSTEM_ENVIRONMENT_PATH)
+endfunction()
diff --git a/cmake/FindIconv.cmake b/cmake/FindIconv.cmake
index 63290fe889..e607c59cf6 100644
--- a/cmake/FindIconv.cmake
+++ b/cmake/FindIconv.cmake
@@ -1,21 +1,14 @@
# TODO(dundargoc): FindIconv is shipped by default on cmake version 3.11+. This
# file can be removed once we decide to upgrade minimum cmake version.
-# - Try to find iconv
-# Once done, this will define
-#
-# Iconv_FOUND - system has iconv
-# Iconv_INCLUDE_DIRS - the iconv include directories
-# Iconv_LIBRARIES - link these to use iconv
-
-include(LibFindMacros)
-
-find_path(ICONV_INCLUDE_DIR NAMES iconv.h)
-find_library(ICONV_LIBRARY NAMES iconv libiconv)
-
-set(Iconv_PROCESS_INCLUDES ICONV_INCLUDE_DIR)
+find_path2(ICONV_INCLUDE_DIR NAMES iconv.h)
+find_library2(ICONV_LIBRARY NAMES iconv libiconv)
+find_package_handle_standard_args(Iconv DEFAULT_MSG
+ ICONV_INCLUDE_DIR)
+mark_as_advanced(ICONV_INCLUDE_DIR ICONV_LIBRARY)
+
+add_library(iconv INTERFACE)
+target_include_directories(iconv SYSTEM BEFORE INTERFACE ${ICONV_INCLUDE_DIR})
if(ICONV_LIBRARY)
- set(Iconv_PROCESS_LIBS ICONV_LIBRARY)
+ target_link_libraries(iconv INTERFACE ${ICONV_LIBRARY})
endif()
-
-libfind_process(Iconv)
diff --git a/cmake/FindLibLUV.cmake b/cmake/FindLibLUV.cmake
deleted file mode 100644
index 23b62b66d3..0000000000
--- a/cmake/FindLibLUV.cmake
+++ /dev/null
@@ -1,32 +0,0 @@
-# - Try to find luv
-# Once done this will define
-# LIBLUV_FOUND - System has libluv
-# LIBLUV_INCLUDE_DIRS - The libluv include directories
-# LIBLUV_LIBRARIES - The libraries needed to use libluv
-
-find_package(PkgConfig)
-if (PKG_CONFIG_FOUND)
- pkg_check_modules(PC_LIBLUV QUIET luv)
-endif()
-
-set(LIBLUV_DEFINITIONS ${PC_LIBLUV_CFLAGS_OTHER})
-
-find_path(LIBLUV_INCLUDE_DIR luv/luv.h
- PATHS ${PC_LIBLUV_INCLUDEDIR} ${PC_LIBLUV_INCLUDE_DIRS})
-
-# Explicitly look for luv.so. #10407
-list(APPEND LIBLUV_NAMES luv_a luv libluv_a luv${CMAKE_SHARED_LIBRARY_SUFFIX})
-
-find_library(LIBLUV_LIBRARY NAMES ${LIBLUV_NAMES}
- HINTS ${PC_LIBLUV_LIBDIR} ${PC_LIBLUV_LIBRARY_DIRS})
-
-set(LIBLUV_LIBRARIES ${LIBLUV_LIBRARY})
-set(LIBLUV_INCLUDE_DIRS ${LIBLUV_INCLUDE_DIR})
-
-include(FindPackageHandleStandardArgs)
-# handle the QUIETLY and REQUIRED arguments and set LIBLUV_FOUND to TRUE
-# if all listed variables are TRUE
-find_package_handle_standard_args(LibLUV DEFAULT_MSG
- LIBLUV_LIBRARY LIBLUV_INCLUDE_DIR)
-
-mark_as_advanced(LIBLUV_INCLUDE_DIR LIBLUV_LIBRARY)
diff --git a/cmake/FindLibTermkey.cmake b/cmake/FindLibTermkey.cmake
deleted file mode 100644
index 3e0c7f1bfd..0000000000
--- a/cmake/FindLibTermkey.cmake
+++ /dev/null
@@ -1,31 +0,0 @@
-# - Try to find libtermkey
-# Once done this will define
-# LIBTERMKEY_FOUND - System has libtermkey
-# LIBTERMKEY_INCLUDE_DIRS - The libtermkey include directories
-# LIBTERMKEY_LIBRARIES - The libraries needed to use libtermkey
-
-find_package(PkgConfig)
-if (PKG_CONFIG_FOUND)
- pkg_check_modules(PC_LIBTERMKEY QUIET termkey)
-endif()
-
-set(LIBTERMKEY_DEFINITIONS ${PC_LIBTERMKEY_CFLAGS_OTHER})
-
-find_path(LIBTERMKEY_INCLUDE_DIR termkey.h
- PATHS ${PC_LIBTERMKEY_INCLUDEDIR} ${PC_LIBTERMKEY_INCLUDE_DIRS})
-
-list(APPEND LIBTERMKEY_NAMES termkey)
-
-find_library(LIBTERMKEY_LIBRARY NAMES ${LIBTERMKEY_NAMES}
- HINTS ${PC_LIBTERMKEY_LIBDIR} ${PC_LIBTERMKEY_LIBRARY_DIRS})
-
-set(LIBTERMKEY_LIBRARIES ${LIBTERMKEY_LIBRARY})
-set(LIBTERMKEY_INCLUDE_DIRS ${LIBTERMKEY_INCLUDE_DIR})
-
-include(FindPackageHandleStandardArgs)
-# handle the QUIETLY and REQUIRED arguments and set LIBTERMKEY_FOUND to TRUE
-# if all listed variables are TRUE
-find_package_handle_standard_args(LibTermkey DEFAULT_MSG
- LIBTERMKEY_LIBRARY LIBTERMKEY_INCLUDE_DIR)
-
-mark_as_advanced(LIBTERMKEY_INCLUDE_DIR LIBTERMKEY_LIBRARY)
diff --git a/cmake/FindLibIntl.cmake b/cmake/FindLibintl.cmake
index 8cc5cb7dd2..630a3545fc 100644
--- a/cmake/FindLibIntl.cmake
+++ b/cmake/FindLibintl.cmake
@@ -1,42 +1,34 @@
-# - Try to find libintl
-# Once done, this will define
-#
-# LibIntl_FOUND - system has libintl
-# LibIntl_INCLUDE_DIRS - the libintl include directories
-# LibIntl_LIBRARIES - link these to use libintl
-
include(CheckCSourceCompiles)
include(CheckVariableExists)
-include(LibFindMacros)
# Append custom gettext path to CMAKE_PREFIX_PATH
-# if installed via Mac Hombrew
-if (CMAKE_HOST_APPLE)
- find_program(HOMEBREW_PROG brew)
- if (EXISTS ${HOMEBREW_PROG})
- execute_process(COMMAND ${HOMEBREW_PROG} --prefix gettext
+# if installed via Mac Homebrew
+if (APPLE)
+ find_program(HOMEBREW_PRG brew)
+ if (EXISTS ${HOMEBREW_PRG})
+ execute_process(COMMAND ${HOMEBREW_PRG} --prefix gettext
OUTPUT_STRIP_TRAILING_WHITESPACE
OUTPUT_VARIABLE HOMEBREW_GETTEXT_PREFIX)
list(APPEND CMAKE_PREFIX_PATH "${HOMEBREW_GETTEXT_PREFIX}")
endif()
endif()
-find_path(LibIntl_INCLUDE_DIR
+find_path(LIBINTL_INCLUDE_DIR
NAMES libintl.h
PATH_SUFFIXES gettext
)
-find_library(LibIntl_LIBRARY
+find_library(LIBINTL_LIBRARY
NAMES intl libintl
)
-if (LibIntl_INCLUDE_DIR)
- list(APPEND CMAKE_REQUIRED_INCLUDES "${LibIntl_INCLUDE_DIR}")
+if (LIBINTL_INCLUDE_DIR)
+ list(APPEND CMAKE_REQUIRED_INCLUDES "${LIBINTL_INCLUDE_DIR}")
endif()
# On some systems (linux+glibc) libintl is passively available.
# So only specify the library if one was found.
-if (LibIntl_LIBRARY)
- list(APPEND CMAKE_REQUIRED_LIBRARIES "${LibIntl_LIBRARY}")
+if (LIBINTL_LIBRARY)
+ list(APPEND CMAKE_REQUIRED_LIBRARIES "${LIBINTL_LIBRARY}")
endif()
if (MSVC)
list(APPEND CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARY})
@@ -44,7 +36,7 @@ endif()
# On macOS, if libintl is a static library then we also need
# to link libiconv and CoreFoundation.
-get_filename_component(LibIntl_EXT "${LibIntl_LIBRARY}" EXT)
+get_filename_component(LibIntl_EXT "${LIBINTL_LIBRARY}" EXT)
if (APPLE AND (LibIntl_EXT STREQUAL ".a"))
set(LibIntl_STATIC TRUE)
find_library(CoreFoundation_FRAMEWORK CoreFoundation)
@@ -67,25 +59,22 @@ endif()
if (LibIntl_STATIC)
list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "${ICONV_LIBRARY}" "${CoreFoundation_FRAMEWORK}")
endif()
-if (LibIntl_INCLUDE_DIR)
- list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES "${LibIntl_INCLUDE_DIR}")
+if (LIBINTL_INCLUDE_DIR)
+ list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES "${LIBINTL_INCLUDE_DIR}")
endif()
-if (LibIntl_LIBRARY)
- list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "${LibIntl_LIBRARY}")
+if (LIBINTL_LIBRARY)
+ list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "${LIBINTL_LIBRARY}")
endif()
+set(REQUIRED_VARIABLES LIBINTL_LIBRARY LIBINTL_INCLUDE_DIR)
if (HAVE_WORKING_LIBINTL)
# On some systems (linux+glibc) libintl is passively available.
# If HAVE_WORKING_LIBINTL then we consider the requirement satisfied.
- # Unset REQUIRED so that libfind_process(LibIntl) can proceed.
- if(LibIntl_FIND_REQUIRED)
- unset(LibIntl_FIND_REQUIRED)
- endif()
- set(LibIntl_FIND_QUIETLY ON)
+ unset(REQUIRED_VARIABLES)
check_variable_exists(_nl_msg_cat_cntr HAVE_NL_MSG_CAT_CNTR)
endif()
-set(LibIntl_PROCESS_INCLUDES LibIntl_INCLUDE_DIR)
-set(LibIntl_PROCESS_LIBS LibIntl_LIBRARY)
-libfind_process(LibIntl)
+find_package_handle_standard_args(Libintl DEFAULT_MSG
+ ${REQUIRED_VARIABLES})
+mark_as_advanced(LIBINTL_LIBRARY LIBINTL_INCLUDE_DIR)
diff --git a/cmake/FindLibtermkey.cmake b/cmake/FindLibtermkey.cmake
new file mode 100644
index 0000000000..8039ae7994
--- /dev/null
+++ b/cmake/FindLibtermkey.cmake
@@ -0,0 +1,9 @@
+find_path2(LIBTERMKEY_INCLUDE_DIR termkey.h)
+find_library2(LIBTERMKEY_LIBRARY NAMES termkey)
+find_package_handle_standard_args(Libtermkey DEFAULT_MSG
+ LIBTERMKEY_LIBRARY LIBTERMKEY_INCLUDE_DIR)
+mark_as_advanced(LIBTERMKEY_INCLUDE_DIR LIBTERMKEY_LIBRARY)
+
+add_library(libtermkey INTERFACE)
+target_include_directories(libtermkey SYSTEM BEFORE INTERFACE ${LIBTERMKEY_INCLUDE_DIR})
+target_link_libraries(libtermkey INTERFACE ${LIBTERMKEY_LIBRARY})
diff --git a/cmake/FindLibUV.cmake b/cmake/FindLibuv.cmake
index d6c4e9cbef..19315388dd 100644
--- a/cmake/FindLibUV.cmake
+++ b/cmake/FindLibuv.cmake
@@ -1,35 +1,7 @@
-# - Try to find libuv
-# Once done, this will define
-#
-# LIBUV_FOUND - system has libuv
-# LIBUV_INCLUDE_DIRS - the libuv include directories
-# LIBUV_LIBRARIES - link these to use libuv
+find_path2(LIBUV_INCLUDE_DIR uv.h)
+find_library2(LIBUV_LIBRARY NAMES uv_a uv)
-find_package(PkgConfig)
-if (PKG_CONFIG_FOUND)
- pkg_check_modules(PC_LIBUV QUIET libuv)
-endif()
-
-find_path(LIBUV_INCLUDE_DIR uv.h
- HINTS ${PC_LIBUV_INCLUDEDIR} ${PC_LIBUV_INCLUDE_DIRS})
-
-list(APPEND LIBUV_NAMES uv_a uv)
-
-find_library(LIBUV_LIBRARY NAMES ${LIBUV_NAMES}
- HINTS ${PC_LIBUV_LIBDIR} ${PC_LIBUV_LIBRARY_DIRS})
-
-mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARY)
-
-if(PC_LIBUV_LIBRARIES)
- list(REMOVE_ITEM PC_LIBUV_LIBRARIES uv)
-endif()
-
-set(LIBUV_LIBRARIES ${LIBUV_LIBRARY} ${PC_LIBUV_LIBRARIES})
-set(LIBUV_INCLUDE_DIRS ${LIBUV_INCLUDE_DIR})
-
-# Deal with the fact that libuv.pc is missing important dependency information.
-
-include(CheckLibraryExists)
+set(LIBUV_LIBRARIES ${LIBUV_LIBRARY})
check_library_exists(dl dlopen "dlfcn.h" HAVE_LIBDL)
if(HAVE_LIBDL)
@@ -83,11 +55,7 @@ if(Threads_FOUND)
list(APPEND LIBUV_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
endif()
-include(FindPackageHandleStandardArgs)
-
-# handle the QUIETLY and REQUIRED arguments and set LIBUV_FOUND to TRUE
-# if all listed variables are TRUE
-find_package_handle_standard_args(LibUV DEFAULT_MSG
+find_package_handle_standard_args(Libuv DEFAULT_MSG
LIBUV_LIBRARY LIBUV_INCLUDE_DIR)
mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARY)
diff --git a/cmake/Findlibvterm.cmake b/cmake/FindLibvterm.cmake
index d8536ca894..68c2646d47 100644
--- a/cmake/Findlibvterm.cmake
+++ b/cmake/FindLibvterm.cmake
@@ -1,5 +1,5 @@
-find_path(LIBVTERM_INCLUDE_DIR vterm.h)
-find_library(LIBVTERM_LIBRARY vterm)
+find_path2(LIBVTERM_INCLUDE_DIR vterm.h)
+find_library2(LIBVTERM_LIBRARY vterm)
if(LIBVTERM_INCLUDE_DIR AND EXISTS "${LIBVTERM_INCLUDE_DIR}/vterm.h")
file(STRINGS ${LIBVTERM_INCLUDE_DIR}/vterm.h VTERM_VERSION_MAJOR REGEX "#define VTERM_VERSION_MAJOR")
@@ -8,13 +8,24 @@ if(LIBVTERM_INCLUDE_DIR AND EXISTS "${LIBVTERM_INCLUDE_DIR}/vterm.h")
file(STRINGS ${LIBVTERM_INCLUDE_DIR}/vterm.h VTERM_VERSION_MINOR REGEX "#define VTERM_VERSION_MINOR")
string(REGEX MATCH "[0-9]+" VTERM_VERSION_MINOR ${VTERM_VERSION_MINOR})
- set(VTERM_VERSION ${VTERM_VERSION_MAJOR}.${VTERM_VERSION_MINOR})
+ file(STRINGS ${LIBVTERM_INCLUDE_DIR}/vterm.h VTERM_VERSION_PATCH REGEX "#define VTERM_VERSION_PATCH")
+
+ # The following is needed to give a coherent error for versions 0.3.2 and
+ # smaller.
+ if(VTERM_VERSION_PATCH)
+ string(REGEX MATCH "[0-9]+" VTERM_VERSION_PATCH ${VTERM_VERSION_PATCH})
+ string(PREPEND VTERM_VERSION_PATCH ".")
+ endif()
+
+ set(VTERM_VERSION ${VTERM_VERSION_MAJOR}.${VTERM_VERSION_MINOR}${VTERM_VERSION_PATCH})
endif()
-find_package_handle_standard_args(libvterm
+find_package_handle_standard_args(Libvterm
REQUIRED_VARS LIBVTERM_INCLUDE_DIR LIBVTERM_LIBRARY
VERSION_VAR VTERM_VERSION)
add_library(libvterm INTERFACE)
-target_include_directories(libvterm SYSTEM BEFORE INTERFACE INTERFACE ${LIBVTERM_INCLUDE_DIR})
+target_include_directories(libvterm SYSTEM BEFORE INTERFACE ${LIBVTERM_INCLUDE_DIR})
target_link_libraries(libvterm INTERFACE ${LIBVTERM_LIBRARY})
+
+mark_as_advanced(LIBVTERM_INCLUDE_DIR LIBVTERM_LIBRARY)
diff --git a/cmake/FindLpeg.cmake b/cmake/FindLpeg.cmake
new file mode 100644
index 0000000000..3d0ff5929d
--- /dev/null
+++ b/cmake/FindLpeg.cmake
@@ -0,0 +1,9 @@
+find_library2(LPEG_LIBRARY NAMES lpeg_a lpeg liblpeg_a lpeg${CMAKE_SHARED_LIBRARY_SUFFIX} PATH_SUFFIXES lua/5.1)
+
+find_package_handle_standard_args(Lpeg DEFAULT_MSG LPEG_LIBRARY)
+mark_as_advanced(LPEG_LIBRARY)
+
+# Workaround: use an imported library to prevent cmake from modifying library
+# link path. See #23395.
+add_library(lpeg UNKNOWN IMPORTED)
+set_target_properties(lpeg PROPERTIES IMPORTED_LOCATION ${LPEG_LIBRARY})
diff --git a/cmake/FindLuaJit.cmake b/cmake/FindLuaJit.cmake
deleted file mode 100644
index 72795afefd..0000000000
--- a/cmake/FindLuaJit.cmake
+++ /dev/null
@@ -1,38 +0,0 @@
-# - Try to find luajit
-# Once done this will define
-# LUAJIT_FOUND - System has luajit
-# LUAJIT_INCLUDE_DIRS - The luajit include directories
-# LUAJIT_LIBRARIES - The libraries needed to use luajit
-
-find_package(PkgConfig)
-if (PKG_CONFIG_FOUND)
- pkg_check_modules(PC_LUAJIT QUIET luajit)
-endif()
-
-set(LUAJIT_DEFINITIONS ${PC_LUAJIT_CFLAGS_OTHER})
-
-find_path(LUAJIT_INCLUDE_DIR luajit.h
- PATHS ${PC_LUAJIT_INCLUDEDIR} ${PC_LUAJIT_INCLUDE_DIRS}
- PATH_SUFFIXES luajit-2.0 luajit-2.1)
-
-if(MSVC)
- list(APPEND LUAJIT_NAMES lua51)
-elseif(MINGW)
- list(APPEND LUAJIT_NAMES libluajit libluajit-5.1)
-else()
- list(APPEND LUAJIT_NAMES luajit-5.1)
-endif()
-
-find_library(LUAJIT_LIBRARY NAMES ${LUAJIT_NAMES}
- PATHS ${PC_LUAJIT_LIBDIR} ${PC_LUAJIT_LIBRARY_DIRS})
-
-set(LUAJIT_LIBRARIES ${LUAJIT_LIBRARY})
-set(LUAJIT_INCLUDE_DIRS ${LUAJIT_INCLUDE_DIR})
-
-include(FindPackageHandleStandardArgs)
-# handle the QUIETLY and REQUIRED arguments and set LUAJIT_FOUND to TRUE
-# if all listed variables are TRUE
-find_package_handle_standard_args(LuaJit DEFAULT_MSG
- LUAJIT_LIBRARY LUAJIT_INCLUDE_DIR)
-
-mark_as_advanced(LUAJIT_INCLUDE_DIR LUAJIT_LIBRARY)
diff --git a/cmake/FindLuajit.cmake b/cmake/FindLuajit.cmake
new file mode 100644
index 0000000000..457ceafdd4
--- /dev/null
+++ b/cmake/FindLuajit.cmake
@@ -0,0 +1,17 @@
+find_path2(LUAJIT_INCLUDE_DIR luajit.h
+ PATH_SUFFIXES luajit-2.1)
+
+if(MSVC)
+ list(APPEND LUAJIT_NAMES lua51)
+elseif(MINGW)
+ list(APPEND LUAJIT_NAMES libluajit libluajit-5.1)
+else()
+ list(APPEND LUAJIT_NAMES luajit-5.1)
+endif()
+
+find_library2(LUAJIT_LIBRARY NAMES ${LUAJIT_NAMES})
+
+find_package_handle_standard_args(Luajit DEFAULT_MSG
+ LUAJIT_LIBRARY LUAJIT_INCLUDE_DIR)
+
+mark_as_advanced(LUAJIT_INCLUDE_DIR LUAJIT_LIBRARY)
diff --git a/cmake/FindLuv.cmake b/cmake/FindLuv.cmake
new file mode 100644
index 0000000000..a4408fe659
--- /dev/null
+++ b/cmake/FindLuv.cmake
@@ -0,0 +1,6 @@
+find_path2(LUV_INCLUDE_DIR luv/luv.h PATH_SUFFIXES lua5.1)
+find_library2(LUV_LIBRARY NAMES luv_a luv libluv_a luv${CMAKE_SHARED_LIBRARY_SUFFIX} PATH_SUFFIXES lua/5.1)
+
+find_package_handle_standard_args(Luv DEFAULT_MSG
+ LUV_LIBRARY LUV_INCLUDE_DIR)
+mark_as_advanced(LUV_INCLUDE_DIR LUV_LIBRARY)
diff --git a/cmake/FindMsgpack.cmake b/cmake/FindMsgpack.cmake
index 26eb19d498..9ef18122ab 100644
--- a/cmake/FindMsgpack.cmake
+++ b/cmake/FindMsgpack.cmake
@@ -1,20 +1,4 @@
-# - Try to find msgpack
-# Once done this will define
-# MSGPACK_FOUND - System has msgpack
-# MSGPACK_INCLUDE_DIRS - The msgpack include directories
-# MSGPACK_LIBRARIES - The libraries needed to use msgpack
-
-find_package(PkgConfig)
-if (PKG_CONFIG_FOUND)
- pkg_search_module(PC_MSGPACK QUIET
- msgpackc>=${Msgpack_FIND_VERSION}
- msgpack>=${Msgpack_FIND_VERSION})
-endif()
-
-set(MSGPACK_DEFINITIONS ${PC_MSGPACK_CFLAGS_OTHER})
-
-find_path(MSGPACK_INCLUDE_DIR msgpack/version_master.h
- HINTS ${PC_MSGPACK_INCLUDEDIR} ${PC_MSGPACK_INCLUDE_DIRS})
+find_path2(MSGPACK_INCLUDE_DIR msgpack/version_master.h)
if(MSGPACK_INCLUDE_DIR)
file(READ ${MSGPACK_INCLUDE_DIR}/msgpack/version_master.h msgpack_version_h)
@@ -26,28 +10,15 @@ else()
set(MSGPACK_VERSION_STRING)
endif()
-if(MSVC)
- # The import library for the msgpack DLL has a different name
- list(APPEND MSGPACK_NAMES msgpackc_import)
-else()
- list(APPEND MSGPACK_NAMES msgpackc msgpack)
-endif()
-
-find_library(MSGPACK_LIBRARY NAMES ${MSGPACK_NAMES}
- # Check each directory for all names to avoid using headers/libraries from
- # different places.
- NAMES_PER_DIR
- HINTS ${PC_MSGPACK_LIBDIR} ${PC_MSGPACK_LIBRARY_DIRS})
+find_library2(MSGPACK_LIBRARY NAMES msgpackc msgpack msgpackc_import msgpack-c
+ NAMES_PER_DIR)
mark_as_advanced(MSGPACK_INCLUDE_DIR MSGPACK_LIBRARY)
-set(MSGPACK_LIBRARIES ${MSGPACK_LIBRARY})
-set(MSGPACK_INCLUDE_DIRS ${MSGPACK_INCLUDE_DIR})
-
-include(FindPackageHandleStandardArgs)
-# handle the QUIETLY and REQUIRED arguments and set MSGPACK_FOUND to TRUE
-# if all listed variables are TRUE
find_package_handle_standard_args(Msgpack
REQUIRED_VARS MSGPACK_LIBRARY MSGPACK_INCLUDE_DIR
VERSION_VAR MSGPACK_VERSION_STRING)
+add_library(msgpack INTERFACE)
+target_include_directories(msgpack SYSTEM BEFORE INTERFACE ${MSGPACK_INCLUDE_DIR})
+target_link_libraries(msgpack INTERFACE ${MSGPACK_LIBRARY})
diff --git a/cmake/FindTreeSitter.cmake b/cmake/FindTreeSitter.cmake
deleted file mode 100644
index ae0928e9f7..0000000000
--- a/cmake/FindTreeSitter.cmake
+++ /dev/null
@@ -1,11 +0,0 @@
-# - Try to find tree-sitter
-# Once done, this will define
-#
-# TreeSitter_FOUND - system has tree-sitter
-# TreeSitter_INCLUDE_DIRS - the tree-sitter include directories
-# TreeSitter_LIBRARIES - link these to use tree-sitter
-
-include(LibFindMacros)
-
-libfind_pkg_detect(TreeSitter tree-sitter FIND_PATH tree_sitter/api.h FIND_LIBRARY tree-sitter)
-libfind_process(TreeSitter)
diff --git a/cmake/FindTreesitter.cmake b/cmake/FindTreesitter.cmake
new file mode 100644
index 0000000000..8dac13337b
--- /dev/null
+++ b/cmake/FindTreesitter.cmake
@@ -0,0 +1,29 @@
+find_path2(TREESITTER_INCLUDE_DIR tree_sitter/api.h)
+find_library2(TREESITTER_LIBRARY NAMES tree-sitter)
+find_package_handle_standard_args(Treesitter DEFAULT_MSG
+ TREESITTER_LIBRARY TREESITTER_INCLUDE_DIR)
+mark_as_advanced(TREESITTER_LIBRARY TREESITTER_INCLUDE_DIR)
+
+add_library(treesitter INTERFACE)
+target_include_directories(treesitter SYSTEM BEFORE INTERFACE ${TREESITTER_INCLUDE_DIR})
+target_link_libraries(treesitter INTERFACE ${TREESITTER_LIBRARY})
+
+# TODO(lewis6991): remove when min TS version is 0.20.9
+list(APPEND CMAKE_REQUIRED_INCLUDES "${TREESITTER_INCLUDE_DIR}")
+list(APPEND CMAKE_REQUIRED_LIBRARIES "${TREESITTER_LIBRARY}")
+check_c_source_compiles("
+#include <tree_sitter/api.h>
+int
+main(void)
+{
+ TSQueryCursor *cursor = ts_query_cursor_new();
+ ts_query_cursor_set_max_start_depth(cursor, 32);
+ return 0;
+}
+" TS_HAS_SET_MAX_START_DEPTH)
+list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES "${TREESITTER_INCLUDE_DIR}")
+list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "${TREESITTER_LIBRARY}")
+
+if(TS_HAS_SET_MAX_START_DEPTH)
+ target_compile_definitions(treesitter INTERFACE NVIM_TS_HAS_SET_MAX_START_DEPTH)
+endif()
diff --git a/cmake/FindUnibilium.cmake b/cmake/FindUnibilium.cmake
new file mode 100644
index 0000000000..4f62815793
--- /dev/null
+++ b/cmake/FindUnibilium.cmake
@@ -0,0 +1,11 @@
+find_path2(UNIBILIUM_INCLUDE_DIR unibilium.h)
+find_library2(UNIBILIUM_LIBRARY unibilium)
+
+find_package_handle_standard_args(Unibilium
+ REQUIRED_VARS UNIBILIUM_INCLUDE_DIR UNIBILIUM_LIBRARY)
+
+add_library(unibilium INTERFACE)
+target_include_directories(unibilium SYSTEM BEFORE INTERFACE ${UNIBILIUM_INCLUDE_DIR})
+target_link_libraries(unibilium INTERFACE ${UNIBILIUM_LIBRARY})
+
+mark_as_advanced(UNIBILIUM_INCLUDE_DIR UNIBILIUM_LIBRARY)
diff --git a/cmake/Findunibilium.cmake b/cmake/Findunibilium.cmake
deleted file mode 100644
index 7bfbcba942..0000000000
--- a/cmake/Findunibilium.cmake
+++ /dev/null
@@ -1,27 +0,0 @@
-find_path(UNIBILIUM_INCLUDE_DIR unibilium.h)
-find_library(UNIBILIUM_LIBRARY unibilium)
-
-find_package_handle_standard_args(unibilium
- REQUIRED_VARS UNIBILIUM_INCLUDE_DIR UNIBILIUM_LIBRARY)
-
-add_library(unibilium INTERFACE)
-target_include_directories(unibilium SYSTEM BEFORE INTERFACE ${UNIBILIUM_INCLUDE_DIR})
-target_link_libraries(unibilium INTERFACE ${UNIBILIUM_LIBRARY})
-
-list(APPEND CMAKE_REQUIRED_INCLUDES "${UNIBILIUM_INCLUDE_DIR}")
-list(APPEND CMAKE_REQUIRED_LIBRARIES "${UNIBILIUM_LIBRARY}")
-check_c_source_compiles("
-#include <unibilium.h>
-
-int
-main(void)
-{
- unibi_str_from_var(unibi_var_from_str(\"\"));
- return unibi_num_from_var(unibi_var_from_num(0));
-}
-" UNIBI_HAS_VAR_FROM)
-list(REMOVE_ITEM CMAKE_REQUIRED_INCLUDES "${UNIBILIUM_INCLUDE_DIR}")
-list(REMOVE_ITEM CMAKE_REQUIRED_LIBRARIES "${UNIBILIUM_LIBRARY}")
-if(UNIBI_HAS_VAR_FROM)
- target_compile_definitions(unibilium INTERFACE NVIM_UNIBI_HAS_VAR_FROM)
-endif()
diff --git a/cmake/Format.cmake b/cmake/Format.cmake
index 4115e66705..7097e5766f 100644
--- a/cmake/Format.cmake
+++ b/cmake/Format.cmake
@@ -1,35 +1,33 @@
# Returns a list of all files that has been changed in current branch compared
# to master branch. This includes unstaged, staged and committed files.
function(get_changed_files outvar)
- set(default_branch master)
-
execute_process(
COMMAND git branch --show-current
OUTPUT_VARIABLE current_branch
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(
- COMMAND git merge-base ${default_branch} ${current_branch}
+ COMMAND git merge-base master HEAD
OUTPUT_VARIABLE ancestor_commit
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Changed files that have been committed
execute_process(
- COMMAND git diff --name-only ${ancestor_commit}...${current_branch}
+ COMMAND git diff --diff-filter=d --name-only ${ancestor_commit}...${current_branch}
OUTPUT_VARIABLE committed_files
OUTPUT_STRIP_TRAILING_WHITESPACE)
separate_arguments(committed_files NATIVE_COMMAND ${committed_files})
# Unstaged files
execute_process(
- COMMAND git diff --name-only
+ COMMAND git diff --diff-filter=d --name-only
OUTPUT_VARIABLE unstaged_files
OUTPUT_STRIP_TRAILING_WHITESPACE)
separate_arguments(unstaged_files NATIVE_COMMAND ${unstaged_files})
# Staged files
execute_process(
- COMMAND git diff --cached --name-only
+ COMMAND git diff --diff-filter=d --cached --name-only
OUTPUT_VARIABLE staged_files
OUTPUT_STRIP_TRAILING_WHITESPACE)
separate_arguments(staged_files NATIVE_COMMAND ${staged_files})
diff --git a/cmake/GenerateVersion.cmake b/cmake/GenerateVersion.cmake
index c092645140..a52dca970f 100644
--- a/cmake/GenerateVersion.cmake
+++ b/cmake/GenerateVersion.cmake
@@ -5,14 +5,17 @@ execute_process(
COMMAND git --git-dir=${NVIM_SOURCE_DIR}/.git --work-tree=${NVIM_SOURCE_DIR} describe --first-parent --dirty --always
OUTPUT_VARIABLE GIT_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET
RESULT_VARIABLE RES)
-
if(RES)
message(STATUS "Using NVIM_VERSION: ${NVIM_VERSION}")
file(WRITE "${OUTPUT}" "")
return()
endif()
+# Extract build info: "v0.9.0-145-g0f9113907" => "g0f9113907"
+string(REGEX REPLACE ".*\\-" "" NVIM_VERSION_BUILD "${GIT_TAG}")
+
# `git describe` annotates the most recent tagged release; for pre-release
# builds we append that to the dev version.
if(NVIM_VERSION_PRERELEASE)
@@ -23,7 +26,7 @@ if(NVIM_VERSION_PRERELEASE)
set(NVIM_VERSION "${NVIM_VERSION}-${NVIM_VERSION_GIT}")
endif()
-set(NVIM_VERSION_STRING "#define NVIM_VERSION_MEDIUM \"${NVIM_VERSION}\"\n")
+set(NVIM_VERSION_STRING "#define NVIM_VERSION_MEDIUM \"${NVIM_VERSION}\"\n#define NVIM_VERSION_BUILD \"${NVIM_VERSION_BUILD}\"\n")
string(SHA1 CURRENT_VERSION_HASH "${NVIM_VERSION_STRING}")
if(EXISTS ${OUTPUT})
diff --git a/cmake/GetCompileFlags.cmake b/cmake/GetCompileFlags.cmake
deleted file mode 100644
index 9b3c053871..0000000000
--- a/cmake/GetCompileFlags.cmake
+++ /dev/null
@@ -1,57 +0,0 @@
-function(get_compile_flags _compile_flags)
- string(TOUPPER "${CMAKE_BUILD_TYPE}" build_type)
- set(compile_flags ${CMAKE_C_COMPILER} ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${build_type}})
-
- # Get flags set by target_compile_options().
- get_target_property(opt main_lib INTERFACE_COMPILE_OPTIONS)
- if(opt)
- list(APPEND compile_flags ${opt})
- endif()
-
- get_target_property(opt nvim COMPILE_OPTIONS)
- if(opt)
- list(APPEND compile_flags ${opt})
- endif()
-
- # Get flags set by target_compile_definitions().
- get_target_property(defs main_lib INTERFACE_COMPILE_DEFINITIONS)
- if(defs)
- foreach(def ${defs})
- list(APPEND compile_flags "-D${def}")
- endforeach()
- endif()
-
- get_target_property(defs nvim COMPILE_DEFINITIONS)
- if(defs)
- foreach(def ${defs})
- list(APPEND compile_flags "-D${def}")
- endforeach()
- endif()
-
- # Get include directories.
- get_target_property(dirs main_lib INTERFACE_INCLUDE_DIRECTORIES)
- if(dirs)
- foreach(dir ${dirs})
- list(APPEND compile_flags "-I${dir}")
- endforeach()
- endif()
-
- get_target_property(dirs main_lib INTERFACE_SYSTEM_INCLUDE_DIRECTORIES)
- if(dirs)
- foreach(dir ${dirs})
- list(APPEND compile_flags "-I${dir}")
- endforeach()
- endif()
-
- get_target_property(dirs nvim INCLUDE_DIRECTORIES)
- if(dirs)
- foreach(dir ${dirs})
- list(APPEND compile_flags "-I${dir}")
- endforeach()
- endif()
-
- list(REMOVE_DUPLICATES compile_flags)
- string(REPLACE ";" " " compile_flags "${compile_flags}")
-
- set(${_compile_flags} "${compile_flags}" PARENT_SCOPE)
-endfunction()
diff --git a/cmake/InstallHelpers.cmake b/cmake/InstallHelpers.cmake
index 3786c4177f..63bf2bb73b 100644
--- a/cmake/InstallHelpers.cmake
+++ b/cmake/InstallHelpers.cmake
@@ -7,9 +7,6 @@ if(CMAKE_SYSTEM_NAME MATCHES "BSD" AND NOT DEFINED CMAKE_INSTALL_MANDIR)
endif()
endif()
-# For $CMAKE_INSTALL_{DATAROOT,MAN, ...}DIR
-include(GNUInstallDirs)
-
# This will create any directories that need to be created in the destination
# path with the typical owner, group, and user permissions--independent of the
# umask setting.
@@ -167,12 +164,3 @@ function(glob_wrapper outvar)
endif()
set(${outvar} ${${outvar}} PARENT_SCOPE)
endfunction()
-
-function(globrecurse_wrapper outvar root)
- if(${CMAKE_VERSION} VERSION_LESS 3.12)
- file(GLOB_RECURSE ${outvar} RELATIVE ${root} ${ARGN})
- else()
- file(GLOB_RECURSE ${outvar} CONFIGURE_DEPENDS RELATIVE ${root} ${ARGN})
- endif()
- set(${outvar} ${${outvar}} PARENT_SCOPE)
-endfunction()
diff --git a/cmake/LibFindMacros.cmake b/cmake/LibFindMacros.cmake
deleted file mode 100644
index 726a8631f0..0000000000
--- a/cmake/LibFindMacros.cmake
+++ /dev/null
@@ -1,269 +0,0 @@
-# Version 2.2
-# Public Domain, originally written by Lasse Kärkkäinen <tronic>
-# Maintained at https://github.com/Tronic/cmake-modules
-# Please send your improvements as pull requests on Github.
-
-# Find another package and make it a dependency of the current package.
-# This also automatically forwards the "REQUIRED" argument.
-# Usage: libfind_package(<prefix> <another package> [extra args to find_package])
-macro (libfind_package PREFIX PKG)
- set(${PREFIX}_args ${PKG} ${ARGN})
- if (${PREFIX}_FIND_REQUIRED)
- set(${PREFIX}_args ${${PREFIX}_args} REQUIRED)
- endif()
- find_package(${${PREFIX}_args})
- set(${PREFIX}_DEPENDENCIES ${${PREFIX}_DEPENDENCIES};${PKG})
- unset(${PREFIX}_args)
-endmacro()
-
-# A simple wrapper to make pkg-config searches a bit easier.
-# Works the same as CMake's internal pkg_check_modules but is always quiet.
-macro (libfind_pkg_check_modules)
- find_package(PkgConfig QUIET)
- if (PKG_CONFIG_FOUND)
- pkg_check_modules(${ARGN} QUIET)
- endif()
-endmacro()
-
-# Avoid useless copy&pasta by doing what most simple libraries do anyway:
-# pkg-config, find headers, find library.
-# Usage: libfind_pkg_detect(<prefix> <pkg-config args> FIND_PATH <name> [other args] FIND_LIBRARY <name> [other args])
-# E.g. libfind_pkg_detect(SDL2 sdl2 FIND_PATH SDL.h PATH_SUFFIXES SDL2 FIND_LIBRARY SDL2)
-function (libfind_pkg_detect PREFIX)
- # Parse arguments
- set(argname pkgargs)
- foreach (i ${ARGN})
- if ("${i}" STREQUAL "FIND_PATH")
- set(argname pathargs)
- elseif ("${i}" STREQUAL "FIND_LIBRARY")
- set(argname libraryargs)
- else()
- set(${argname} ${${argname}} ${i})
- endif()
- endforeach()
- if (NOT pkgargs)
- message(FATAL_ERROR "libfind_pkg_detect requires at least a pkg_config package name to be passed.")
- endif()
- # Find library
- libfind_pkg_check_modules(${PREFIX}_PKGCONF ${pkgargs})
- if (pathargs)
- find_path(${PREFIX}_INCLUDE_DIR NAMES ${pathargs} HINTS ${${PREFIX}_PKGCONF_INCLUDE_DIRS})
- endif()
- if (libraryargs)
- find_library(${PREFIX}_LIBRARY NAMES ${libraryargs} HINTS ${${PREFIX}_PKGCONF_LIBRARY_DIRS})
- endif()
- # Read pkg-config version
- if (${PREFIX}_PKGCONF_VERSION)
- set(${PREFIX}_VERSION ${${PREFIX}_PKGCONF_VERSION} PARENT_SCOPE)
- endif()
-endfunction()
-
-# Extracts a version #define from a version.h file, output stored to <PREFIX>_VERSION.
-# Usage: libfind_version_header(Foobar foobar/version.h FOOBAR_VERSION_STR)
-# Fourth argument "QUIET" may be used for silently testing different define names.
-# This function does nothing if the version variable is already defined.
-function (libfind_version_header PREFIX VERSION_H DEFINE_NAME)
- # Skip processing if we already have a version or if the include dir was not found
- if (${PREFIX}_VERSION OR NOT ${PREFIX}_INCLUDE_DIR)
- return()
- endif()
- set(quiet ${${PREFIX}_FIND_QUIETLY})
- # Process optional arguments
- foreach(arg ${ARGN})
- if (arg STREQUAL "QUIET")
- set(quiet TRUE)
- else()
- message(AUTHOR_WARNING "Unknown argument ${arg} to libfind_version_header ignored.")
- endif()
- endforeach()
- # Read the header and parse for version number
- set(filename "${${PREFIX}_INCLUDE_DIR}/${VERSION_H}")
- if (NOT EXISTS ${filename})
- if (NOT quiet)
- message(AUTHOR_WARNING "Unable to find ${${PREFIX}_INCLUDE_DIR}/${VERSION_H}")
- endif()
- return()
- endif()
- file(READ "${filename}" header)
- string(REGEX REPLACE ".*#[ \t]*define[ \t]*${DEFINE_NAME}[ \t]*\"([^\n]*)\".*" "\\1" match "${header}")
- # No regex match?
- if (match STREQUAL header)
- if (NOT quiet)
- message(AUTHOR_WARNING "Unable to find \#define ${DEFINE_NAME} \"<version>\" from ${${PREFIX}_INCLUDE_DIR}/${VERSION_H}")
- endif()
- return()
- endif()
- # Export the version string
- set(${PREFIX}_VERSION "${match}" PARENT_SCOPE)
-endfunction()
-
-# Do the final processing once the paths have been detected.
-# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain
-# all the variables, each of which contain one include directory.
-# Ditto for ${PREFIX}_PROCESS_LIBS and library files.
-# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES.
-# Also handles errors in case library detection was required, etc.
-function (libfind_process PREFIX)
- # Skip processing if already processed during this configuration run
- if (${PREFIX}_FOUND)
- return()
- endif()
-
- set(found TRUE) # Start with the assumption that the package was found
-
- # Did we find any files? Did we miss includes? These are for formatting better error messages.
- set(some_files FALSE)
- set(missing_headers FALSE)
-
- # Shorthands for some variables that we need often
- set(quiet ${${PREFIX}_FIND_QUIETLY})
- set(required ${${PREFIX}_FIND_REQUIRED})
- set(exactver ${${PREFIX}_FIND_VERSION_EXACT})
- set(findver "${${PREFIX}_FIND_VERSION}")
- set(version "${${PREFIX}_VERSION}")
-
- # Lists of config option names (all, includes, libs)
- unset(configopts)
- set(includeopts ${${PREFIX}_PROCESS_INCLUDES})
- set(libraryopts ${${PREFIX}_PROCESS_LIBS})
-
- # Process deps to add to
- foreach (i ${PREFIX} ${${PREFIX}_DEPENDENCIES})
- if (DEFINED ${i}_INCLUDE_OPTS OR DEFINED ${i}_LIBRARY_OPTS)
- # The package seems to export option lists that we can use, woohoo!
- list(APPEND includeopts ${${i}_INCLUDE_OPTS})
- list(APPEND libraryopts ${${i}_LIBRARY_OPTS})
- else()
- # If plural forms don't exist or they equal singular forms
- if ((NOT DEFINED ${i}_INCLUDE_DIRS AND NOT DEFINED ${i}_LIBRARIES) OR
- (${i}_INCLUDE_DIR STREQUAL ${i}_INCLUDE_DIRS AND ${i}_LIBRARY STREQUAL ${i}_LIBRARIES))
- # Singular forms can be used
- if (DEFINED ${i}_INCLUDE_DIR)
- list(APPEND includeopts ${i}_INCLUDE_DIR)
- endif()
- if (DEFINED ${i}_LIBRARY)
- list(APPEND libraryopts ${i}_LIBRARY)
- endif()
- else()
- # Oh no, we don't know the option names
- message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes and libs. Aieeh!")
- endif()
- endif()
- endforeach()
-
- if (includeopts)
- list(REMOVE_DUPLICATES includeopts)
- endif()
-
- if (libraryopts)
- list(REMOVE_DUPLICATES libraryopts)
- endif()
-
- string(REGEX REPLACE ".*[ ;]([^ ;]*(_INCLUDE_DIRS|_LIBRARIES))" "\\1" tmp "${includeopts} ${libraryopts}")
- if (NOT tmp STREQUAL "${includeopts} ${libraryopts}")
- message(AUTHOR_WARNING "Plural form ${tmp} found in config options of ${PREFIX}. This works as before but is now deprecated. Please only use singular forms INCLUDE_DIR and LIBRARY, and update your find scripts for LibFindMacros > 2.0 automatic dependency system (most often you can simply remove the PROCESS variables entirely).")
- endif()
-
- # Include/library names separated by spaces (notice: not CMake lists)
- unset(includes)
- unset(libs)
-
- # Process all includes and set found false if any are missing
- foreach (i ${includeopts})
- list(APPEND configopts ${i})
- if (NOT "${${i}}" STREQUAL "${i}-NOTFOUND")
- list(APPEND includes "${${i}}")
- else()
- set(found FALSE)
- set(missing_headers TRUE)
- endif()
- endforeach()
-
- # Process all libraries and set found false if any are missing
- foreach (i ${libraryopts})
- list(APPEND configopts ${i})
- if (NOT "${${i}}" STREQUAL "${i}-NOTFOUND")
- list(APPEND libs "${${i}}")
- else()
- set (found FALSE)
- endif()
- endforeach()
-
- # Version checks
- if (found AND findver)
- if (NOT version)
- message(WARNING "The find module for ${PREFIX} does not provide version information, so we'll just assume that it is OK. Please fix the module or remove package version requirements to get rid of this warning.")
- elseif (version VERSION_LESS findver OR (exactver AND NOT version VERSION_EQUAL findver))
- set(found FALSE)
- set(version_unsuitable TRUE)
- endif()
- endif()
-
- # If all-OK, hide all config options, export variables, print status and exit
- if (found)
- foreach (i ${configopts})
- mark_as_advanced(${i})
- endforeach()
- if (NOT quiet)
- message(STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}")
- if (LIBFIND_DEBUG)
- message(STATUS " ${PREFIX}_DEPENDENCIES=${${PREFIX}_DEPENDENCIES}")
- message(STATUS " ${PREFIX}_INCLUDE_OPTS=${includeopts}")
- message(STATUS " ${PREFIX}_INCLUDE_DIRS=${includes}")
- message(STATUS " ${PREFIX}_LIBRARY_OPTS=${libraryopts}")
- message(STATUS " ${PREFIX}_LIBRARIES=${libs}")
- endif()
- endif()
- set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE)
- set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE)
- set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE)
- set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE)
- set (${PREFIX}_FOUND TRUE PARENT_SCOPE)
- return()
- endif()
-
- # Format messages for debug info and the type of error
- set(vars "Relevant CMake configuration variables:\n")
- foreach (i ${configopts})
- mark_as_advanced(CLEAR ${i})
- set(val ${${i}})
- if ("${val}" STREQUAL "${i}-NOTFOUND")
- set (val "<not found>")
- elseif (val AND NOT EXISTS ${val})
- set (val "${val} (does not exist)")
- else()
- set(some_files TRUE)
- endif()
- set(vars "${vars} ${i}=${val}\n")
- endforeach()
- set(vars "${vars}You may use CMake GUI, cmake -D or ccmake to modify the values. Delete CMakeCache.txt to discard all values and force full re-detection if necessary.\n")
- if (version_unsuitable)
- set(msg "${PREFIX} ${${PREFIX}_VERSION} was found but")
- if (exactver)
- set(msg "${msg} only version ${findver} is acceptable.")
- else()
- set(msg "${msg} version ${findver} is the minimum requirement.")
- endif()
- else()
- if (missing_headers)
- set(msg "We could not find development headers for ${PREFIX}. Do you have the necessary dev package installed?")
- elseif (some_files)
- set(msg "We only found some files of ${PREFIX}, not all of them. Perhaps your installation is incomplete or maybe we just didn't look in the right place?")
- if(findver)
- set(msg "${msg} This could also be caused by incompatible version (if it helps, at least ${PREFIX} ${findver} should work).")
- endif()
- else()
- set(msg "We were unable to find package ${PREFIX}.")
- endif()
- endif()
-
- # Fatal error out if REQUIRED
- if (required)
- set(msg "REQUIRED PACKAGE NOT FOUND\n${msg} This package is REQUIRED and you need to install it or adjust CMake configuration in order to continue building ${CMAKE_PROJECT_NAME}.")
- message(FATAL_ERROR "${msg}\n${vars}")
- endif()
- # Otherwise just print a nasty warning
- if (NOT quiet)
- message(WARNING "WARNING: MISSING PACKAGE\n${msg} This package is NOT REQUIRED and you may ignore this warning but by doing so you may miss some functionality of ${CMAKE_PROJECT_NAME}. \n${vars}")
- endif()
-endfunction()
diff --git a/cmake/LuaHelpers.cmake b/cmake/LuaHelpers.cmake
deleted file mode 100644
index 0239460f2b..0000000000
--- a/cmake/LuaHelpers.cmake
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Functions to help checking for a Lua interpreter
-#
-
-# Check if a module is available in Lua
-function(check_lua_module LUA_PRG_PATH MODULE RESULT_VAR)
- execute_process(COMMAND ${LUA_PRG_PATH} -l "${MODULE}" -e ""
- RESULT_VARIABLE module_missing)
- if(module_missing)
- set(${RESULT_VAR} False PARENT_SCOPE)
- else()
- set(${RESULT_VAR} True PARENT_SCOPE)
- endif()
-endfunction()
-
-# Check Lua interpreter for dependencies
-function(check_lua_deps LUA_PRG_PATH MODULES RESULT_VAR)
- # Check if the lua interpreter at the given path
- # satisfies all Neovim dependencies
- message(STATUS "Checking Lua interpreter: ${LUA_PRG_PATH}")
- if(NOT EXISTS ${LUA_PRG_PATH})
- message(STATUS
- "[${LUA_PRG_PATH}] file not found")
- endif()
-
- foreach(module ${MODULES})
- check_lua_module(${LUA_PRG_PATH} ${module} has_module)
- if(NOT has_module)
- message(STATUS
- "[${LUA_PRG_PATH}] The '${module}' lua package is required for building Neovim")
- set(${RESULT_VAR} False PARENT_SCOPE)
- return()
- endif()
- endforeach()
-
- set(${RESULT_VAR} True PARENT_SCOPE)
-endfunction()
diff --git a/cmake/RunTests.cmake b/cmake/RunTests.cmake
index d724f43a5f..8d5b0d2402 100644
--- a/cmake/RunTests.cmake
+++ b/cmake/RunTests.cmake
@@ -1,13 +1,5 @@
# Set LC_ALL to meet expectations of some locale-sensitive tests.
set(ENV{LC_ALL} "en_US.UTF-8")
-
-if(POLICY CMP0012)
- # Avoid policy warning due to CI=true. This is needed even if the main
- # project has already set this policy as project settings aren't inherited
- # when using cmake script mode (-P).
- cmake_policy(SET CMP0012 NEW)
-endif()
-
set(ENV{VIMRUNTIME} ${WORKING_DIR}/runtime)
set(ENV{NVIM_RPLUGIN_MANIFEST} ${BUILD_DIR}/Xtest_rplugin_manifest)
set(ENV{XDG_CONFIG_HOME} ${BUILD_DIR}/Xtest_xdg/config)
@@ -72,15 +64,15 @@ endif()
set(ENV{SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_NAME}) # used by test/helpers.lua.
-# TODO: eventually always use NVIM_PRG as the runner
-if("${TEST_TYPE}" STREQUAL "unit")
- set(RUNNER_PRG ${NVIM_PRG} -ll ${WORKING_DIR}/test/busted_runner.lua)
-else()
- set(RUNNER_PRG ${BUSTED_PRG})
+if(NOT WIN32)
+ # Tests assume POSIX "sh" and may fail if SHELL=fish. #24941 #6172
+ set(ENV{SHELL} sh)
endif()
execute_process(
- COMMAND ${RUNNER_PRG} -v -o test.busted.outputHandlers.${BUSTED_OUTPUT_TYPE}
+ # Note: because of "-ll" (low-level interpreter mode), some modules like
+ # _editor.lua are not loaded.
+ COMMAND ${NVIM_PRG} -ll ${WORKING_DIR}/test/lua_runner.lua ${DEPS_INSTALL_DIR} busted -v -o test.busted.outputHandlers.${BUSTED_OUTPUT_TYPE}
--lazy --helper=${TEST_DIR}/${TEST_TYPE}/preload.lua
--lpath=${BUILD_DIR}/?.lua
--lpath=${WORKING_DIR}/runtime/lua/?.lua
@@ -96,7 +88,7 @@ execute_process(
file(GLOB RM_FILES ${BUILD_DIR}/Xtest_*)
file(REMOVE_RECURSE ${RM_FILES})
-if(NOT res EQUAL 0)
+if(res)
message(STATUS "Tests exited non-zero: ${res}")
if("${err}" STREQUAL "")
message(STATUS "No output to stderr.")
@@ -105,7 +97,7 @@ if(NOT res EQUAL 0)
endif()
# Dump the logfile on CI (if not displayed and moved already).
- if($ENV{CI})
+ if(CI_BUILD)
if(EXISTS $ENV{NVIM_LOG_FILE} AND NOT EXISTS $ENV{NVIM_LOG_FILE}.displayed)
file(READ $ENV{NVIM_LOG_FILE} out)
message(STATUS "$NVIM_LOG_FILE: $ENV{NVIM_LOG_FILE}\n${out}")
diff --git a/cmake/Util.cmake b/cmake/Util.cmake
index e15b44d29a..01d34d6752 100644
--- a/cmake/Util.cmake
+++ b/cmake/Util.cmake
@@ -4,7 +4,6 @@
# depends on the value of TOUCH_STRATEGY.
#
# Options:
-# REQUIRED - Abort if COMMAND doesn't exist.
#
# Single value arguments:
# TARGET - Name of the target
@@ -53,7 +52,7 @@
# files.
function(add_glob_target)
cmake_parse_arguments(ARG
- "REQUIRED"
+ ""
"TARGET;COMMAND;GLOB_PAT;TOUCH_STRATEGY"
"FLAGS;FILES;GLOB_DIRS;EXCLUDE"
${ARGN}
@@ -61,14 +60,8 @@ function(add_glob_target)
if(NOT ARG_COMMAND)
add_custom_target(${ARG_TARGET})
- if(ARG_REQUIRED)
- add_custom_command(TARGET ${ARG_TARGET}
- COMMAND ${CMAKE_COMMAND} -E echo "${ARG_TARGET}: ${ARG_COMMAND} not found"
- COMMAND false)
- else()
- add_custom_command(TARGET ${ARG_TARGET}
- COMMAND ${CMAKE_COMMAND} -E echo "${ARG_TARGET} SKIP: ${ARG_COMMAND} not found")
- endif()
+ add_custom_command(TARGET ${ARG_TARGET}
+ COMMAND ${CMAKE_COMMAND} -E echo "${ARG_TARGET} SKIP: ${ARG_COMMAND} not found")
return()
endif()
@@ -169,8 +162,8 @@ endfunction()
# cmake -B build
# cmake --build build --config Release
#
-# Passing CMAKE_BUILD_TYPE for multi-config generators will now not only
-# not be used, but also generate a warning for the user.
+# Passing CMAKE_BUILD_TYPE for multi-config generators will not only not be
+# used, but also generate a warning for the user.
function(set_default_buildtype)
set(allowableBuildTypes Debug Release MinSizeRel RelWithDebInfo)
@@ -193,3 +186,14 @@ function(set_default_buildtype)
endif()
endif()
endfunction()
+
+# Check if a module is available in Lua
+function(check_lua_module LUA_PRG_PATH MODULE RESULT_VAR)
+ execute_process(COMMAND ${LUA_PRG_PATH} -l "${MODULE}" -e ""
+ RESULT_VARIABLE module_missing)
+ if(module_missing)
+ set(${RESULT_VAR} FALSE PARENT_SCOPE)
+ else()
+ set(${RESULT_VAR} TRUE PARENT_SCOPE)
+ endif()
+endfunction()
diff --git a/cmake/WindowsDllCopy.cmake b/cmake/WindowsDllCopy.cmake
index fbbabf3a0c..c972d88f57 100644
--- a/cmake/WindowsDllCopy.cmake
+++ b/cmake/WindowsDllCopy.cmake
@@ -6,13 +6,13 @@
# - CMAKE_PREFIX_PATH: A list of directories to search for dependencies
if(NOT DEFINED BINARY)
- message(FATAL_ERROR "Missing required argument -DBINARY=")
+ message(FATAL_ERROR "Missing required argument -D BINARY=")
endif()
if(NOT DEFINED DST)
- message(FATAL_ERROR "Missing required arguments -DDST=")
+ message(FATAL_ERROR "Missing required arguments -D DST=")
endif()
if(NOT DEFINED CMAKE_PREFIX_PATH)
- message(FATAL_ERROR "Missing required arguments -DCMAKE_PREFIX_PATH=")
+ message(FATAL_ERROR "Missing required arguments -D CMAKE_PREFIX_PATH=")
endif()
include(GetPrerequisites)
@@ -23,8 +23,9 @@ foreach(DLL_NAME ${DLLS})
message(FATAL_ERROR "Unable to find dependency ${DLL_NAME}")
endif()
- message("Copying ${DLL_NAME} to ${DST}")
+ if(CI_BUILD)
+ message("Copying ${DLL_NAME} to ${DST}")
+ endif()
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${DLL_PATH} ${DST})
unset(DLL_PATH CACHE)
endforeach()
-