mirror of
https://github.com/oxen-io/lokinet
synced 2023-12-14 06:53:00 +01:00
Add FindLibUV and migrate
This commit is contained in:
parent
96a4c027d7
commit
2cc180b6a4
5 changed files with 105 additions and 6 deletions
|
@ -26,6 +26,8 @@ include(cmake/target_link_libraries_system.cmake)
|
|||
include(cmake/add_import_library.cmake)
|
||||
include(cmake/add_log_tag.cmake)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
|
||||
|
||||
# Basic definitions
|
||||
set(LIB lokinet)
|
||||
set(SHARED_LIB ${LIB}-shared)
|
||||
|
@ -251,7 +253,7 @@ else()
|
|||
set(LIBTUNTAP_SRC ${LIBTUNTAP_SRC_BASE})
|
||||
endif()
|
||||
|
||||
set(LIBS ${MALLOC_LIB} ${FS_LIB} ${UV_LIB})
|
||||
set(LIBS ${MALLOC_LIB} ${FS_LIB} ${LIBUV_LIBRARY})
|
||||
|
||||
add_subdirectory(crypto)
|
||||
add_subdirectory(libutp)
|
||||
|
|
95
cmake/FindLibUV.cmake
Normal file
95
cmake/FindLibUV.cmake
Normal file
|
@ -0,0 +1,95 @@
|
|||
# Taken from https://github.com/neovim/neovim/blob/master/cmake/FindLibUV.cmake
|
||||
# - Try to find libuv
|
||||
# Once done, this will define
|
||||
#
|
||||
# LIBUV_FOUND - system has libuv
|
||||
# LIBUV_INCLUDE_DIRS - the libuv include directories
|
||||
# LIBUV_LIBRARIES - link these to use libuv
|
||||
#
|
||||
# Set the LIBUV_USE_STATIC variable to specify if static libraries should
|
||||
# be preferred to shared ones.
|
||||
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PC_LIBUV QUIET libuv)
|
||||
endif()
|
||||
|
||||
find_path(LIBUV_INCLUDE_DIR uv.h
|
||||
HINTS ${PC_LIBUV_INCLUDEDIR} ${PC_LIBUV_INCLUDE_DIRS})
|
||||
|
||||
# If we're asked to use static linkage, add libuv.a as a preferred library name.
|
||||
if(LIBUV_USE_STATIC)
|
||||
list(APPEND LIBUV_NAMES
|
||||
"${CMAKE_STATIC_LIBRARY_PREFIX}uv${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||
endif(LIBUV_USE_STATIC)
|
||||
|
||||
list(APPEND LIBUV_NAMES uv)
|
||||
|
||||
find_library(LIBUV_LIBRARY NAMES ${LIBUV_NAMES}
|
||||
HINTS ${PC_LIBUV_LIBDIR} ${PC_LIBUV_LIBRARY_DIRS})
|
||||
|
||||
mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARY)
|
||||
|
||||
if(PC_LIBUV_LIBRARIES)
|
||||
list(REMOVE_ITEM PC_LIBUV_LIBRARIES uv)
|
||||
endif()
|
||||
|
||||
set(LIBUV_LIBRARIES ${LIBUV_LIBRARY} ${PC_LIBUV_LIBRARIES})
|
||||
set(LIBUV_INCLUDE_DIRS ${LIBUV_INCLUDE_DIR})
|
||||
|
||||
# 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()
|
||||
|
||||
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()
|
||||
|
||||
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)
|
|
@ -2,11 +2,12 @@ add_definitions(-DUNIX)
|
|||
add_definitions(-DPOSIX)
|
||||
|
||||
if (STATIC_LINK_RUNTIME)
|
||||
find_library(UV_LIB NAMES libuv.a)
|
||||
else()
|
||||
find_library(UV_LIB NAMES uv)
|
||||
set(LIBUV_USE_STATIC ON)
|
||||
endif()
|
||||
|
||||
find_package(LibUV 1.28.0 REQUIRED)
|
||||
include_directories(SYSTEM ${LIBUV_INCLUDE_DIRS})
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||
set(FS_LIB stdc++fs)
|
||||
get_filename_component(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-linux.c ABSOLUTE)
|
||||
|
|
|
@ -5,5 +5,5 @@ add_library(${ABYSS_LIB} "${CMAKE_CURRENT_SOURCE_DIR}/src/md5.cpp"
|
|||
|
||||
target_include_directories(${ABYSS_LIB} PUBLIC include)
|
||||
if(NOT WIN32)
|
||||
target_link_libraries(${ABYSS_LIB} PUBLIC ${PLATFORM_LIB} uv)
|
||||
target_link_libraries(${ABYSS_LIB} PUBLIC ${PLATFORM_LIB} ${LIBUV_LIBRARY})
|
||||
endif()
|
|
@ -1,4 +1,5 @@
|
|||
#ifndef LLARP_EV_LIBUV_HPP
|
||||
#define LLARP_EV_LIBUV_HPP
|
||||
#include <ev/ev.hpp>
|
||||
#include <uv.h>
|
||||
#include <vector>
|
||||
|
|
Loading…
Reference in a new issue