From 3ce88dbf1c626eb078d21dd8b47585aed565fd1b Mon Sep 17 00:00:00 2001 From: Adrien Ollier Date: Tue, 25 Aug 2026 13:41:53 +0200 Subject: [PATCH 1/9] Modernize FindBotan.cmake to use PkgConfig and imported targets - Replace raw variables (BOTAN_LIBRARY, BOTAN_INCLUDE_DIRS) with an imported target Botan::botan that carries include dirs, compile options, and link flags - Remove global include_directories() in favor of explicit target_link_libraries() - Rename internal variables from BOTAN_ to Botan_ for consistency - Update the rest of the project to depend on Botan::botan instead of ${BOTAN_LIBRARIES} Tested on Ubuntu; relying on GitHub CI to validate Windows and macOS builds. --- CMakeLists.txt | 7 +- cmake/FindBotan.cmake | 124 ++++++++++++++++++++++++---------- src/CMakeLists.txt | 4 +- src/autotype/CMakeLists.txt | 2 +- src/browser/CMakeLists.txt | 2 +- src/cli/CMakeLists.txt | 2 +- src/fdosecrets/CMakeLists.txt | 2 +- src/keeshare/CMakeLists.txt | 2 +- src/proxy/CMakeLists.txt | 2 +- src/sshagent/CMakeLists.txt | 4 +- 10 files changed, 102 insertions(+), 49 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84de141764..7ddabfaf65 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -476,13 +476,12 @@ endif() # Find Botan find_package(Botan REQUIRED) -if(BOTAN_VERSION VERSION_GREATER_EQUAL "3.0.0") +if(Botan_VERSION VERSION_GREATER_EQUAL "3.0.0") set(WITH_BOTAN3 TRUE) -elseif(BOTAN_VERSION VERSION_LESS "2.19.1") +elseif(Botan_VERSION VERSION_LESS "2.19.1") # Check for minimum Botan version - message(FATAL_ERROR "Botan 2.19.1 or higher is required") + message(FATAL_ERROR "Botan 2.19.1 or higher is required") endif() -include_directories(SYSTEM ${BOTAN_INCLUDE_DIR}) # Find zlib find_package(ZLIB REQUIRED) diff --git a/cmake/FindBotan.cmake b/cmake/FindBotan.cmake index dfa415c1d0..72bc0f3a41 100644 --- a/cmake/FindBotan.cmake +++ b/cmake/FindBotan.cmake @@ -1,65 +1,117 @@ -# - Find botan -# Find the botan cryptographic library -# -# This module defines the following variables: -# BOTAN_FOUND - True if library and include directory are found -# If set to TRUE, the following are also defined: -# BOTAN_INCLUDE_DIRS - The directory where to find the header file -# BOTAN_LIBRARIES - Where to find the library files -# -# This file is in the public domain (https://github.com/vistle/vistle/blob/master/cmake/Modules/FindBOTAN.cmake) +#[=======================================================================[.rst: +FindBotan +--------- -include(FindPackageHandleStandardArgs) +Finds the botan cryptographic library + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module provides the following imported targets, if found: + +``Botan::botan`` + The Botan library + +Result Variables +^^^^^^^^^^^^^^^^ + +This module defines the following variables: + +``Botan_FOUND`` + Boolean indicating whether Botan was found. +``Botan_VERSION`` + The version of the Botan library which was found. +``Botan_LIBRARY`` + The path to the Botan library + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Botan_INCLUDE_DIR`` + The directory containing ``botan/build.h``. +``Botan_LIBRARY_DEBUG`` + The debug version of the Botan library, if present +``Botan_LIBRARY_RELEASE`` + The release version of the Botan library + +#]=======================================================================] + +find_package(PkgConfig QUIET) +if(PkgConfig_FOUND) + pkg_search_module(PC_Botan QUIET botan-3 botan-2>=2.19.1 libbotan-2>=2.19.1 botan>=2.19.1) +endif() set(BOTAN_VERSIONS botan-3 botan-2) set(BOTAN_NAMES botan-3 botan-2 botan) set(BOTAN_NAMES_DEBUG botand-3 botand-2 botand botan botan-3) find_path( - BOTAN_INCLUDE_DIR + Botan_INCLUDE_DIR NAMES botan/build.h + HINTS ${PC_Botan_INCLUDE_DIRS} PATH_SUFFIXES ${BOTAN_VERSIONS} DOC "The Botan include directory") -if(BOTAN_INCLUDE_DIR) - file(READ "${BOTAN_INCLUDE_DIR}/botan/build.h" build) + +if(Botan_INCLUDE_DIR) + file(READ "${Botan_INCLUDE_DIR}/botan/build.h" build) string(REGEX MATCH "BOTAN_VERSION_MAJOR ([0-9]*)" _ ${build}) - set(BOTAN_VERSION_MAJOR ${CMAKE_MATCH_1}) + set(Botan_VERSION_MAJOR ${CMAKE_MATCH_1}) string(REGEX MATCH "BOTAN_VERSION_MINOR ([0-9]*)" _ ${build}) - set(BOTAN_VERSION_MINOR ${CMAKE_MATCH_1}) + set(Botan_VERSION_MINOR ${CMAKE_MATCH_1}) string(REGEX MATCH "BOTAN_VERSION_PATCH ([0-9]*)" _ ${build}) - set(BOTAN_VERSION_PATCH ${CMAKE_MATCH_1}) - set(BOTAN_VERSION "${BOTAN_VERSION_MAJOR}.${BOTAN_VERSION_MINOR}.${BOTAN_VERSION_PATCH}") + set(Botan_VERSION_PATCH ${CMAKE_MATCH_1}) + set(Botan_VERSION "${Botan_VERSION_MAJOR}.${Botan_VERSION_MINOR}.${Botan_VERSION_PATCH}") endif() find_library( - BOTAN_LIBRARY + Botan_LIBRARY_RELEASE NAMES ${BOTAN_NAMES} + HINTS ${PC_Botan_LIBRARY_DIRS} PATH_SUFFIXES release/lib lib DOC "The Botan (release) library") + if(WIN32 AND NOT MINGW) find_library( - BOTAN_LIBRARY_DEBUG + Botan_LIBRARY_DEBUG NAMES ${BOTAN_NAMES_DEBUG} + HINTS ${PC_Botan_LIBRARY_DIRS} PATH_SUFFIXES debug/lib lib DOC "The Botan debug library") - find_package_handle_standard_args( - Botan - REQUIRED_VARS BOTAN_LIBRARY BOTAN_LIBRARY_DEBUG BOTAN_INCLUDE_DIR - VERSION_VAR BOTAN_VERSION) -else() - find_package_handle_standard_args( - Botan - REQUIRED_VARS BOTAN_LIBRARY BOTAN_INCLUDE_DIR - VERSION_VAR BOTAN_VERSION) endif() -if(BOTAN_FOUND) - set(BOTAN_INCLUDE_DIRS ${BOTAN_INCLUDE_DIR}) - if(WIN32 AND NOT MINGW) - set(BOTAN_LIBRARIES optimized ${BOTAN_LIBRARY} debug ${BOTAN_LIBRARY_DEBUG}) - else() - set(BOTAN_LIBRARIES ${BOTAN_LIBRARY}) +include(SelectLibraryConfigurations) +select_library_configurations(Botan) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + Botan + REQUIRED_VARS Botan_LIBRARY Botan_INCLUDE_DIR + VERSION_VAR Botan_VERSION) + +if(Botan_FOUND) + if(NOT TARGET Botan::botan) + add_library(Botan::botan UNKNOWN IMPORTED) + endif() + if(Botan_LIBRARY_RELEASE) + set_property(TARGET Botan::botan APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE + ) + set_target_properties(Botan::botan PROPERTIES + IMPORTED_LOCATION_RELEASE ${Botan_LIBRARY_RELEASE}) + endif() + if(Botan_LIBRARY_DEBUG) + set_property(TARGET Botan::botan APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG + ) + set_target_properties(Botan::botan PROPERTIES + IMPORTED_LOCATION_DEBUG ${Botan_LIBRARY_DEBUG}) endif() + set_target_properties(Botan::botan PROPERTIES + INTERFACE_LINK_OPTIONS "${PC_Botan_LDFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Botan_INCLUDE_DIR}" + ) endif() -mark_as_advanced(BOTAN_INCLUDE_DIR BOTAN_LIBRARY BOTAN_LIBRARY_DEBUG) +mark_as_advanced(Botan_INCLUDE_DIR Botan_LIBRARY_RELEASE Botan_LIBRARY_DEBUG) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3956de2d33..083496d5dd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -352,11 +352,11 @@ find_package(Qt6 REQUIRED COMPONENTS SvgWidgets) # Core Library Definition add_library(keepassxc_core STATIC ${core_SOURCES}) target_compile_definitions(keepassxc_core PRIVATE KPXC_BUILDING_CORE) -target_link_libraries(keepassxc_core +target_link_libraries(keepassxc_core ${qrcode_LIB} Qt6::Core Qt6::Concurrent - ${BOTAN_LIBRARIES} + Botan::botan ${PCSC_LIBRARIES} ${ZXCVBN_LIBRARIES} ${ZLIB_LIBRARIES} diff --git a/src/autotype/CMakeLists.txt b/src/autotype/CMakeLists.txt index 77f75cb819..07e22340c9 100644 --- a/src/autotype/CMakeLists.txt +++ b/src/autotype/CMakeLists.txt @@ -38,7 +38,7 @@ elseif(WIN32) endif() add_library(autotype STATIC ${autotype_SOURCES}) -target_link_libraries(autotype Qt6::Core Qt6::Widgets) +target_link_libraries(autotype Qt6::Core Qt6::Widgets Botan::botan) if(UNIX AND NOT APPLE AND NOT HAIKU) target_link_libraries(autotype Qt6::DBus PkgConfig::Xkbcommon) diff --git a/src/browser/CMakeLists.txt b/src/browser/CMakeLists.txt index 7bfd2e047b..71cddcb9d1 100644 --- a/src/browser/CMakeLists.txt +++ b/src/browser/CMakeLists.txt @@ -37,5 +37,5 @@ if(KPXC_FEATURE_BROWSER) PasskeyUtils.cpp) add_library(browser STATIC ${browser_SOURCES}) - target_link_libraries(browser Qt6::Core Qt6::Concurrent Qt6::Widgets Qt6::Network ${BOTAN_LIBRARIES}) + target_link_libraries(browser Qt6::Core Qt6::Concurrent Qt6::Widgets Qt6::Network Botan::botan) endif() diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index 455e6e7af4..32a7d65b44 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -63,7 +63,7 @@ endif() add_library(cli STATIC ${cli_SOURCES}) target_link_libraries(cli PRIVATE ${ZXCVBN_LIBRARIES} text_stream - PUBLIC Qt6::Core) + PUBLIC Qt6::Core Botan::botan) add_executable(keepassxc-cli keepassxc-cli.cpp) target_link_libraries(keepassxc-cli diff --git a/src/fdosecrets/CMakeLists.txt b/src/fdosecrets/CMakeLists.txt index 27ecb06809..e43783beb3 100644 --- a/src/fdosecrets/CMakeLists.txt +++ b/src/fdosecrets/CMakeLists.txt @@ -30,5 +30,5 @@ if(KPXC_FEATURE_FDOSECRETS) objects/Prompt.cpp dbus/DBusTypes.cpp ) - target_link_libraries(fdosecrets Qt6::Core Qt6::Widgets Qt6::DBus ${BOTAN_LIBRARIES}) + target_link_libraries(fdosecrets Qt6::Core Qt6::Widgets Qt6::DBus Botan::botan) endif() diff --git a/src/keeshare/CMakeLists.txt b/src/keeshare/CMakeLists.txt index 5da855b501..45ec7c9329 100644 --- a/src/keeshare/CMakeLists.txt +++ b/src/keeshare/CMakeLists.txt @@ -27,5 +27,5 @@ set(keeshare_SOURCES ) add_library(keeshare STATIC ${keeshare_SOURCES}) -target_link_libraries(keeshare PUBLIC Qt6::Core Qt6::Widgets ${BOTAN_LIBRARIES} ${ZLIB_LIBRARIES} PRIVATE ${MINIZIP_LIBRARIES}) +target_link_libraries(keeshare PUBLIC Qt6::Core Qt6::Widgets Botan::botan ${ZLIB_LIBRARIES} PRIVATE ${MINIZIP_LIBRARIES}) include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/proxy/CMakeLists.txt b/src/proxy/CMakeLists.txt index b71311470f..16f009ed6a 100644 --- a/src/proxy/CMakeLists.txt +++ b/src/proxy/CMakeLists.txt @@ -21,7 +21,7 @@ if(KPXC_FEATURE_BROWSER) # Alloc must be defined in a static library to prevent clashing with clang ASAN definitions add_library(proxy_alloc STATIC ../core/Alloc.cpp) - target_link_libraries(proxy_alloc PRIVATE Qt6::Core ${BOTAN_LIBRARIES}) + target_link_libraries(proxy_alloc PRIVATE Qt6::Core Botan::botan) add_executable(keepassxc-proxy ${proxy_SOURCES}) target_link_libraries(keepassxc-proxy proxy_alloc Qt6::Core Qt6::Network) diff --git a/src/sshagent/CMakeLists.txt b/src/sshagent/CMakeLists.txt index 759d1ea9ea..254db812a5 100644 --- a/src/sshagent/CMakeLists.txt +++ b/src/sshagent/CMakeLists.txt @@ -29,5 +29,7 @@ if(KPXC_FEATURE_SSHAGENT) ) add_library(sshagent STATIC ${sshagent_SOURCES}) - target_link_libraries(sshagent Qt6::Core Qt6::Widgets Qt6::Network ${BOTAN_LIBRARIES}) + target_link_libraries(sshagent + PUBLIC Qt6::Core Qt6::Widgets Qt6::Network + PRIVATE Botan::botan) endif() From 602b0f3d53fa0cbd31d6767cad322da4ccba75e1 Mon Sep 17 00:00:00 2001 From: Adrien Ollier Date: Sat, 29 Aug 2026 10:11:34 +0200 Subject: [PATCH 2/9] Make non-Qt librairies PRIVATE except for keepassxc_core and keepassxc_gui --- src/CMakeLists.txt | 20 +++++++++++--------- src/autotype/CMakeLists.txt | 10 ++++++---- src/browser/CMakeLists.txt | 4 +++- src/cli/CMakeLists.txt | 4 ++-- src/fdosecrets/CMakeLists.txt | 4 +++- src/keeshare/CMakeLists.txt | 5 ++++- src/proxy/CMakeLists.txt | 4 +++- 7 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 083496d5dd..ba2636dbf2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -353,10 +353,11 @@ find_package(Qt6 REQUIRED COMPONENTS SvgWidgets) add_library(keepassxc_core STATIC ${core_SOURCES}) target_compile_definitions(keepassxc_core PRIVATE KPXC_BUILDING_CORE) target_link_libraries(keepassxc_core - ${qrcode_LIB} + PUBLIC Qt6::Core Qt6::Concurrent Botan::botan + ${qrcode_LIB} ${PCSC_LIBRARIES} ${ZXCVBN_LIBRARIES} ${ZLIB_LIBRARIES} @@ -367,6 +368,7 @@ target_link_libraries(keepassxc_core add_library(keepassxc_gui STATIC ${gui_SOURCES}) target_compile_definitions(keepassxc_gui PRIVATE KPXC_BUILDING_CORE) target_link_libraries(keepassxc_gui + PUBLIC keepassxc_core Qt6::Network Qt6::SvgWidgets @@ -378,27 +380,27 @@ target_link_libraries(keepassxc_gui ${sshagent_LIB}) if(APPLE) - target_link_libraries(keepassxc_gui "-framework Foundation -framework AppKit -framework Carbon -framework Security -framework LocalAuthentication -framework ScreenCaptureKit") + target_link_libraries(keepassxc_gui PUBLIC "-framework Foundation -framework AppKit -framework Carbon -framework Security -framework LocalAuthentication -framework ScreenCaptureKit") if(Qt6MacExtras_FOUND) - target_link_libraries(keepassxc_gui Qt6::MacExtras) + target_link_libraries(keepassxc_gui PRIVATE Qt6::MacExtras) endif() endif() if(HAIKU) - target_link_libraries(keepassxc_gui network) + target_link_libraries(keepassxc_gui PRIVATE network) endif() if(UNIX AND NOT APPLE) - target_link_libraries(keepassxc_core Qt6::DBus ${LIBUSB_LIBRARIES}) + target_link_libraries(keepassxc_core PRIVATE Qt6::DBus ${LIBUSB_LIBRARIES}) if("${CMAKE_SYSTEM}" MATCHES "Linux") - target_link_libraries(keepassxc_core ${KEYUTILS_LIBRARIES}) + target_link_libraries(keepassxc_core PRIVATE ${KEYUTILS_LIBRARIES}) endif() if(WITH_X11) - target_link_libraries(keepassxc_gui X11) + target_link_libraries(keepassxc_gui PRIVATE X11) endif() endif() if(WIN32) - target_link_libraries(keepassxc_gui Wtsapi32.lib Ws2_32.lib) + target_link_libraries(keepassxc_gui PRIVATE Wtsapi32.lib Ws2_32.lib) if (WINSDK) - target_link_libraries(keepassxc_gui WindowsApp.lib) + target_link_libraries(keepassxc_gui PRIVATE WindowsApp.lib) endif() endif() diff --git a/src/autotype/CMakeLists.txt b/src/autotype/CMakeLists.txt index 07e22340c9..d97e7be4d9 100644 --- a/src/autotype/CMakeLists.txt +++ b/src/autotype/CMakeLists.txt @@ -38,13 +38,15 @@ elseif(WIN32) endif() add_library(autotype STATIC ${autotype_SOURCES}) -target_link_libraries(autotype Qt6::Core Qt6::Widgets Botan::botan) +target_link_libraries(autotype + PUBLIC Qt6::Core Qt6::Widgets + PRIVATE Botan::botan) if(UNIX AND NOT APPLE AND NOT HAIKU) - target_link_libraries(autotype Qt6::DBus PkgConfig::Xkbcommon) + target_link_libraries(autotype PRIVATE Qt6::DBus PkgConfig::Xkbcommon) if(WITH_X11) - target_link_libraries(autotype ${X11_X11_LIB} ${X11_Xi_LIB} ${X11_XTest_LIB}) + target_link_libraries(autotype PRIVATE ${X11_X11_LIB} ${X11_Xi_LIB} ${X11_XTest_LIB}) endif() elseif(APPLE) - target_link_libraries(autotype "-framework Foundation" "-framework AppKit" "-framework Carbon" "-framework ScreenCaptureKit") + target_link_libraries(autotype PUBLIC "-framework Foundation" "-framework AppKit" "-framework Carbon" "-framework ScreenCaptureKit") endif() diff --git a/src/browser/CMakeLists.txt b/src/browser/CMakeLists.txt index 71cddcb9d1..4240882489 100644 --- a/src/browser/CMakeLists.txt +++ b/src/browser/CMakeLists.txt @@ -37,5 +37,7 @@ if(KPXC_FEATURE_BROWSER) PasskeyUtils.cpp) add_library(browser STATIC ${browser_SOURCES}) - target_link_libraries(browser Qt6::Core Qt6::Concurrent Qt6::Widgets Qt6::Network Botan::botan) + target_link_libraries(browser + PUBLIC Qt6::Core Qt6::Concurrent Qt6::Widgets Qt6::Network + PRIVATE Botan::botan) endif() diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index 32a7d65b44..f7e2395e11 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -62,8 +62,8 @@ endif() # cli library add_library(cli STATIC ${cli_SOURCES}) target_link_libraries(cli - PRIVATE ${ZXCVBN_LIBRARIES} text_stream - PUBLIC Qt6::Core Botan::botan) + PRIVATE ${ZXCVBN_LIBRARIES} Botan::botan text_stream + PUBLIC Qt6::Core) add_executable(keepassxc-cli keepassxc-cli.cpp) target_link_libraries(keepassxc-cli diff --git a/src/fdosecrets/CMakeLists.txt b/src/fdosecrets/CMakeLists.txt index e43783beb3..15a81fcc2b 100644 --- a/src/fdosecrets/CMakeLists.txt +++ b/src/fdosecrets/CMakeLists.txt @@ -30,5 +30,7 @@ if(KPXC_FEATURE_FDOSECRETS) objects/Prompt.cpp dbus/DBusTypes.cpp ) - target_link_libraries(fdosecrets Qt6::Core Qt6::Widgets Qt6::DBus Botan::botan) + target_link_libraries(fdosecrets + PUBLIC Qt6::Core Qt6::Widgets Qt6::DBus + PRIVATE Botan::botan) endif() diff --git a/src/keeshare/CMakeLists.txt b/src/keeshare/CMakeLists.txt index 45ec7c9329..0768576c87 100644 --- a/src/keeshare/CMakeLists.txt +++ b/src/keeshare/CMakeLists.txt @@ -27,5 +27,8 @@ set(keeshare_SOURCES ) add_library(keeshare STATIC ${keeshare_SOURCES}) -target_link_libraries(keeshare PUBLIC Qt6::Core Qt6::Widgets Botan::botan ${ZLIB_LIBRARIES} PRIVATE ${MINIZIP_LIBRARIES}) +target_link_libraries(keeshare + PUBLIC Qt6::Core Qt6::Widgets + PRIVATE Botan::botan ${MINIZIP_LIBRARIES} ${ZLIB_LIBRARIES}) + include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/src/proxy/CMakeLists.txt b/src/proxy/CMakeLists.txt index 16f009ed6a..33b7556ab1 100644 --- a/src/proxy/CMakeLists.txt +++ b/src/proxy/CMakeLists.txt @@ -21,7 +21,9 @@ if(KPXC_FEATURE_BROWSER) # Alloc must be defined in a static library to prevent clashing with clang ASAN definitions add_library(proxy_alloc STATIC ../core/Alloc.cpp) - target_link_libraries(proxy_alloc PRIVATE Qt6::Core Botan::botan) + target_link_libraries(proxy_alloc + PUBLIC Qt6::Core + PRIVATE Botan::botan) add_executable(keepassxc-proxy ${proxy_SOURCES}) target_link_libraries(keepassxc-proxy proxy_alloc Qt6::Core Qt6::Network) From cc78279c2ee5f117edb529d140e1cfd24684141f Mon Sep 17 00:00:00 2001 From: Adrien Ollier Date: Sat, 5 Sep 2026 20:07:28 +0200 Subject: [PATCH 3/9] remove unnecessary intermediate variables --- cmake/FindBotan.cmake | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/cmake/FindBotan.cmake b/cmake/FindBotan.cmake index 72bc0f3a41..d12767a4eb 100644 --- a/cmake/FindBotan.cmake +++ b/cmake/FindBotan.cmake @@ -43,15 +43,11 @@ if(PkgConfig_FOUND) pkg_search_module(PC_Botan QUIET botan-3 botan-2>=2.19.1 libbotan-2>=2.19.1 botan>=2.19.1) endif() -set(BOTAN_VERSIONS botan-3 botan-2) -set(BOTAN_NAMES botan-3 botan-2 botan) -set(BOTAN_NAMES_DEBUG botand-3 botand-2 botand botan botan-3) - find_path( Botan_INCLUDE_DIR NAMES botan/build.h HINTS ${PC_Botan_INCLUDE_DIRS} - PATH_SUFFIXES ${BOTAN_VERSIONS} + PATH_SUFFIXES botan-3 botan-2 DOC "The Botan include directory") if(Botan_INCLUDE_DIR) @@ -67,7 +63,7 @@ endif() find_library( Botan_LIBRARY_RELEASE - NAMES ${BOTAN_NAMES} + NAMES botan-3 botan-2 botan HINTS ${PC_Botan_LIBRARY_DIRS} PATH_SUFFIXES release/lib lib DOC "The Botan (release) library") @@ -75,7 +71,7 @@ find_library( if(WIN32 AND NOT MINGW) find_library( Botan_LIBRARY_DEBUG - NAMES ${BOTAN_NAMES_DEBUG} + NAMES botand-3 botand-2 botand botan botan-3 HINTS ${PC_Botan_LIBRARY_DIRS} PATH_SUFFIXES debug/lib lib DOC "The Botan debug library") From 05c33a3e90c997c2fb2b013d2aae6bdc5e305c92 Mon Sep 17 00:00:00 2001 From: Adrien Ollier Date: Sat, 19 Sep 2026 05:58:42 +0200 Subject: [PATCH 4/9] update botan minimum version in INSTALL.md --- INSTALL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/INSTALL.md b/INSTALL.md index 4eb2665a4c..74afa4d1c9 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -16,7 +16,7 @@ The following build tools must exist within your PATH: The following minimum versions of libraries must exist: * qt (>= 5.12.0) -* botan (>= 2.12.0 or >= 3.0.0) +* botan (>= 2.19.1 or >= 3.0.0) * zlib (>= 1.2.0) * Besides a working C++ toolchain, KeePassXC also has a number of direct build and runtime dependencies. For detailed information about how to install them, please refer to the GitHub wiki: From 941cbef6342c0943f268a7f02b293451e25be783 Mon Sep 17 00:00:00 2001 From: Adrien Ollier Date: Mon, 21 Sep 2026 10:15:55 +0200 Subject: [PATCH 5/9] Add copyright for cmake/FindBotan.cmake --- COPYING | 2 +- cmake/FindBotan.cmake | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/COPYING b/COPYING index a00aaf28c3..c0f5d4eb66 100644 --- a/COPYING +++ b/COPYING @@ -43,7 +43,7 @@ Copyright: 2012 - 2015, Lars Bilke License: BSD-3-clause Files: cmake/FindBotan.cmake -Copyright: none +Copyright: 2026, Adrien Ollier License: LGPL-2.1 Files: cmake/GenerateProductVersion.cmake diff --git a/cmake/FindBotan.cmake b/cmake/FindBotan.cmake index d12767a4eb..8653521141 100644 --- a/cmake/FindBotan.cmake +++ b/cmake/FindBotan.cmake @@ -1,3 +1,23 @@ +# Copyright (C) 2026 Adrien Ollier +# +# This file is part of KeePassXC (https://github.com/keepassxreboot/keepassxc). +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation; either version 1.2 of the License, or +# (at your option) any later version. +# +# This file is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this file; if not, contact the Free Software Foundation +# at licensing@fsf.org or write to the Free Software Foundation, Inc., +# 31 Milk Street, # 960789, Boston, MA 02196 USA. + + #[=======================================================================[.rst: FindBotan --------- From c09a6e334b249a23e93d10c53e630ac6f9986655 Mon Sep 17 00:00:00 2001 From: Adrien Ollier Date: Wed, 23 Sep 2026 00:39:17 +0200 Subject: [PATCH 6/9] Correct license header from LGPL-1.2 to LGPL-2.1 --- cmake/FindBotan.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/FindBotan.cmake b/cmake/FindBotan.cmake index 8653521141..402c8f0a77 100644 --- a/cmake/FindBotan.cmake +++ b/cmake/FindBotan.cmake @@ -4,7 +4,7 @@ # # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by -# the Free Software Foundation; either version 1.2 of the License, or +# the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # This file is distributed in the hope that it will be useful, From 6e02f414e28f16cdcde0085c4c799e3cf3f71997 Mon Sep 17 00:00:00 2001 From: Adrien Ollier Date: Wed, 23 Sep 2026 00:43:48 +0200 Subject: [PATCH 7/9] Add generic imported location fallback for Botan --- cmake/FindBotan.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/FindBotan.cmake b/cmake/FindBotan.cmake index 402c8f0a77..86e9397296 100644 --- a/cmake/FindBotan.cmake +++ b/cmake/FindBotan.cmake @@ -115,6 +115,7 @@ if(Botan_FOUND) IMPORTED_CONFIGURATIONS RELEASE ) set_target_properties(Botan::botan PROPERTIES + IMPORTED_LOCATION ${Botan_LIBRARY_RELEASE} IMPORTED_LOCATION_RELEASE ${Botan_LIBRARY_RELEASE}) endif() if(Botan_LIBRARY_DEBUG) From 0f9017c99339d6e1427b1a6e2704b3ab05a7ddbd Mon Sep 17 00:00:00 2001 From: Adrien Ollier Date: Wed, 23 Sep 2026 00:49:53 +0200 Subject: [PATCH 8/9] Keep Qt6::DBus public for keepassxc_core --- src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ba2636dbf2..cef407d5dd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -389,7 +389,7 @@ if(HAIKU) target_link_libraries(keepassxc_gui PRIVATE network) endif() if(UNIX AND NOT APPLE) - target_link_libraries(keepassxc_core PRIVATE Qt6::DBus ${LIBUSB_LIBRARIES}) + target_link_libraries(keepassxc_core PUBLIC Qt6::DBus PRIVATE ${LIBUSB_LIBRARIES}) if("${CMAKE_SYSTEM}" MATCHES "Linux") target_link_libraries(keepassxc_core PRIVATE ${KEYUTILS_LIBRARIES}) endif() From 5f99ee1d90ebacd985b494df9d45c9948fc4e9c1 Mon Sep 17 00:00:00 2001 From: Adrien Ollier Date: Wed, 23 Sep 2026 00:53:16 +0200 Subject: [PATCH 9/9] Make Botan a public dependency of the browser target --- src/browser/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/browser/CMakeLists.txt b/src/browser/CMakeLists.txt index 4240882489..bc044f9cb5 100644 --- a/src/browser/CMakeLists.txt +++ b/src/browser/CMakeLists.txt @@ -38,6 +38,5 @@ if(KPXC_FEATURE_BROWSER) add_library(browser STATIC ${browser_SOURCES}) target_link_libraries(browser - PUBLIC Qt6::Core Qt6::Concurrent Qt6::Widgets Qt6::Network - PRIVATE Botan::botan) + PUBLIC Qt6::Core Qt6::Concurrent Qt6::Widgets Qt6::Network Botan::botan) endif()