robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
404fdb0f36
master
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) 8list ( APPEND LIBUV_LIBRARIES dl ) 9endif () 10 11check_library_exists ( kstat kstat_lookup "kstat.h" HAVE_LIBKSTAT ) 12if ( HAVE_LIBKSTAT) 13list ( APPEND LIBUV_LIBRARIES kstat ) 14endif () 15 16check_library_exists ( kvm kvm_open "kvm.h" HAVE_LIBKVM ) 17if ( HAVE_LIBKVMAND NOT CMAKE_SYSTEM_NAMESTREQUAL "OpenBSD" ) 18list ( APPEND LIBUV_LIBRARIES kvm ) 19endif () 20 21check_library_exists ( nsl gethostbyname "nsl.h" HAVE_LIBNSL ) 22if ( HAVE_LIBNSL) 23list ( APPEND LIBUV_LIBRARIES nsl ) 24endif () 25 26check_library_exists ( perfstat perfstat_cpu "libperfstat.h" HAVE_LIBPERFSTAT ) 27if ( HAVE_LIBPERFSTAT) 28list ( APPEND LIBUV_LIBRARIES perfstat ) 29endif () 30 31check_library_exists ( rt clock_gettime "time.h" HAVE_LIBRT ) 32if ( HAVE_LIBRT) 33list ( APPEND LIBUV_LIBRARIES rt ) 34endif () 35 36check_library_exists ( sendfile sendfile "" HAVE_LIBSENDFILE ) 37if ( HAVE_LIBSENDFILE) 38list ( 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 44list ( APPEND LIBUV_LIBRARIES 45iphlpapi 46psapi 47userenv 48ws2_32 49dbghelp ) 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. 57list ( APPEND LIBUV_LIBRARIES ${ CMAKE_THREAD_LIBS_INIT }) 58endif () 59 60find_package_handle_standard_args ( Libuv DEFAULT_MSG 61LIBUV_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 })