mirror of
https://github.com/deneraraujo/OpenVPNAdapter.git
synced 2026-04-24 00:00:05 +08:00
Merge commit '86cc97e55fe346502462284d2e636a2b3708163e' as 'Sources/OpenVPN3'
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
project(googletest-download NONE)
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(googletest
|
||||
GIT_REPOSITORY https://github.com/google/googletest.git
|
||||
GIT_TAG master
|
||||
SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-src"
|
||||
BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googletest-build"
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
@@ -0,0 +1,9 @@
|
||||
find_path(LZ4_INCLUDE_DIR NAMES lz4.h)
|
||||
find_library(LZ4_LIBRARY NAMES lz4)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
|
||||
LZ4 DEFAULT_MSG
|
||||
LZ4_LIBRARY LZ4_INCLUDE_DIR)
|
||||
|
||||
mark_as_advanced(LZ4_INCLUDE_DIR LZ4_LIBRARY)
|
||||
@@ -0,0 +1,63 @@
|
||||
# - Try to find mbedTLS
|
||||
# Once done this will define
|
||||
#
|
||||
# Read-Only variables
|
||||
# MBEDTLS_FOUND - system has mbedTLS
|
||||
# MBEDTLS_INCLUDE_DIR - the mbedTLS include directory
|
||||
# MBEDTLS_LIBRARY_DIR - the mbedTLS library directory
|
||||
# MBEDTLS_LIBRARIES - Link these to use mbedTLS
|
||||
# MBEDTLS_LIBRARY - path to mbedTLS library
|
||||
# MBEDX509_LIBRARY - path to mbedTLS X.509 library
|
||||
# MBEDCRYPTO_LIBRARY - path to mbedTLS Crypto library
|
||||
|
||||
FIND_PATH(MBEDTLS_INCLUDE_DIR mbedtls/version.h)
|
||||
|
||||
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES)
|
||||
# Already in cache, be silent
|
||||
SET(MBEDTLS_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
FIND_LIBRARY(MBEDTLS_LIBRARY NAMES mbedtls libmbedtls libmbedx509)
|
||||
FIND_LIBRARY(MBEDX509_LIBRARY NAMES mbedx509 libmbedx509)
|
||||
FIND_LIBRARY(MBEDCRYPTO_LIBRARY NAMES mbedcrypto libmbedcrypto)
|
||||
|
||||
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
|
||||
SET(MBEDTLS_FOUND TRUE)
|
||||
ELSEIF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND NOT MBEDX509_LIBRARY AND NOT MBEDCRYPTO_LIBRARY)
|
||||
SET(MBEDTLS_FOUND TRUE)
|
||||
SET(HACKY_OVPN_MBEDTLS TRUE)
|
||||
ENDIF()
|
||||
|
||||
IF(MBEDTLS_FOUND)
|
||||
IF(HACKY_OVPN_MBEDTLS)
|
||||
SET(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY})
|
||||
ELSE()
|
||||
SET(MBEDTLS_LIBRARIES ${MBEDTLS_LIBRARY} ${MBEDX509_LIBRARY} ${MBEDCRYPTO_LIBRARY})
|
||||
endif()
|
||||
|
||||
IF(NOT MBEDTLS_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found mbedTLS:")
|
||||
FILE(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
|
||||
STRING(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
|
||||
IF (MBEDTLSMATCH)
|
||||
STRING(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
|
||||
MESSAGE(STATUS " version ${MBEDTLS_VERSION}")
|
||||
ENDIF(MBEDTLSMATCH)
|
||||
MESSAGE(STATUS " TLS: ${MBEDTLS_LIBRARY}")
|
||||
MESSAGE(STATUS " X509: ${MBEDX509_LIBRARY}")
|
||||
MESSAGE(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
|
||||
ENDIF(NOT MBEDTLS_FIND_QUIETLY)
|
||||
ELSE(MBEDTLS_FOUND)
|
||||
IF(mbedTLS_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find mbedTLS")
|
||||
ENDIF(mbedTLS_FIND_REQUIRED)
|
||||
ENDIF(MBEDTLS_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
MBEDTLS_INCLUDE_DIR
|
||||
MBEDTLS_LIBRARY_DIR
|
||||
MBEDTLS_LIBRARIES
|
||||
MBEDTLS_LIBRARY
|
||||
MBEDX509_LIBRARY
|
||||
MBEDCRYPTO_LIBRARY
|
||||
)
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
# Google Test Unit testing
|
||||
# Download and unpack googletest at configure time
|
||||
|
||||
# Ensure that this only downloaded and added once
|
||||
#include_guard(GLOBAL)
|
||||
# Unfortunately include_guard requires cmake >= 3.10
|
||||
include(mypragmaonce)
|
||||
|
||||
my_pragma_once()
|
||||
|
||||
|
||||
configure_file(${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in googletest-download/CMakeLists.txt)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
||||
if(result)
|
||||
message(FATAL_ERROR "CMake step for googletest failed: ${result}")
|
||||
endif()
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )
|
||||
if(result)
|
||||
message(FATAL_ERROR "Build step for googletest failed: ${result}")
|
||||
endif()
|
||||
|
||||
# Prevent overriding the parent project's compiler/linker
|
||||
# settings on Windows
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
|
||||
# Add googletest directly to our build. This defines
|
||||
# the gtest and gtest_main targets.
|
||||
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src
|
||||
${CMAKE_CURRENT_BINARY_DIR}/googletest-build
|
||||
EXCLUDE_FROM_ALL)
|
||||
@@ -0,0 +1,107 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
|
||||
#cmake_policy(SET CMP0079 NEW)
|
||||
|
||||
set(CORE_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
|
||||
|
||||
|
||||
set(DEP_DIR ${CORE_DIR}/../deps CACHE PATH "Dependencies")
|
||||
option(USE_MBEDTLS "Use mbed TLS instead of OpenSSL")
|
||||
|
||||
if (DEFINED ENV{DEP_DIR})
|
||||
message(WARNING "Overriding DEP_DIR setting with environment variable")
|
||||
set(DEP_DIR $ENV{DEP_DIR})
|
||||
endif ()
|
||||
|
||||
# Include our DEP_DIR in path used to find libraries
|
||||
|
||||
|
||||
function(add_core_dependencies target)
|
||||
if (APPLE)
|
||||
set(PLAT osx)
|
||||
elseif (WIN32)
|
||||
set(PLAT amd64)
|
||||
else ()
|
||||
set(PLAT linux)
|
||||
endif ()
|
||||
|
||||
set(CORE_INCLUDES
|
||||
${CORE_DIR}
|
||||
${DEP_DIR}/asio/asio/include
|
||||
)
|
||||
set(CORE_DEFINES
|
||||
-DASIO_STANDALONE
|
||||
-DUSE_ASIO
|
||||
-DHAVE_LZ4
|
||||
-DLZ4_DISABLE_DEPRECATE_WARNINGS
|
||||
-DMBEDTLS_DEPRECATED_REMOVED
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
list(APPEND CMAKE_PREFIX_PATH
|
||||
${DEP_DIR}/${PLAT}/mbedtls
|
||||
${DEP_DIR}/${PLAT}/lz4/lib
|
||||
)
|
||||
list(APPEND CMAKE_LIBRARY_PATH
|
||||
${DEP_DIR}/${PLAT}/mbedtls/library
|
||||
)
|
||||
list(APPEND CORE_INCLUDES
|
||||
${DEP_DIR}/${PLAT}/asio/asio/include
|
||||
${DEP_DIR}/${PLAT}/lz4/lz4/include
|
||||
${DEP_DIR}/${PLAT}/tap-windows/src
|
||||
)
|
||||
list(APPEND CORE_DEFINES
|
||||
-D_WIN32_WINNT=0x0600
|
||||
-DTAP_WIN_COMPONENT_ID=tap0901
|
||||
-D_CRT_SECURE_NO_WARNINGS
|
||||
)
|
||||
set(EXTRA_LIBS fwpuclnt.lib Iphlpapi.lib)
|
||||
target_compile_options(${target} PRIVATE "/bigobj")
|
||||
else ()
|
||||
list(APPEND CMAKE_PREFIX_PATH
|
||||
${DEP_DIR}/mbedtls/mbedtls-${PLAT}
|
||||
${DEP_DIR}/lz4/lz4-${PLAT}
|
||||
)
|
||||
list(APPEND CMAKE_LIBRARY_PATH
|
||||
${DEP_DIR}/mbedtls/mbedtls-${PLAT}/library
|
||||
)
|
||||
endif ()
|
||||
|
||||
|
||||
if (${USE_MBEDTLS})
|
||||
find_package(mbedTLS REQUIRED)
|
||||
|
||||
set(SSL_LIBRARY ${MBEDTLS_LIBRARIES})
|
||||
|
||||
list(APPEND CORE_DEFINES -DUSE_MBEDTLS)
|
||||
|
||||
# The findmbedTLS does not set these automatically :(
|
||||
list(APPEND CORE_INCLUDES ${MBEDTLS_INCLUDE_DIR})
|
||||
|
||||
else ()
|
||||
find_package(OpenSSL REQUIRED)
|
||||
SET(SSL_LIBRARY OpenSSL::SSL)
|
||||
list(APPEND CORE_DEFINES -DUSE_OPENSSL)
|
||||
endif ()
|
||||
|
||||
if (APPLE)
|
||||
find_library(coreFoundation CoreFoundation)
|
||||
find_library(iokit IOKit)
|
||||
find_library(coreServices CoreServices)
|
||||
find_library(systemConfiguration SystemConfiguration)
|
||||
target_link_libraries(${target} ${coreFoundation} ${iokit} ${coreServices} ${systemConfiguration} ${lz4} ${SSL_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
target_link_libraries(${target} pthread)
|
||||
endif()
|
||||
|
||||
find_package(LZ4 REQUIRED)
|
||||
list(APPEND CORE_INCLUDES ${LZ4_INCLUDE_DIR})
|
||||
|
||||
target_include_directories(${target} PRIVATE ${CORE_INCLUDES})
|
||||
target_compile_definitions(${target} PRIVATE ${CORE_DEFINES})
|
||||
target_link_libraries(${target} ${SSL_LIBRARY} ${EXTRA_LIBS} ${LZ4_LIBRARY})
|
||||
endfunction()
|
||||
@@ -0,0 +1,8 @@
|
||||
macro(my_pragma_once)
|
||||
set(__filename "${CMAKE_CURRENT_LIST_FILE}")
|
||||
get_property(already_included GLOBAL PROPERTY "pr_${__filename}")
|
||||
if(already_included)
|
||||
return()
|
||||
endif()
|
||||
set_property(GLOBAL PROPERTY "pr_${__filename}" TRUE)
|
||||
endmacro()
|
||||
Reference in New Issue
Block a user