From 4e23460c6fd781a311285228760f3cf4cecd5e44 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Sun, 1 Dec 2024 20:21:22 -0500 Subject: [PATCH] refactor: no configure_openssl macro --- CMakeLists.txt | 5 ++++ cmake/Libraries.cmake | 41 +++++++++++++++------------------ src/lib/platform/CMakeLists.txt | 4 ++-- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b507c41b..834ecc44b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,11 @@ project( message(STATUS "Building ${CMAKE_PROJECT_NAME}-${CMAKE_PROJECT_VERSION}") +# Set lib versions +set(REQUIRED_OPENSSL_VERSION 3.0) +set(REQUIRED_LIBEI_VERSION 1.3) +set(REQUIRED_LIBPORTAL_VERSION 0.8) + # Set required macOS SDK if(APPLE) set(CMAKE_OSX_DEPLOYMENT_TARGET 12) diff --git a/cmake/Libraries.cmake b/cmake/Libraries.cmake index 6829e1ea7..e8cd30e5d 100644 --- a/cmake/Libraries.cmake +++ b/cmake/Libraries.cmake @@ -13,9 +13,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -set(LIBEI_MIN_VERSION 1.3) -set(LIBPORTAL_MIN_VERSION 0.8) - macro(configure_libs) set(libs) @@ -35,7 +32,24 @@ macro(configure_libs) endif() configure_qt() - configure_openssl() + + # TODO SSL check can happen in lib/net when we make wix packages with cpack + + # Apple has to use static libraries because "Use of the Apple-provided OpenSSL + # libraries by apps is strongly discouraged." + # https://developer.apple.com/library/archive/documentation/Security/Conceptual/cryptoservices/SecureNetworkCommunicationAPIs/SecureNetworkCommunicationAPIs.html + if(APPLE) + set(OPENSSL_USE_STATIC_LIBS TRUE) + endif() + + find_package(OpenSSL ${REQUIRED_OPENSSL_VERSION} REQUIRED COMPONENTS SSL Crypto) + if(WIN32) #Used for dev in TLS and WIX TODO RM when cpack used for wix + cmake_path(SET OPENSSL_ROOT_DIR NORMALIZE "${OPENSSL_INCLUDE_DIR}/..") + message(VERBOSE "Set OPENSSL_ROOT_DIR: ${OPENSSL_ROOT_DIR}") + set(OPENSSL_EXE_DIR "${OPENSSL_ROOT_DIR}/tools/openssl") + add_definitions(-DOPENSSL_EXE_DIR="${OPENSSL_EXE_DIR}") + endif() + option(ENABLE_COVERAGE "Enable test coverage" OFF) if(ENABLE_COVERAGE) @@ -335,22 +349,3 @@ macro(configure_qt) message(STATUS "Qt version: ${Qt6_VERSION}") endmacro() - -macro(configure_openssl) - # Apple has to use static libraries because "Use of the Apple-provided OpenSSL - # libraries by apps is strongly discouraged." - # https://developer.apple.com/library/archive/documentation/Security/Conceptual/cryptoservices/SecureNetworkCommunicationAPIs/SecureNetworkCommunicationAPIs.html - # TODO: How about bundling the OpenSSL .dylib files with the app so they can be updated? - if(APPLE) - set(OPENSSL_USE_STATIC_LIBS TRUE) - endif() - - find_package(OpenSSL 3.0 REQUIRED COMPONENTS SSL Crypto) - if(WIN32) #Used for dev in TLS and WIX - cmake_path(SET OPENSSL_ROOT_DIR NORMALIZE "${OPENSSL_INCLUDE_DIR}/..") - message(VERBOSE "Set OPENSSL_ROOT_DIR: ${OPENSSL_ROOT_DIR}") - set(OPENSSL_EXE_DIR "${OPENSSL_ROOT_DIR}/tools/openssl") - add_definitions(-DOPENSSL_EXE_DIR="${OPENSSL_EXE_DIR}") - endif() - -endmacro() diff --git a/src/lib/platform/CMakeLists.txt b/src/lib/platform/CMakeLists.txt index 6eb8e66df..a58efea8c 100644 --- a/src/lib/platform/CMakeLists.txt +++ b/src/lib/platform/CMakeLists.txt @@ -16,10 +16,10 @@ # along with this program. If not, see . if(UNIX AND NOT APPLE) - pkg_check_modules(LIBEI REQUIRED QUIET "libei-1.0 >= 1.3") + pkg_check_modules(LIBEI REQUIRED QUIET "libei-1.0 >= ${REQUIRED_LIBEI_VERSION}") message(STATUS "libei version: ${LIBEI_VERSION}") - pkg_check_modules(LIBPORTAL REQUIRED QUIET "libportal >= 0.8") + pkg_check_modules(LIBPORTAL REQUIRED QUIET "libportal >= ${REQUIRED_LIBPORTAL_VERSION}") message(STATUS "libportal version: ${LIBPORTAL_VERSION}") endif()