aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2023-01-26 21:35:06 +0100
committerGitHub <noreply@github.com>2023-01-26 21:35:06 +0100
commit843c9025ae8b44b14d0908674c8874a51dc13a38 (patch)
treeb90cfcabef285ce18398be7b009cc54b41b11a8f
parent3c2bb1b2bec993cbcd6d65572c531aafbefa25a1 (diff)
downloadrneovim-843c9025ae8b44b14d0908674c8874a51dc13a38.tar.gz
rneovim-843c9025ae8b44b14d0908674c8874a51dc13a38.tar.bz2
rneovim-843c9025ae8b44b14d0908674c8874a51dc13a38.zip
build: check if libvterm version meets requirement (#22010)
The vterm.h file only specifies major and minor version, but not patch, meaning that requiring a specific patch number isn't currently possible.
-rw-r--r--cmake/FindLIBVTERM.cmake10
-rw-r--r--cmake/Findlibvterm.cmake20
-rwxr-xr-xsrc/nvim/CMakeLists.txt5
3 files changed, 22 insertions, 13 deletions
diff --git a/cmake/FindLIBVTERM.cmake b/cmake/FindLIBVTERM.cmake
deleted file mode 100644
index 469494ddfd..0000000000
--- a/cmake/FindLIBVTERM.cmake
+++ /dev/null
@@ -1,10 +0,0 @@
-# - Try to find libvterm
-# Once done this will define
-# LIBVTERM_FOUND - System has libvterm
-# LIBVTERM_INCLUDE_DIRS - The libvterm include directories
-# LIBVTERM_LIBRARIES - The libraries needed to use libvterm
-
-include(LibFindMacros)
-
-libfind_pkg_detect(LIBVTERM vterm FIND_PATH vterm.h FIND_LIBRARY vterm)
-libfind_process(LIBVTERM REQUIRED)
diff --git a/cmake/Findlibvterm.cmake b/cmake/Findlibvterm.cmake
new file mode 100644
index 0000000000..e73775d973
--- /dev/null
+++ b/cmake/Findlibvterm.cmake
@@ -0,0 +1,20 @@
+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 INTERFACE ${LIBVTERM_INCLUDE_DIR})
+target_link_libraries(main_lib INTERFACE ${LIBVTERM_LIBRARY})
diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt
index 2361210e59..faeef65261 100755
--- a/src/nvim/CMakeLists.txt
+++ b/src/nvim/CMakeLists.txt
@@ -30,9 +30,8 @@ find_package(LibTermkey 0.22 REQUIRED)
target_include_directories(main_lib SYSTEM BEFORE INTERFACE ${LIBTERMKEY_INCLUDE_DIRS})
target_link_libraries(main_lib INTERFACE ${LIBTERMKEY_LIBRARIES})
-find_package(LIBVTERM 0.3 REQUIRED)
-target_include_directories(main_lib SYSTEM BEFORE INTERFACE ${LIBVTERM_INCLUDE_DIRS})
-target_link_libraries(main_lib INTERFACE ${LIBVTERM_LIBRARIES})
+find_package(libvterm 0.3 REQUIRED)
+target_link_libraries(main_lib INTERFACE libvterm)
find_package(Iconv REQUIRED)
target_include_directories(main_lib SYSTEM BEFORE INTERFACE ${Iconv_INCLUDE_DIRS})