mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
build: adjust how find order is prioritized
Ensure bundled libraries and include directories are always searched first before any others. This will provide a more consistent experience as the search order of the builtin find_ functions can vary depending on system. This should make the build process faster when building with bundled deps as we limit the search to only the .deps directory. Separating the search between .deps and everything makes debugging find_-related problems simpler if you need to check how dependencies are found. For libraries, we divide the search process into the following order: 1. Only search in .deps directory and only search for static libraries. 2. Only search in .deps directory and search for all libraries. 3. Search everywhere and search for all libraries. Make an exception for FindLibintl.cmake as changing the search order seems to break some tests on macos.
This commit is contained in:
parent
a4c4b39d55
commit
b80a8e2c16
@ -31,6 +31,7 @@ include(FindPackageHandleStandardArgs)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
include(Deps)
|
||||
include(Find)
|
||||
include(InstallHelpers)
|
||||
include(PreventInTreeBuilds)
|
||||
include(Util)
|
||||
|
@ -141,11 +141,3 @@ elseif(MSVC)
|
||||
else()
|
||||
message(FATAL_ERROR "Trying to build luajit in an unsupported system ${CMAKE_SYSTEM_NAME}/${CMAKE_C_COMPILER_ID}")
|
||||
endif()
|
||||
|
||||
if (NOT MSVC)
|
||||
add_custom_target(clean_shared_libraries_luajit ALL
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D REMOVE_FILE_GLOB=${DEPS_LIB_DIR}/${CMAKE_SHARED_LIBRARY_PREFIX}*${CMAKE_SHARED_LIBRARY_SUFFIX}*
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/RemoveFiles.cmake)
|
||||
add_dependencies(clean_shared_libraries_luajit luajit)
|
||||
endif()
|
||||
|
@ -1,5 +0,0 @@
|
||||
file(GLOB_RECURSE FILES_TO_REMOVE ${REMOVE_FILE_GLOB})
|
||||
|
||||
if(FILES_TO_REMOVE)
|
||||
file(REMOVE ${FILES_TO_REMOVE})
|
||||
endif()
|
39
cmake/Find.cmake
Normal file
39
cmake/Find.cmake
Normal file
@ -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()
|
@ -1,8 +1,8 @@
|
||||
# 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.
|
||||
|
||||
find_path(ICONV_INCLUDE_DIR NAMES iconv.h)
|
||||
find_library(ICONV_LIBRARY NAMES iconv libiconv)
|
||||
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)
|
||||
|
@ -1,5 +1,5 @@
|
||||
find_path(LIBTERMKEY_INCLUDE_DIR termkey.h)
|
||||
find_library(LIBTERMKEY_LIBRARY NAMES termkey)
|
||||
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)
|
||||
|
@ -1,5 +1,5 @@
|
||||
find_path(LIBUV_INCLUDE_DIR uv.h)
|
||||
find_library(LIBUV_LIBRARY NAMES uv_a uv)
|
||||
find_path2(LIBUV_INCLUDE_DIR uv.h)
|
||||
find_library2(LIBUV_LIBRARY NAMES uv_a uv)
|
||||
|
||||
set(LIBUV_LIBRARIES ${LIBUV_LIBRARY})
|
||||
|
||||
|
@ -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")
|
||||
|
@ -1,4 +1,4 @@
|
||||
find_library(LPEG_LIBRARY NAMES lpeg_a lpeg liblpeg_a lpeg${CMAKE_SHARED_LIBRARY_SUFFIX} PATH_SUFFIXES lua/5.1)
|
||||
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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
find_path(LUAJIT_INCLUDE_DIR luajit.h
|
||||
find_path2(LUAJIT_INCLUDE_DIR luajit.h
|
||||
PATH_SUFFIXES luajit-2.1)
|
||||
|
||||
if(MSVC)
|
||||
@ -9,7 +9,7 @@ else()
|
||||
list(APPEND LUAJIT_NAMES luajit-5.1)
|
||||
endif()
|
||||
|
||||
find_library(LUAJIT_LIBRARY NAMES ${LUAJIT_NAMES})
|
||||
find_library2(LUAJIT_LIBRARY NAMES ${LUAJIT_NAMES})
|
||||
|
||||
find_package_handle_standard_args(Luajit DEFAULT_MSG
|
||||
LUAJIT_LIBRARY LUAJIT_INCLUDE_DIR)
|
||||
|
@ -1,5 +1,5 @@
|
||||
find_path(LUV_INCLUDE_DIR luv/luv.h PATH_SUFFIXES lua5.1)
|
||||
find_library(LUV_LIBRARY NAMES luv_a luv libluv_a luv${CMAKE_SHARED_LIBRARY_SUFFIX} PATH_SUFFIXES lua/5.1)
|
||||
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)
|
||||
|
@ -1,4 +1,4 @@
|
||||
find_path(MSGPACK_INCLUDE_DIR msgpack/version_master.h)
|
||||
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)
|
||||
@ -10,7 +10,7 @@ else()
|
||||
set(MSGPACK_VERSION_STRING)
|
||||
endif()
|
||||
|
||||
find_library(MSGPACK_LIBRARY NAMES msgpackc msgpack msgpackc_import msgpack-c
|
||||
find_library2(MSGPACK_LIBRARY NAMES msgpackc msgpack msgpackc_import msgpack-c
|
||||
NAMES_PER_DIR)
|
||||
|
||||
mark_as_advanced(MSGPACK_INCLUDE_DIR MSGPACK_LIBRARY)
|
||||
|
@ -1,5 +1,5 @@
|
||||
find_path(TREESITTER_INCLUDE_DIR tree_sitter/api.h)
|
||||
find_library(TREESITTER_LIBRARY NAMES tree-sitter)
|
||||
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)
|
||||
|
@ -1,5 +1,5 @@
|
||||
find_path(UNIBILIUM_INCLUDE_DIR unibilium.h)
|
||||
find_library(UNIBILIUM_LIBRARY unibilium)
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user