diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:19:48 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-03-09 13:20:02 +0000 |
commit | 58daab21cd043e1dc37024a7f99b396788372918 (patch) | |
tree | 96771e43bb69f7c1c2b0b4f7374cb74d7866d0cb /fluent-bit/cmake/FindLibEdit.cmake | |
parent | Releasing debian version 1.43.2-1. (diff) | |
download | netdata-58daab21cd043e1dc37024a7f99b396788372918.tar.xz netdata-58daab21cd043e1dc37024a7f99b396788372918.zip |
Merging upstream version 1.44.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'fluent-bit/cmake/FindLibEdit.cmake')
-rw-r--r-- | fluent-bit/cmake/FindLibEdit.cmake | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/fluent-bit/cmake/FindLibEdit.cmake b/fluent-bit/cmake/FindLibEdit.cmake new file mode 100644 index 000000000..ea8bdfd80 --- /dev/null +++ b/fluent-bit/cmake/FindLibEdit.cmake @@ -0,0 +1,72 @@ +# FindLibEdit +# ----------- +# +# Find libedit library and headers +# +# The module defines the following variables: +# +# :: +# +# libedit_FOUND - true if libedit was found +# libedit_INCLUDE_DIRS - include search path +# libedit_LIBRARIES - libraries to link +# libedit_VERSION - version number + +# This cmake file is based on LLVM Project one's. +# +# Copyright (c) 2018-2022 LLVM Project +# + +if(libedit_INCLUDE_DIRS AND libedit_LIBRARIES) + set(libedit_FOUND TRUE) +else() + find_package(PkgConfig QUIET) + pkg_check_modules(PC_LIBEDIT QUIET libedit) + + find_path(libedit_INCLUDE_DIRS + NAMES + histedit.h + HINTS + ${PC_LIBEDIT_INCLUDEDIR} + ${PC_LIBEDIT_INCLUDE_DIRS} + ${CMAKE_INSTALL_FULL_INCLUDEDIR}) + find_library(libedit_LIBRARIES + NAMES + edit libedit + HINTS + ${PC_LIBEDIT_LIBDIR} + ${PC_LIBEDIT_LIBRARY_DIRS} + ${CMAKE_INSTALL_FULL_LIBDIR}) + + if(libedit_INCLUDE_DIRS AND EXISTS "${libedit_INCLUDE_DIRS}/histedit.h") + file(STRINGS "${libedit_INCLUDE_DIRS}/histedit.h" + libedit_major_version_str + REGEX "^#define[ \t]+LIBEDIT_MAJOR[ \t]+[0-9]+") + string(REGEX REPLACE "^#define[ \t]+LIBEDIT_MAJOR[ \t]+([0-9]+)" "\\1" + LIBEDIT_MAJOR_VERSION "${libedit_major_version_str}") + + file(STRINGS "${libedit_INCLUDE_DIRS}/histedit.h" + libedit_minor_version_str + REGEX "^#define[ \t]+LIBEDIT_MINOR[ \t]+[0-9]+") + string(REGEX REPLACE "^#define[ \t]+LIBEDIT_MINOR[ \t]+([0-9]+)" "\\1" + LIBEDIT_MINOR_VERSION "${libedit_minor_version_str}") + + set(libedit_VERSION_STRING "${libedit_major_version}.${libedit_minor_version}") + endif() + + include(FindPackageHandleStandardArgs) + find_package_handle_standard_args(LibEdit + REQUIRED_VARS + libedit_INCLUDE_DIRS + libedit_LIBRARIES + VERSION_VAR + libedit_VERSION_STRING) + mark_as_advanced(libedit_INCLUDE_DIRS libedit_LIBRARIES) +endif() + +if (libedit_INCLUDE_DIRS AND libedit_LIBRARIES AND NOT TARGET LibEdit::LibEdit) + add_library(LibEdit::LibEdit UNKNOWN IMPORTED) + set_target_properties(LibEdit::LibEdit PROPERTIES + IMPORTED_LOCATION ${libedit_LIBRARIES} + INTERFACE_INCLUDE_DIRECTORIES ${libedit_INCLUDE_DIRS}) +endif() |