summaryrefslogtreecommitdiffstats
path: root/cmake/FindLibev.cmake
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 07:30:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 07:30:55 +0000
commit17e81f2cd1843f01838245eae7b5ed5edf83d6be (patch)
treea0f685dff11ce5a2dc546a7b46a48bae5d1c0140 /cmake/FindLibev.cmake
parentInitial commit. (diff)
downloadngtcp2-17e81f2cd1843f01838245eae7b5ed5edf83d6be.tar.xz
ngtcp2-17e81f2cd1843f01838245eae7b5ed5edf83d6be.zip
Adding upstream version 0.12.1+dfsg.upstream/0.12.1+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cmake/FindLibev.cmake')
-rw-r--r--cmake/FindLibev.cmake38
1 files changed, 38 insertions, 0 deletions
diff --git a/cmake/FindLibev.cmake b/cmake/FindLibev.cmake
new file mode 100644
index 0000000..71e4508
--- /dev/null
+++ b/cmake/FindLibev.cmake
@@ -0,0 +1,38 @@
+# - Try to find libev
+# Once done this will define
+# LIBEV_FOUND - System has libev
+# LIBEV_INCLUDE_DIRS - The libev include directories
+# LIBEV_LIBRARIES - The libraries needed to use libev
+
+find_path(LIBEV_INCLUDE_DIR
+ NAMES ev.h
+)
+find_library(LIBEV_LIBRARY
+ NAMES ev
+)
+
+if(LIBEV_INCLUDE_DIR)
+ file(STRINGS "${LIBEV_INCLUDE_DIR}/ev.h"
+ LIBEV_VERSION_MAJOR REGEX "^#define[ \t]+EV_VERSION_MAJOR[ \t]+[0-9]+")
+ file(STRINGS "${LIBEV_INCLUDE_DIR}/ev.h"
+ LIBEV_VERSION_MINOR REGEX "^#define[ \t]+EV_VERSION_MINOR[ \t]+[0-9]+")
+ string(REGEX REPLACE "[^0-9]+" "" LIBEV_VERSION_MAJOR "${LIBEV_VERSION_MAJOR}")
+ string(REGEX REPLACE "[^0-9]+" "" LIBEV_VERSION_MINOR "${LIBEV_VERSION_MINOR}")
+ set(LIBEV_VERSION "${LIBEV_VERSION_MAJOR}.${LIBEV_VERSION_MINOR}")
+ unset(LIBEV_VERSION_MINOR)
+ unset(LIBEV_VERSION_MAJOR)
+endif()
+
+include(FindPackageHandleStandardArgs)
+# handle the QUIETLY and REQUIRED arguments and set LIBEV_FOUND to TRUE
+# if all listed variables are TRUE and the requested version matches.
+find_package_handle_standard_args(Libev REQUIRED_VARS
+ LIBEV_LIBRARY LIBEV_INCLUDE_DIR
+ VERSION_VAR LIBEV_VERSION)
+
+if(LIBEV_FOUND)
+ set(LIBEV_LIBRARIES ${LIBEV_LIBRARY})
+ set(LIBEV_INCLUDE_DIRS ${LIBEV_INCLUDE_DIR})
+endif()
+
+mark_as_advanced(LIBEV_INCLUDE_DIR LIBEV_LIBRARY)