aboutsummaryrefslogtreecommitdiff
path: root/cmake/FindLibuv.cmake
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-11-30 20:35:25 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-11-30 20:35:25 +0000
commit1b7b916b7631ddf73c38e3a0070d64e4636cb2f3 (patch)
treecd08258054db80bb9a11b1061bb091c70b76926a /cmake/FindLibuv.cmake
parenteaa89c11d0f8aefbb512de769c6c82f61a8baca3 (diff)
parent4a8bf24ac690004aedf5540fa440e788459e5e34 (diff)
downloadrneovim-aucmd_textputpost.tar.gz
rneovim-aucmd_textputpost.tar.bz2
rneovim-aucmd_textputpost.zip
Merge remote-tracking branch 'upstream/master' into aucmd_textputpostaucmd_textputpost
Diffstat (limited to 'cmake/FindLibuv.cmake')
-rw-r--r--cmake/FindLibuv.cmake61
1 files changed, 61 insertions, 0 deletions
diff --git a/cmake/FindLibuv.cmake b/cmake/FindLibuv.cmake
new file mode 100644
index 0000000000..19315388dd
--- /dev/null
+++ b/cmake/FindLibuv.cmake
@@ -0,0 +1,61 @@
+find_path2(LIBUV_INCLUDE_DIR uv.h)
+find_library2(LIBUV_LIBRARY NAMES uv_a uv)
+
+set(LIBUV_LIBRARIES ${LIBUV_LIBRARY})
+
+check_library_exists(dl dlopen "dlfcn.h" HAVE_LIBDL)
+if(HAVE_LIBDL)
+ list(APPEND LIBUV_LIBRARIES dl)
+endif()
+
+check_library_exists(kstat kstat_lookup "kstat.h" HAVE_LIBKSTAT)
+if(HAVE_LIBKSTAT)
+ list(APPEND LIBUV_LIBRARIES kstat)
+endif()
+
+check_library_exists(kvm kvm_open "kvm.h" HAVE_LIBKVM)
+if(HAVE_LIBKVM AND NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
+ list(APPEND LIBUV_LIBRARIES kvm)
+endif()
+
+check_library_exists(nsl gethostbyname "nsl.h" HAVE_LIBNSL)
+if(HAVE_LIBNSL)
+ list(APPEND LIBUV_LIBRARIES nsl)
+endif()
+
+check_library_exists(perfstat perfstat_cpu "libperfstat.h" HAVE_LIBPERFSTAT)
+if(HAVE_LIBPERFSTAT)
+ list(APPEND LIBUV_LIBRARIES perfstat)
+endif()
+
+check_library_exists(rt clock_gettime "time.h" HAVE_LIBRT)
+if(HAVE_LIBRT)
+ list(APPEND LIBUV_LIBRARIES rt)
+endif()
+
+check_library_exists(sendfile sendfile "" HAVE_LIBSENDFILE)
+if(HAVE_LIBSENDFILE)
+ list(APPEND LIBUV_LIBRARIES sendfile)
+endif()
+
+if(WIN32)
+ # check_library_exists() does not work for Win32 API calls in X86 due to name
+ # mangling calling conventions
+ list(APPEND LIBUV_LIBRARIES iphlpapi)
+ list(APPEND LIBUV_LIBRARIES psapi)
+ list(APPEND LIBUV_LIBRARIES userenv)
+ list(APPEND LIBUV_LIBRARIES ws2_32)
+endif()
+
+find_package(Threads)
+if(Threads_FOUND)
+ # TODO: Fix the cmake file to properly handle static deps for bundled builds.
+ # Meanwhile just include the threads library if CMake tells us there's one to
+ # use.
+ list(APPEND LIBUV_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
+endif()
+
+find_package_handle_standard_args(Libuv DEFAULT_MSG
+ LIBUV_LIBRARY LIBUV_INCLUDE_DIR)
+
+mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARY)