2014-02-24 13:57:04 -07:00
|
|
|
# - Try to find libuv
|
|
|
|
# Once done, this will define
|
|
|
|
#
|
2014-03-03 08:09:06 -07:00
|
|
|
# LIBUV_FOUND - system has libuv
|
|
|
|
# LIBUV_INCLUDE_DIRS - the libuv include directories
|
|
|
|
# LIBUV_LIBRARIES - link these to use libuv
|
2014-02-26 10:36:06 -07:00
|
|
|
#
|
2014-03-03 08:09:06 -07:00
|
|
|
# Set the LIBUV_USE_STATIC variable to specify if static libraries should
|
2014-02-26 10:36:06 -07:00
|
|
|
# be preferred to shared ones.
|
2014-02-24 13:57:04 -07:00
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
if(NOT LIBUV_USE_BUNDLED)
|
|
|
|
find_package(PkgConfig)
|
|
|
|
if (PKG_CONFIG_FOUND)
|
|
|
|
pkg_check_modules(PC_LIBUV QUIET libuv)
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(PC_LIBUV_INCLUDEDIR)
|
|
|
|
set(PC_LIBUV_INCLUDE_DIRS)
|
|
|
|
set(PC_LIBUV_LIBDIR)
|
|
|
|
set(PC_LIBUV_LIBRARY_DIRS)
|
|
|
|
set(LIMIT_SEARCH NO_DEFAULT_PATH)
|
|
|
|
endif()
|
2014-02-24 13:57:04 -07:00
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
find_path(LIBUV_INCLUDE_DIR uv.h
|
|
|
|
HINTS ${PC_LIBUV_INCLUDEDIR} ${PC_LIBUV_INCLUDE_DIRS}
|
|
|
|
${LIMIT_SEARCH})
|
2014-02-26 10:36:06 -07:00
|
|
|
|
|
|
|
# If we're asked to use static linkage, add libuv.a as a preferred library name.
|
2014-03-03 08:09:06 -07:00
|
|
|
if(LIBUV_USE_STATIC)
|
|
|
|
list(APPEND LIBUV_NAMES
|
|
|
|
"${CMAKE_STATIC_LIBRARY_PREFIX}uv${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
|
|
|
endif(LIBUV_USE_STATIC)
|
|
|
|
|
2014-07-14 17:06:17 -07:00
|
|
|
if(MSVC)
|
|
|
|
list(APPEND LIBUV_NAMES libuv)
|
|
|
|
else()
|
|
|
|
list(APPEND LIBUV_NAMES uv)
|
|
|
|
endif()
|
2014-03-03 08:09:06 -07:00
|
|
|
|
|
|
|
find_library(LIBUV_LIBRARY NAMES ${LIBUV_NAMES}
|
|
|
|
HINTS ${PC_LIBUV_LIBDIR} ${PC_LIBUV_LIBRARY_DIRS}
|
|
|
|
${LIMIT_SEARCH})
|
|
|
|
|
|
|
|
mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARY)
|
|
|
|
|
2015-02-24 12:00:02 -07:00
|
|
|
if(PC_LIBUV_LIBRARIES)
|
|
|
|
list(REMOVE_ITEM PC_LIBUV_LIBRARIES uv)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(LIBUV_LIBRARIES ${LIBUV_LIBRARY} ${PC_LIBUV_LIBRARIES})
|
2014-03-03 08:09:06 -07:00
|
|
|
set(LIBUV_INCLUDE_DIRS ${LIBUV_INCLUDE_DIR})
|
|
|
|
|
2014-03-09 05:40:55 -07:00
|
|
|
# Deal with the fact that libuv.pc is missing important dependency information.
|
|
|
|
|
|
|
|
include(CheckLibraryExists)
|
|
|
|
|
|
|
|
check_library_exists(dl dlopen "dlfcn.h" HAVE_LIBDL)
|
|
|
|
if(HAVE_LIBDL)
|
|
|
|
list(APPEND LIBUV_LIBRARIES dl)
|
|
|
|
endif()
|
|
|
|
|
2015-06-08 13:54:34 -07:00
|
|
|
check_library_exists(iphlpapi GetAdaptersAddresses "iphlpapi.h" HAVE_LIBIPHLPAPI)
|
|
|
|
if(HAVE_LIBIPHLPAPI)
|
|
|
|
list(APPEND LIBUV_LIBRARIES iphlpapi)
|
|
|
|
endif()
|
|
|
|
|
2014-03-09 05:40:55 -07:00
|
|
|
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)
|
|
|
|
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()
|
|
|
|
|
2015-06-08 13:54:34 -07:00
|
|
|
check_library_exists(psapi GetProcessMemoryInfo "psapi.h" HAVE_LIBPSAPI)
|
|
|
|
if(HAVE_LIBPSAPI)
|
|
|
|
list(APPEND LIBUV_LIBRARIES psapi)
|
|
|
|
endif()
|
|
|
|
|
2014-03-09 05:40:55 -07:00
|
|
|
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()
|
|
|
|
|
2015-06-08 13:54:34 -07:00
|
|
|
check_library_exists(userenv GetUserProfileDirectoryW "userenv.h" HAVE_LIBUSERENV)
|
|
|
|
if(HAVE_LIBUSERENV)
|
|
|
|
list(APPEND LIBUV_LIBRARIES userenv)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
check_library_exists(ws2_32 WSAStartup "winsock2.h" HAVE_LIBWS232)
|
|
|
|
if(HAVE_LIBWS232)
|
|
|
|
list(APPEND LIBUV_LIBRARIES ws2_32)
|
|
|
|
endif()
|
|
|
|
|
2014-03-03 08:09:06 -07:00
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
|
|
|
|
# handle the QUIETLY and REQUIRED arguments and set LIBUV_FOUND to TRUE
|
|
|
|
# if all listed variables are TRUE
|
|
|
|
find_package_handle_standard_args(LibUV DEFAULT_MSG
|
|
|
|
LIBUV_LIBRARY LIBUV_INCLUDE_DIR)
|
|
|
|
|
|
|
|
mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARY)
|