diff --git a/CMakeLists.txt b/CMakeLists.txt index 22f1022a54..b66756521c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,11 +141,7 @@ endif(WIN32) # set a few other things at the top level to prevent incompatibilities set(CMAKE_C_STANDARD 99) -if(NOT CRYPTO_BACKEND_BOTAN3) - set(CMAKE_CXX_STANDARD 11) -else() - set(CMAKE_CXX_STANDARD 20) -endif() +set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) add_definitions(-D_GNU_SOURCE) diff --git a/cmake/Modules/FindBotan.cmake b/cmake/Modules/FindBotan.cmake index 1babefca2e..abdfe2b38f 100644 --- a/cmake/Modules/FindBotan.cmake +++ b/cmake/Modules/FindBotan.cmake @@ -84,14 +84,21 @@ if(DEFINED ENV{BOTAN_ROOT_DIR}) list(APPEND _hints_lib "$ENV{BOTAN_ROOT_DIR}/lib") endif() +# Append PC_* stuff only if BOTAN_ROOT_DIR is not specified +if(NOT _hints_include) + list(APPEND _hints_include ${PC_BOTAN_INCLUDEDIR} ${PC_BOTAN_INCLUDE_DIRS}) + list(APPEND _hints_lib ${PC_BOTAN_LIBDIR} ${PC_BOTAN_LIBRARY_DIRS}) +else() + set(_no_def_path "NO_DEFAULT_PATH") +endif() + # find the headers find_path(BOTAN_INCLUDE_DIR NAMES botan/version.h HINTS ${_hints_include} - ${PC_BOTAN_INCLUDEDIR} - ${PC_BOTAN_INCLUDE_DIRS} PATH_SUFFIXES ${_suffixes} + ${_no_def_path} ) # find the library @@ -100,8 +107,7 @@ if(MSVC) NAMES botan HINTS ${_hints_lib} - ${PC_BOTAN_LIBDIR} - ${PC_BOTAN_LIBRARY_DIRS} + ${_no_def_path} ) else() find_library(BOTAN_LIBRARY @@ -109,15 +115,12 @@ else() ${_names} HINTS ${_hints_lib} - ${PC_BOTAN_LIBDIR} - ${PC_BOTAN_LIBRARY_DIRS} + ${_no_def_path} ) endif() # determine the version -if(PC_BOTAN_VERSION) - set(BOTAN_VERSION ${PC_BOTAN_VERSION}) -elseif(BOTAN_INCLUDE_DIR AND EXISTS "${BOTAN_INCLUDE_DIR}/botan/build.h") +if(BOTAN_INCLUDE_DIR AND EXISTS "${BOTAN_INCLUDE_DIR}/botan/build.h") file(STRINGS "${BOTAN_INCLUDE_DIR}/botan/build.h" botan_version_str REGEX "^#define[\t ]+(BOTAN_VERSION_[A-Z]+)[\t ]+[0-9]+") @@ -163,4 +166,3 @@ if (BOTAN_FOUND AND NOT TARGET Botan::Botan) endif() mark_as_advanced(BOTAN_INCLUDE_DIR BOTAN_LIBRARY) - diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index c8fbdcd1b8..fe6c7ff1c0 100755 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -48,6 +48,10 @@ if (CRYPTO_BACKEND_OPENSSL) endif() endif() +if(CRYPTO_BACKEND_BOTAN3) + set(CMAKE_CXX_STANDARD 20) +endif() + # generate a config.h include(CheckIncludeFileCXX) include(CheckCXXSymbolExists) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 026dc09750..502d0f6302 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -70,11 +70,18 @@ if (CRYPTO_BACKEND_BOTAN3) find_package(Botan 3.0.0 REQUIRED) elseif (CRYPTO_BACKEND_BOTAN) find_package(Botan 2.14.0 REQUIRED) + if(BOTAN_VERSION VERSION_GREATER_EQUAL 3.0.0) + set(CRYPTO_BACKEND_BOTAN3 1) + endif() endif() if (CRYPTO_BACKEND_LOWERCASE STREQUAL "openssl") find_package(OpenSSL 1.1.1 REQUIRED) endif() +if(CRYPTO_BACKEND_BOTAN3) + set(CMAKE_CXX_STANDARD 20) +endif() + add_executable(rnp_tests ../rnp/rnpcfg.cpp ../rnp/fficli.cpp