robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

dundargocbuild: cmake fixes404fdb0f36

master
1.8 KiB67 linesraw
1find_path2(LIBUV_INCLUDE_DIR uv.h)
2find_library2(LIBUV_LIBRARY NAMES uv_a uv libuv)
3
4set(LIBUV_LIBRARIES ${LIBUV_LIBRARY})
5
6check_library_exists(dl dlopen "dlfcn.h" HAVE_LIBDL)
7if(HAVE_LIBDL)
8  list(APPEND LIBUV_LIBRARIES dl)
9endif()
10
11check_library_exists(kstat kstat_lookup "kstat.h" HAVE_LIBKSTAT)
12if(HAVE_LIBKSTAT)
13  list(APPEND LIBUV_LIBRARIES kstat)
14endif()
15
16check_library_exists(kvm kvm_open "kvm.h" HAVE_LIBKVM)
17if(HAVE_LIBKVM AND NOT CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
18  list(APPEND LIBUV_LIBRARIES kvm)
19endif()
20
21check_library_exists(nsl gethostbyname "nsl.h" HAVE_LIBNSL)
22if(HAVE_LIBNSL)
23  list(APPEND LIBUV_LIBRARIES nsl)
24endif()
25
26check_library_exists(perfstat perfstat_cpu "libperfstat.h" HAVE_LIBPERFSTAT)
27if(HAVE_LIBPERFSTAT)
28  list(APPEND LIBUV_LIBRARIES perfstat)
29endif()
30
31check_library_exists(rt clock_gettime "time.h" HAVE_LIBRT)
32if(HAVE_LIBRT)
33  list(APPEND LIBUV_LIBRARIES rt)
34endif()
35
36check_library_exists(sendfile sendfile "" HAVE_LIBSENDFILE)
37if(HAVE_LIBSENDFILE)
38  list(APPEND LIBUV_LIBRARIES sendfile)
39endif()
40
41if(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)
50endif()
51
52find_package(Threads)
53if(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})
58endif()
59
60find_package_handle_standard_args(Libuv DEFAULT_MSG
61                                  LIBUV_LIBRARY LIBUV_INCLUDE_DIR)
62
63mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARY)
64
65add_library(libuv INTERFACE)
66target_include_directories(libuv SYSTEM BEFORE INTERFACE ${LIBUV_INCLUDE_DIR})
67target_link_libraries(libuv INTERFACE ${LIBUV_LIBRARIES})