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:
dundargoc
2023-10-10 23:18:45 +02:00
committed by dundargoc
parent a4c4b39d55
commit b80a8e2c16
14 changed files with 59 additions and 32 deletions

View File

@ -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)