|
|
|
@ -2,6 +2,9 @@ if(NOT UNIX)
|
|
|
|
|
return()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
|
include(CheckLibraryExists)
|
|
|
|
|
|
|
|
|
|
add_definitions(-DUNIX)
|
|
|
|
|
add_definitions(-DPOSIX)
|
|
|
|
|
|
|
|
|
@ -21,9 +24,46 @@ endif()
|
|
|
|
|
|
|
|
|
|
include_directories(${LIBUV_INCLUDE_DIRS})
|
|
|
|
|
|
|
|
|
|
function(check_working_cxx_atomics64 varname)
|
|
|
|
|
check_cxx_source_compiles("
|
|
|
|
|
#include <atomic>
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
std::atomic<uint64_t> x (0);
|
|
|
|
|
int main() {
|
|
|
|
|
uint64_t i = x.load(std::memory_order_relaxed);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
" ${varname})
|
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
|
|
function(link_libatomic)
|
|
|
|
|
check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITHOUT_LIB)
|
|
|
|
|
|
|
|
|
|
if(HAVE_CXX_ATOMICS64_WITHOUT_LIB)
|
|
|
|
|
message(STATUS "Have working 64bit atomics")
|
|
|
|
|
return()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
check_library_exists(atomic __atomic_load_8 "" HAVE_CXX_LIBATOMICS64)
|
|
|
|
|
if (HAVE_CXX_LIBATOMICS64)
|
|
|
|
|
message(STATUS "Have 64bit atomics via library")
|
|
|
|
|
list(APPEND CMAKE_REQUIRED_LIBRARIES "atomic")
|
|
|
|
|
check_working_cxx_atomics64(HAVE_CXX_ATOMICS64_WITH_LIB)
|
|
|
|
|
if (HAVE_CXX_ATOMICS64_WITH_LIB)
|
|
|
|
|
message(STATUS "Can link with libatomic")
|
|
|
|
|
link_libraries(-latomic)
|
|
|
|
|
return()
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
message(FATAL_ERROR "Host compiler must support 64-bit std::atomic!")
|
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
|
|
|
set(FS_LIB stdc++fs)
|
|
|
|
|
get_filename_component(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-unix-linux.c ABSOLUTE)
|
|
|
|
|
|
|
|
|
|
link_libatomic()
|
|
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
|
|
|
|
|
find_library(FS_LIB NAMES c++fs c++experimental stdc++fs)
|
|
|
|
|
if(FS_LIB STREQUAL FS_LIB-NOTFOUND)
|
|
|
|
|