From 30089b0cb61c1c40d6338877ffd5d72b31024271 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Fri, 1 Nov 2024 12:00:10 +0000 Subject: [PATCH 1/2] cmake: Add `FindQRencode` module --- CMakeLists.txt | 3 +- cmake/module/FindQRencode.cmake | 71 +++++++++++++++++++++++++++++++++ src/qt/CMakeLists.txt | 2 +- 3 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 cmake/module/FindQRencode.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e6e73dae03eb..aefd707a21a4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -135,8 +135,7 @@ cmake_dependent_option(ENABLE_EXTERNAL_SIGNER "Enable external signer support." cmake_dependent_option(WITH_QRENCODE "Enable QR code support." ON "BUILD_GUI" OFF) if(WITH_QRENCODE) - find_package(PkgConfig REQUIRED) - pkg_check_modules(libqrencode REQUIRED IMPORTED_TARGET libqrencode) + find_package(QRencode MODULE REQUIRED) set(USE_QRCODE TRUE) endif() diff --git a/cmake/module/FindQRencode.cmake b/cmake/module/FindQRencode.cmake new file mode 100644 index 0000000000000..39e3b8b679be2 --- /dev/null +++ b/cmake/module/FindQRencode.cmake @@ -0,0 +1,71 @@ +# Copyright (c) 2024-present The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or https://opensource.org/license/mit/. + +#[=======================================================================[ +FindQRencode +------------ + +Finds the QRencode header and library. + +This is a wrapper around find_package()/pkg_check_modules() commands that: + - facilitates searching in various build environments + - prints a standard log message + +#]=======================================================================] + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_QRencode QUIET libqrencode) +endif() + +find_path(QRencode_INCLUDE_DIR + NAMES qrencode.h + PATHS ${PC_QRencode_INCLUDE_DIRS} +) + +find_library(QRencode_LIBRARY_RELEASE + NAMES qrencode + PATHS ${PC_QRencode_LIBRARY_DIRS} +) +find_library(QRencode_LIBRARY_DEBUG + NAMES qrencoded qrencode + PATHS ${PC_QRencode_LIBRARY_DIRS} +) +include(SelectLibraryConfigurations) +select_library_configurations(QRencode) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(QRencode + REQUIRED_VARS QRencode_LIBRARY QRencode_INCLUDE_DIR + VERSION_VAR PC_QRencode_VERSION +) + +if(QRencode_FOUND) + if(NOT TARGET QRencode::QRencode) + add_library(QRencode::QRencode UNKNOWN IMPORTED) + endif() + if(QRencode_LIBRARY_RELEASE) + set_property(TARGET QRencode::QRencode APPEND PROPERTY + IMPORTED_CONFIGURATIONS RELEASE + ) + set_target_properties(QRencode::QRencode PROPERTIES + IMPORTED_LOCATION_RELEASE "${QRencode_LIBRARY_RELEASE}" + ) + endif() + if(QRencode_LIBRARY_DEBUG) + set_property(TARGET QRencode::QRencode APPEND PROPERTY + IMPORTED_CONFIGURATIONS DEBUG + ) + set_target_properties(QRencode::QRencode PROPERTIES + IMPORTED_LOCATION_DEBUG "${QRencode_LIBRARY_DEBUG}" + ) + endif() + set_target_properties(QRencode::QRencode PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${QRencode_INCLUDE_DIR}" + ) +endif() + +mark_as_advanced( + QRencode_INCLUDE_DIR +) diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index 71592124f2217..e8e3a146fa220 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -133,7 +133,7 @@ target_link_libraries(bitcoinqt bitcoin_cli leveldb Boost::headers - $ + $ $<$:-framework\ AppKit> $<$:shlwapi> ) From 9e5089dbb02ef8a32f484aab682ad06748e1a532 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Mon, 28 Oct 2024 14:09:12 +0000 Subject: [PATCH 2/2] build, msvc: Enable `libqrencode` vcpkg package --- CMakePresets.json | 6 ++---- doc/build-windows-msvc.md | 4 +--- vcpkg.json | 3 ++- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index c9d2d1b31fe92..597907b93243f 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -15,8 +15,7 @@ "toolchainFile": "$env{VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake", "cacheVariables": { "VCPKG_TARGET_TRIPLET": "x64-windows", - "BUILD_GUI": "ON", - "WITH_QRENCODE": "OFF" + "BUILD_GUI": "ON" } }, { @@ -32,8 +31,7 @@ "toolchainFile": "$env{VCPKG_ROOT}\\scripts\\buildsystems\\vcpkg.cmake", "cacheVariables": { "VCPKG_TARGET_TRIPLET": "x64-windows-static", - "BUILD_GUI": "ON", - "WITH_QRENCODE": "OFF" + "BUILD_GUI": "ON" } }, { diff --git a/doc/build-windows-msvc.md b/doc/build-windows-msvc.md index 80c2b77f1e83d..482b7a7d1fbb3 100644 --- a/doc/build-windows-msvc.md +++ b/doc/build-windows-msvc.md @@ -42,9 +42,7 @@ Available presets can be listed as follows: cmake --list-presets ``` -By default, all presets: -- Set `BUILD_GUI` to `ON`. -- Set `WITH_QRENCODE` to `OFF`, due to known build issues when using vcpkg's `libqrencode` package. +By default, all presets set `BUILD_GUI` to `ON`. ## Building diff --git a/vcpkg.json b/vcpkg.json index f7b15f9c685ba..69cfedeae5deb 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -25,7 +25,8 @@ "description": "Build GUI, Qt 5", "dependencies": [ "qt5-base", - "qt5-tools" + "qt5-tools", + "libqrencode" ] }, "sqlite": {