Skip to content

Commit

Permalink
Revert OpenSSL changes (microsoft#1892)
Browse files Browse the repository at this point in the history
* Revert "Fix QNS builds (microsoft#1891)"

This reverts commit 8569b6c.

* Revert "Consolidate OpenSSL build into a single CMakeLists file (microsoft#1885)"

This reverts commit c16d492.
  • Loading branch information
thhous-msft authored Aug 9, 2021
1 parent 8569b6c commit 97f1fd8
Show file tree
Hide file tree
Showing 3 changed files with 243 additions and 252 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
mkdir build
cd build
cmake ..
cmake --build . --target OpenSSL_Target
cmake --build . --target OpenSSL_Build
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
Expand Down
133 changes: 121 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ set(QUIC_LIBRARY_NAME "msquic" CACHE STRING "Override the output library name")

set(BUILD_SHARED_LIBS ${QUIC_BUILD_SHARED})

# FindLTTngUST does not exist before CMake 3.6, so disable logging for older cmake versions
if (${CMAKE_VERSION} VERSION_LESS "3.6.0")
message(WARNING "Logging unsupported on this version of CMake. Please upgrade to 3.6 or later.")
set(QUIC_ENABLE_LOGGING OFF)
endif()

if (QUIC_PDBALTPATH AND MSVC)
# Disabled in all cases because generation is broken.
# file(READ ${CMAKE_CURRENT_LIST_DIR}/cmake/PdbAltPath.txt PDBALTPATH)
Expand Down Expand Up @@ -466,21 +472,124 @@ else() #!WIN32
endif()

if(QUIC_TLS STREQUAL "openssl")
add_library(OpenSSL INTERFACE)
if (WIN32)
add_library(OpenSSL INTERFACE)

include(FetchContent)
include(FetchContent)

FetchContent_Declare(
OpenSSLQuic
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/submodules
CMAKE_ARGS "-DQUIC_USE_SYSTEM_LIBCRYPTO=${QUIC_USE_SYSTEM_LIBCRYPTO}"
)
FetchContent_MakeAvailable(OpenSSLQuic)
FetchContent_Declare(
OpenSSLQuic
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/submodules
CMAKE_ARGS "-DQUIC_BUILD_DIR=${QUIC_BUILD_DIR}"
)
FetchContent_MakeAvailable(OpenSSLQuic)

target_link_libraries(OpenSSL
INTERFACE
OpenSSLQuic
)
target_link_libraries(OpenSSL
INTERFACE
OpenSSLQuic::OpenSSLQuic
)
else()
# Configure and build OpenSSL.
set(OPENSSL_DIR ${QUIC_BUILD_DIR}/openssl)
set(OPENSSL_CONFIG_FLAGS
enable-tls1_3 no-makedepend no-dgram no-ssl3 no-psk no-srp

#
# The following line is needed for the 3.0 branch.
#
# no-uplink no-cmp no-acvp_tests no-fips no-padlockeng no-siv

no-zlib no-egd no-idea no-rc5 no-rc4 no-afalgeng
no-comp no-cms no-ct no-srp no-srtp no-ts no-gost no-dso no-ec2m
no-tls1 no-tls1_1 no-tls1_2 no-dtls no-dtls1 no-dtls1_2 no-ssl
no-ssl3-method no-tls1-method no-tls1_1-method no-tls1_2-method no-dtls1-method no-dtls1_2-method
no-siphash no-whirlpool no-aria no-bf no-blake2 no-sm2 no-sm3 no-sm4 no-camellia no-cast no-md4 no-mdc2 no-ocb no-rc2 no-rmd160 no-scrypt
no-weak-ssl-ciphers no-shared no-tests --prefix=${OPENSSL_DIR})

if (QUIC_ENABLE_SANITIZERS)
list(APPEND OPENSSL_CONFIG_FLAGS enable-asan enable-ubsan)
endif()
if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
set(OPENSSL_CONFIG_CMD ${CMAKE_CURRENT_SOURCE_DIR}/submodules/openssl/Configure
linux-armv4 -DL_ENDIAN
--cross-compile-prefix=${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-)
list(APPEND OPENSSL_CONFIG_FLAGS -latomic)
elseif(CX_PLATFORM STREQUAL "darwin")
# need to build with Apple's compiler
if (CMAKE_OSX_ARCHITECTURES STREQUAL arm64)
set(OPENSSL_CONFIG_CMD ARCHFLAGS="-arch arm64" ${CMAKE_CURRENT_SOURCE_DIR}/submodules/openssl/Configure darwin64-arm64-cc)
elseif(CMAKE_OSX_ARCHITECTURES STREQUAL x86_64)
set(OPENSSL_CONFIG_CMD ARCHFLAGS="-arch x86_64" ${CMAKE_CURRENT_SOURCE_DIR}/submodules/openssl/Configure darwin64-x86_64-cc)
else()
set(OPENSSL_CONFIG_CMD ${CMAKE_CURRENT_SOURCE_DIR}/submodules/openssl/config)
endif()
list(APPEND OPENSSL_CONFIG_FLAGS -isysroot ${CMAKE_OSX_SYSROOT})
elseif(ANDROID)
message(STATUS "${ANDROID_ABI}")
if(ANDROID_ABI STREQUAL "arm64-v8a")
set(OPENSSL_BUILD_TYPE android-arm64)
elseif(ANDROID_ABI STREQUAL "armeabi-v7a")
set(OPENSSL_BUILD_TYPE android-arm)
elseif(ANDROID_ABI STREQUAL "x86")
set(OPENSSL_BUILD_TYPE android-x86)
elseif(ANDROID_ABI STREQUAL "x86_64")
set(OPENSSL_BUILD_TYPE android-x86_64)
else()
message(FATAL_ERROR "Unknown android abi type")
endif()
set(OPENSSL_CONFIG_CMD ${CMAKE_CURRENT_SOURCE_DIR}/submodules/openssl/Configure
${OPENSSL_BUILD_TYPE}
-D__ANDROID_API__=29)
else()
set(OPENSSL_CONFIG_CMD ${CMAKE_CURRENT_SOURCE_DIR}/submodules/openssl/config
CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER})
endif()
add_custom_target(mkdir_openssl_build
COMMAND mkdir -p ${QUIC_BUILD_DIR}/submodules/openssl)
add_custom_command(
DEPENDS mkdir_openssl_build
WORKING_DIRECTORY ${QUIC_BUILD_DIR}/submodules/openssl
OUTPUT ${OPENSSL_DIR}/lib/libcrypto${CMAKE_STATIC_LIBRARY_SUFFIX}
OUTPUT ${OPENSSL_DIR}/lib/libssl${CMAKE_STATIC_LIBRARY_SUFFIX}
COMMAND SYSTEM=${CMAKE_HOST_SYSTEM_NAME}
${OPENSSL_CONFIG_CMD} ${OPENSSL_CONFIG_FLAGS}
COMMAND make -j$$(nproc)
COMMAND make install_dev)
add_custom_target(OpenSSL_Build
DEPENDS ${OPENSSL_DIR}/lib/libcrypto${CMAKE_STATIC_LIBRARY_SUFFIX}
DEPENDS ${OPENSSL_DIR}/lib/libssl${CMAKE_STATIC_LIBRARY_SUFFIX})

file(MAKE_DIRECTORY ${OPENSSL_DIR}/include)

add_library(OpenSSL STATIC IMPORTED)
set_target_properties(OpenSSL PROPERTIES
IMPORTED_LOCATION ${OPENSSL_DIR}/lib/libssl${CMAKE_STATIC_LIBRARY_SUFFIX}
IMPORTED_LINK_INTERFACE_LANGUAGES "C")

target_include_directories(OpenSSL INTERFACE ${OPENSSL_DIR}/include)

if (QUIC_USE_SYSTEM_LIBCRYPTO)
include(FindOpenSSL)
if (OPENSSL_FOUND)
if (OPENSSL_VERSION VERSION_EQUAL 1.1.1)
target_link_libraries(OpenSSL INTERFACE OpenSSL::Crypto)
else()
message(FATAL_ERROR "OpenSSL 1.1.1 not found, found ${OPENSSL_VERSION}")
endif()
else()
message(FATAL_ERROR "System OpenSSL not found when requested")
endif()
else()
add_library(OpenSSL_Crypto STATIC IMPORTED)
set_target_properties(OpenSSL_Crypto PROPERTIES
IMPORTED_LOCATION ${OPENSSL_DIR}/lib/libcrypto${CMAKE_STATIC_LIBRARY_SUFFIX}
IMPORTED_LINK_INTERFACE_LANGUAGES "C")

add_dependencies(OpenSSL_Crypto OpenSSL_Build)
target_link_libraries(OpenSSL INTERFACE OpenSSL_Crypto)
endif()
add_dependencies(OpenSSL OpenSSL_Build)
endif()
endif()

if(QUIC_CODE_CHECK)
Expand Down
Loading

0 comments on commit 97f1fd8

Please sign in to comment.