|
|
|
@ -13,10 +13,13 @@ endmacro(add_cxxflags)
|
|
|
|
|
|
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
|
|
|
|
if(COMPILER_SUPPORTS_CXX11)
|
|
|
|
|
CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
|
|
|
|
|
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
|
|
|
|
add_cxxflags("-std=c++11")
|
|
|
|
|
elseif(COMPILER_SUPPORTS_CXX17)
|
|
|
|
|
add_cxxflags("-std=c++17")
|
|
|
|
|
else()
|
|
|
|
|
message(ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
|
|
|
|
|
message(ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 or C++17 support. Please use a different C++ compiler.")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
set(THREAD_LIB "-pthread")
|
|
|
|
@ -97,9 +100,9 @@ if(SODIUM_LIBRARIES)
|
|
|
|
|
set(SODIUM_LIB ${SODIUM_LIBRARIES})
|
|
|
|
|
else()
|
|
|
|
|
find_library (
|
|
|
|
|
SODIUM_LIB
|
|
|
|
|
NAMES sodium libsodium
|
|
|
|
|
HINTS "/usr/local/lib"
|
|
|
|
|
SODIUM_LIB
|
|
|
|
|
NAMES sodium libsodium
|
|
|
|
|
HINTS "/usr/local/lib"
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
@ -310,29 +313,85 @@ else()
|
|
|
|
|
|
|
|
|
|
if(WITH_STATIC)
|
|
|
|
|
add_library(${STATIC_LIB} STATIC ${LIB_SRC})
|
|
|
|
|
add_library(libbackport-static STATIC ${CPP_BACKPORT_SRC})
|
|
|
|
|
add_library(libllarpplatform-static STATIC ${LIB_PLATFORM_SRC})
|
|
|
|
|
target_link_libraries(libllarpplatform-static ${THREAD_LIB})
|
|
|
|
|
target_link_libraries(${STATIC_LIB} ${LIBS} libbackport-static libllarpplatform-static)
|
|
|
|
|
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
|
|
|
|
add_library(backport-static STATIC ${CPP_BACKPORT_SRC})
|
|
|
|
|
endif(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
|
|
|
|
add_library(llarpplatform-static STATIC ${LIB_PLATFORM_SRC})
|
|
|
|
|
target_link_libraries(llarpplatform-static ${THREAD_LIB})
|
|
|
|
|
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
|
|
|
|
target_link_libraries(${STATIC_LIB} ${LIBS} backport-static llarpplatform-static)
|
|
|
|
|
else()
|
|
|
|
|
target_link_libraries(${STATIC_LIB} ${LIBS} llarpplatform-static)
|
|
|
|
|
endif(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
|
|
|
|
if(NOT WITH_SHARED)
|
|
|
|
|
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} libbackport-static libllarpplatform-static)
|
|
|
|
|
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} libbackport-static libllarpplatform-static)
|
|
|
|
|
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} libbackport-static libllarpplatform-static)
|
|
|
|
|
target_link_libraries(dns libllarpplatform-static pthread)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
|
|
|
|
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static)
|
|
|
|
|
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static)
|
|
|
|
|
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static)
|
|
|
|
|
if (MINGW)
|
|
|
|
|
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static ws2_32 stdc++fs)
|
|
|
|
|
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static ws2_32 stdc++fs)
|
|
|
|
|
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static ws2_32 stdc++fs)
|
|
|
|
|
elseif(WIN32)
|
|
|
|
|
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static ws2_32)
|
|
|
|
|
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static ws2_32)
|
|
|
|
|
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static ws2_32)
|
|
|
|
|
endif(MINGW)
|
|
|
|
|
else()
|
|
|
|
|
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static)
|
|
|
|
|
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static)
|
|
|
|
|
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static)
|
|
|
|
|
if (MINGW)
|
|
|
|
|
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static ws2_32 stdc++fs)
|
|
|
|
|
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static ws2_32 stdc++fs)
|
|
|
|
|
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static ws2_32 stdc++fs)
|
|
|
|
|
elseif(WIN32)
|
|
|
|
|
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static ws2_32)
|
|
|
|
|
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static ws2_32)
|
|
|
|
|
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static ws2_32)
|
|
|
|
|
endif(MINGW)
|
|
|
|
|
endif(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
|
|
|
|
if (MINGW)
|
|
|
|
|
target_link_libraries(dns ${STATIC_LIB} llarpplatform-static pthread ws2_32 stdc++fs)
|
|
|
|
|
elseif(WIN32)
|
|
|
|
|
target_link_libraries(dns ${STATIC_LIB} llarpplatform-static pthread ws2_32)
|
|
|
|
|
endif(MINGW)
|
|
|
|
|
target_link_libraries(dns ${STATIC_LIB} llarpplatform-static pthread)
|
|
|
|
|
endif(NOT WITH_SHARED)
|
|
|
|
|
endif(WITH_STATIC)
|
|
|
|
|
|
|
|
|
|
if(WITH_SHARED)
|
|
|
|
|
add_library(${SHARED_LIB} SHARED ${LIB_SRC})
|
|
|
|
|
add_library(libbackport SHARED ${CPP_BACKPORT_SRC})
|
|
|
|
|
add_library(libllarpplatform SHARED ${LIB_PLATFORM_SRC})
|
|
|
|
|
target_link_libraries(${SHARED_LIB} ${LIBS} libbackport libllarpplatform)
|
|
|
|
|
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
|
|
|
|
add_library(backport SHARED ${CPP_BACKPORT_SRC})
|
|
|
|
|
endif(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
|
|
|
|
add_library(llarpplatform SHARED ${LIB_PLATFORM_SRC})
|
|
|
|
|
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
|
|
|
|
target_link_libraries(${SHARED_LIB} ${LIBS} backport llarpplatform)
|
|
|
|
|
if (MINGW)
|
|
|
|
|
target_link_libraries(${SHARED_LIB} ${LIBS} backport llarpplatform ws2_32 stdc++fs)
|
|
|
|
|
elseif(WIN32)
|
|
|
|
|
target_link_libraries(${SHARED_LIB} ${LIBS} backport llarpplatform ws2_32)
|
|
|
|
|
endif(MINGW)
|
|
|
|
|
else()
|
|
|
|
|
target_link_libraries(${SHARED_LIB} ${LIBS} llarpplatform)
|
|
|
|
|
if (MINGW)
|
|
|
|
|
target_link_libraries(${SHARED_LIB} ${LIBS} llarpplatform ws2_32 stdc++fs)
|
|
|
|
|
elseif(WIN32)
|
|
|
|
|
target_link_libraries(${SHARED_LIB} ${LIBS} llarpplatform ws2_32)
|
|
|
|
|
endif(MINGW)
|
|
|
|
|
endif(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
|
|
|
|
if(NOT WITH_STATIC)
|
|
|
|
|
target_link_libraries(${EXE} ${SHARED_LIB} libbackport libllarpplatform)
|
|
|
|
|
target_link_libraries(${CLIENT_EXE} ${SHARED_LIB} libbackport libllarpplatform)
|
|
|
|
|
target_link_libraries(rcutil ${SHARED_LIB} libbackport libllarpplatform)
|
|
|
|
|
target_link_libraries(dns libllarpplatform pthread)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
|
|
|
|
target_link_libraries(${EXE} ${SHARED_LIB} backport llarpplatform)
|
|
|
|
|
target_link_libraries(${CLIENT_EXE} ${SHARED_LIB} backport llarpplatform)
|
|
|
|
|
target_link_libraries(rcutil ${SHARED_LIB} backport llarpplatform)
|
|
|
|
|
else()
|
|
|
|
|
target_link_libraries(${EXE} ${SHARED_LIB} llarpplatform)
|
|
|
|
|
target_link_libraries(${CLIENT_EXE} ${SHARED_LIB} llarpplatform)
|
|
|
|
|
target_link_libraries(rcutil ${SHARED_LIB} llarpplatform)
|
|
|
|
|
endif(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
|
|
|
|
|
target_link_libraries(dns ${SHARED_LIB} llarpplatform pthread)
|
|
|
|
|
endif(NOT WITH_STATIC)
|
|
|
|
|
endif(WITH_SHARED)
|
|
|
|
|
endif(SHADOW)
|
|
|
|
|