neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

FindLibuv.cmake (1871B)


      1 find_path2(LIBUV_INCLUDE_DIR uv.h)
      2 find_library2(LIBUV_LIBRARY NAMES uv_a uv libuv)
      3 
      4 set(LIBUV_LIBRARIES ${LIBUV_LIBRARY})
      5 
      6 check_library_exists(dl dlopen "dlfcn.h" HAVE_LIBDL)
      7 if(HAVE_LIBDL)
      8  list(APPEND LIBUV_LIBRARIES dl)
      9 endif()
     10 
     11 check_library_exists(kstat kstat_lookup "kstat.h" HAVE_LIBKSTAT)
     12 if(HAVE_LIBKSTAT)
     13  list(APPEND LIBUV_LIBRARIES kstat)
     14 endif()
     15 
     16 check_library_exists(kvm kvm_open "kvm.h" HAVE_LIBKVM)
     17 if(HAVE_LIBKVM AND NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
     18  list(APPEND LIBUV_LIBRARIES kvm)
     19 endif()
     20 
     21 check_library_exists(nsl gethostbyname "nsl.h" HAVE_LIBNSL)
     22 if(HAVE_LIBNSL)
     23  list(APPEND LIBUV_LIBRARIES nsl)
     24 endif()
     25 
     26 check_library_exists(perfstat perfstat_cpu "libperfstat.h" HAVE_LIBPERFSTAT)
     27 if(HAVE_LIBPERFSTAT)
     28  list(APPEND LIBUV_LIBRARIES perfstat)
     29 endif()
     30 
     31 check_library_exists(rt clock_gettime "time.h" HAVE_LIBRT)
     32 if(HAVE_LIBRT)
     33  list(APPEND LIBUV_LIBRARIES rt)
     34 endif()
     35 
     36 check_library_exists(sendfile sendfile "" HAVE_LIBSENDFILE)
     37 if(HAVE_LIBSENDFILE)
     38  list(APPEND LIBUV_LIBRARIES sendfile)
     39 endif()
     40 
     41 if(WIN32)
     42  # check_library_exists() does not work for Win32 API calls in X86 due to name
     43  # mangling calling conventions
     44  list(APPEND LIBUV_LIBRARIES
     45    iphlpapi
     46    psapi
     47    userenv
     48    ws2_32
     49    dbghelp)
     50 endif()
     51 
     52 find_package(Threads)
     53 if(Threads_FOUND)
     54  # TODO: Fix the cmake file to properly handle static deps for bundled builds.
     55  # Meanwhile just include the threads library if CMake tells us there's one to
     56  # use.
     57  list(APPEND LIBUV_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
     58 endif()
     59 
     60 find_package_handle_standard_args(Libuv DEFAULT_MSG
     61                                  LIBUV_LIBRARY LIBUV_INCLUDE_DIR)
     62 
     63 mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARY)
     64 
     65 add_library(libuv INTERFACE)
     66 target_include_directories(libuv SYSTEM BEFORE INTERFACE ${LIBUV_INCLUDE_DIR})
     67 target_link_libraries(libuv INTERFACE ${LIBUV_LIBRARIES})