Fix Botan 3 build ()

* SymmetricCipher: Fix Botan 3 build

Botan commit 819cf8fe6278a19b8266f449228f02fc28a4f784 changed
Botan::Cipher_Dir to be a scoped enumeration, so the users
must be adapted.

This change causes no issues with Botan 2 because normal
enumeration values can also be referred to the same way
scoped enumeration values are accessed.

* Auto detect Botan3

* AsyncTask: Do not use `std::result_of`

`std::result_of` was deprecated in C++17 and then it was
subsequently removed in C++20. One could use `std::invoke_result_t`,
but let Qt figure out the return type instead.

* Collapse Botan2 and Botan3 find package into one

* Update COPYING

---------

Co-authored-by: Jonathan White <support@dmapps.us>
This commit is contained in:
Barnabás Pőcze 2023-05-07 14:48:58 +02:00 committed by GitHub
parent cf819e0a3f
commit 16b3d32ca5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 94 additions and 259 deletions

View file

@ -61,7 +61,6 @@ if(UNIX AND NOT APPLE)
option(WITH_XC_FDOSECRETS "Implement freedesktop.org Secret Storage Spec server side API." OFF)
endif()
option(WITH_XC_DOCS "Enable building of documentation" ON)
option(KPXC_DEV_BOTAN3 "Build against Botan3" OFF)
set(WITH_XC_X11 ON CACHE BOOL "Enable building with X11 deps")
@ -204,6 +203,16 @@ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14.0")
check_pie_supported()
endif()
# Find Botan early since the version affects subsequent compiler options
find_package(Botan REQUIRED)
if(BOTAN_VERSION VERSION_GREATER_EQUAL "3.0.0")
set(WITH_XC_BOTAN3 TRUE)
elseif(BOTAN_VERSION VERSION_LESS "2.11.0")
# Check for minimum Botan version
message(FATAL_ERROR "Botan 2.11.0 or higher is required")
endif()
include_directories(SYSTEM ${BOTAN_INCLUDE_DIR})
# Create position independent code for shared libraries and executables
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
@ -300,7 +309,7 @@ if(CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
check_add_gcc_compiler_flag("-Wshadow-local")
add_gcc_compiler_flags("-Werror")
# This is needed since compiling aginst Botan3 requires compiling against C++20
if(KPXC_DEV_BOTAN3)
if(WITH_XC_BOTAN3)
add_gcc_compiler_cxxflags("-Wno-error=deprecated-enum-enum-conversion -Wno-error=deprecated")
endif()
endif()
@ -348,7 +357,7 @@ if(UNIX AND NOT APPLE)
endif()
set(CMAKE_C_STANDARD 99)
if(KPXC_DEV_BOTAN3)
if(WITH_XC_BOTAN3)
set(CMAKE_CXX_STANDARD 20)
else()
set(CMAKE_CXX_STANDARD 17)
@ -538,26 +547,6 @@ endif()
# Make sure we don't enable asserts there.
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_NONE QT_NO_DEBUG)
if(KPXC_DEV_BOTAN3)
# Find Botan3
find_package(Botan3 REQUIRED)
if(BOTAN3_VERSION VERSION_LESS "3.0.0")
message(FATAL_ERROR "Botan3 3.0.0 or higher is required")
endif()
set(BOTAN_VERSION "${BOTAN3_VERSION}")
set(BOTAN_INCLUDE_DIR "${BOTAN3_INCLUDE_DIR}")
set(BOTAN_LIBRARIES "${BOTAN3_LIBRARIES}")
else()
# Find Botan2
find_package(Botan2 REQUIRED)
if(BOTAN2_VERSION VERSION_LESS "2.11.0")
message(FATAL_ERROR "Botan2 2.11.0 or higher is required")
endif()
set(BOTAN_VERSION "${BOTAN2_VERSION}")
set(BOTAN_INCLUDE_DIR "${BOTAN2_INCLUDE_DIR}")
set(BOTAN_LIBRARIES "${BOTAN2_LIBRARIES}")
endif()
include_directories(SYSTEM ${BOTAN_INCLUDE_DIR})
# Find Argon2 -- Botan 2.18 and below does not support threaded Argon2
find_library(ARGON2_LIBRARIES NAMES argon2)
find_path(ARGON2_INCLUDE_DIR NAMES argon2.h PATH_SUFFIXES local/include)