2019-07-22 01:39:56 +02:00
|
|
|
if(NOT WIN32)
|
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
2019-04-30 01:48:43 +02:00
|
|
|
enable_language(RC)
|
|
|
|
|
2019-07-21 18:05:51 +02:00
|
|
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
2019-07-29 01:31:07 +02:00
|
|
|
if (MSVC OR MSVC_VERSION)
|
2019-07-23 00:20:17 +02:00
|
|
|
add_compile_options(/EHca /arch:AVX2 /MD)
|
|
|
|
add_definitions(-D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING)
|
2019-08-27 15:47:44 +02:00
|
|
|
# If we're building a lokinet for windows, but need to target ancient hardware
|
|
|
|
function(check_working_cxx_atomics64 varname)
|
|
|
|
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -arch:IA32")
|
|
|
|
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})
|
|
|
|
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
|
|
|
|
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! (What do, MSVC doesn't emit __atomic_load_x)")
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
if(EMBEDDED_CFG)
|
|
|
|
link_libatomic()
|
|
|
|
endif()
|
2019-07-31 01:42:13 +02:00
|
|
|
|
|
|
|
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
|
|
|
|
add_compile_options(-Wno-nonportable-system-include-path)
|
|
|
|
endif()
|
2019-07-29 01:31:07 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT MSVC_VERSION)
|
2019-05-06 04:33:19 +02:00
|
|
|
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wno-bad-function-cast>)
|
|
|
|
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wno-cast-function-type>)
|
|
|
|
# unlike unix where you get a *single* compiler ID string in .comment
|
|
|
|
# GNU ld sees fit to merge *all* the .ident sections in object files
|
|
|
|
# to .r[o]data section one after the other!
|
2019-07-29 01:31:07 +02:00
|
|
|
add_compile_options(-fno-ident -Wa,-mbig-obj)
|
2019-08-15 00:40:17 +02:00
|
|
|
link_libraries( -lshlwapi -ldbghelp )
|
2019-07-25 02:46:41 +02:00
|
|
|
add_definitions(-DWINVER=0x0500 -D_WIN32_WINNT=0x0500)
|
2019-08-02 05:53:22 +02:00
|
|
|
# Wait a minute, if we're not Microsoft C++, nor a Clang paired with Microsoft C++,
|
|
|
|
# then the only possible option has to be GNU or a GNU-linked Clang!
|
2019-08-27 15:47:44 +02:00
|
|
|
set(FS_LIB stdc++fs)
|
|
|
|
# If we're building a lokinet for windows, but need to target ancient hardware
|
|
|
|
function(check_working_cxx_atomics64 varname)
|
|
|
|
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -march=i486")
|
|
|
|
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})
|
|
|
|
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
|
|
|
|
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(EMBEDDED_CFG)
|
|
|
|
link_libatomic()
|
2019-07-25 02:46:41 +02:00
|
|
|
endif()
|
2019-05-06 04:33:19 +02:00
|
|
|
endif()
|
|
|
|
|
2019-04-30 01:48:43 +02:00
|
|
|
get_filename_component(LIBTUNTAP_IMPL ${TT_ROOT}/tuntap-windows.c ABSOLUTE)
|
|
|
|
get_filename_component(EV_SRC "llarp/ev/ev_win32.cpp" ABSOLUTE)
|
2019-07-17 21:35:49 +02:00
|
|
|
add_definitions(-DWIN32_LEAN_AND_MEAN -DWIN32 -DWINVER=0x0500)
|
2019-08-15 00:40:17 +02:00
|
|
|
set(EXE_LIBS ${STATIC_LIB} ${FS_LIB} ws2_32 iphlpapi)
|
2019-04-30 01:48:43 +02:00
|
|
|
|
|
|
|
if(RELEASE_MOTTO)
|
|
|
|
add_definitions(-DLLARP_RELEASE_MOTTO="${RELEASE_MOTTO}")
|
|
|
|
add_definitions(-DRELEASE_MOTTO=${RELEASE_MOTTO})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (NOT STATIC_LINK_RUNTIME AND NOT MSVC)
|
|
|
|
message("must ship compiler runtime libraries with this build: libwinpthread-1.dll, libgcc_s_dw2-1.dll, and libstdc++-6.dll")
|
|
|
|
message("for release builds, turn on STATIC_LINK_RUNTIME in cmake options")
|
2019-07-17 21:35:49 +02:00
|
|
|
endif()
|