From 4cf4ae93df6af09ef3a0df678bb3d154b65bf731 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Thu, 2 Mar 2023 22:50:43 +0100 Subject: build: cmake cleanup (#22251) - Remove unused code - Use consistent casing. Variable names such as LibLuV_LIBRARIES is needlessly jarring, even if the name might be technically correct. - Use title casing for packages. find_package(unibilium) requires the find_module to be named "Findunibilium.cmake", which makes it harder to spot when scanning the files. Instead, use "Unibilium". --- cmake/FindLibvterm.cmake | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 cmake/FindLibvterm.cmake (limited to 'cmake/FindLibvterm.cmake') diff --git a/cmake/FindLibvterm.cmake b/cmake/FindLibvterm.cmake new file mode 100644 index 0000000000..ad2e682b30 --- /dev/null +++ b/cmake/FindLibvterm.cmake @@ -0,0 +1,22 @@ +find_path(LIBVTERM_INCLUDE_DIR vterm.h) +find_library(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") + string(REGEX MATCH "[0-9]+" VTERM_VERSION_MAJOR ${VTERM_VERSION_MAJOR}) + + 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}) +endif() + +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 ${LIBVTERM_INCLUDE_DIR}) +target_link_libraries(libvterm INTERFACE ${LIBVTERM_LIBRARY}) + +mark_as_advanced(LIBVTERM_INCLUDE_DIR LIBVTERM_LIBRARY) -- cgit From b80a8e2c16b6d6eb16ac84232c27eb7cfa4a434a Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 10 Oct 2023 23:18:45 +0200 Subject: 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. --- cmake/FindLibvterm.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cmake/FindLibvterm.cmake') diff --git a/cmake/FindLibvterm.cmake b/cmake/FindLibvterm.cmake index ad2e682b30..f591f6853f 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") -- cgit From 7a5effb0f95e295c265fe09e7414d859a6d79657 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Wed, 25 Oct 2023 16:54:20 +0200 Subject: build: bump required minimum libvterm version to 0.3.3 Also add detection for libvterm patch version. --- cmake/FindLibvterm.cmake | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'cmake/FindLibvterm.cmake') diff --git a/cmake/FindLibvterm.cmake b/cmake/FindLibvterm.cmake index f591f6853f..68c2646d47 100644 --- a/cmake/FindLibvterm.cmake +++ b/cmake/FindLibvterm.cmake @@ -8,7 +8,16 @@ 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 -- cgit