Add optional support for Botan3 ()

This commit is contained in:
Pat Long 2023-02-18 16:38:39 -05:00 committed by GitHub
parent 4a30417f76
commit f9f82e9705
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 171 additions and 14 deletions

View file

@ -61,6 +61,7 @@ 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")
@ -298,6 +299,10 @@ if(CMAKE_BUILD_TYPE_LOWER STREQUAL "debug")
check_add_gcc_compiler_flag("-Wshadow-compatible-local")
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)
add_gcc_compiler_cxxflags("-Wno-error=deprecated-enum-enum-conversion -Wno-error=deprecated")
endif()
endif()
if (NOT HAIKU)
@ -343,7 +348,11 @@ if(UNIX AND NOT APPLE)
endif()
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 17)
if(KPXC_DEV_BOTAN3)
set(CMAKE_CXX_STANDARD 20)
else()
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
check_cxx_compiler_flag("-fsized-deallocation" CXX_HAS_fsized_deallocation)
@ -529,12 +538,26 @@ endif()
# Make sure we don't enable asserts there.
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_NONE QT_NO_DEBUG)
# 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")
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 ${BOTAN2_INCLUDE_DIR})
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)