mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 13:15:09 -07:00
b80a8e2c16
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.
30 lines
1.1 KiB
CMake
30 lines
1.1 KiB
CMake
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()
|