From 593b13079ef027159269ac63c6c20db6cfb8db4d Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 18 Aug 2022 10:12:27 +0100 Subject: [PATCH] cmake: Add `libqrencode` optional package support --- CMakeLists.txt | 4 ++++ cmake/optional.cmake | 20 ++++++++++++++++++++ src/qt/CMakeLists.txt | 1 + 3 files changed, 25 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c5d2fe2a12f2..f9c56c41a1e77 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -83,6 +83,7 @@ tristate_option(WITH_EXTERNAL_SIGNER "if Boost.Process is found." AUTO ) +tristate_option(WITH_QRENCODE "Enable QR code support." "if libqrencode is found." AUTO) option(BUILD_TESTS "Build test_bitcoin executable." ON) option(BUILD_BENCH "Build bench_bitcoin executable." ON) @@ -427,6 +428,9 @@ message(" SQLite, descriptor wallets .......... ${WITH_SQLITE}") message(" Berkeley DB, legacy wallets ......... ${WITH_BDB}") message("Optional packages:") message(" GUI ................................. ${WITH_GUI}") +if(WITH_GUI) + message(" QR code (GUI) ....................... ${WITH_QRENCODE}") +endif() message(" external signer ..................... ${WITH_EXTERNAL_SIGNER}") message(" NAT-PMP ............................. ${WITH_NATPMP}") message(" UPnP ................................ ${WITH_MINIUPNPC}") diff --git a/cmake/optional.cmake b/cmake/optional.cmake index 6bc803fb656f0..96db91f736eee 100644 --- a/cmake/optional.cmake +++ b/cmake/optional.cmake @@ -187,3 +187,23 @@ else() set(WITH_SQLITE OFF) set(WITH_BDB OFF) endif() + +if(WITH_GUI AND WITH_QRENCODE) + if(MSVC) + # TODO: vcpkg fails to build libqrencode package due to + # the build error in its libiconv dependency. + # See: https://github.com/microsoft/vcpkg/issues/36924. + else() + cross_pkg_check_modules(libqrencode libqrencode IMPORTED_TARGET) + endif() + if(TARGET PkgConfig::libqrencode) + set_target_properties(PkgConfig::libqrencode PROPERTIES + INTERFACE_COMPILE_DEFINITIONS USE_QRCODE + ) + set(WITH_QRENCODE ON) + elseif(WITH_QRENCODE STREQUAL "AUTO") + set(WITH_QRENCODE OFF) + else() + message(FATAL_ERROR "libqrencode requested, but not found.") + endif() +endif() diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index d3b7fea9d25a5..ece9eee05c1b8 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -112,6 +112,7 @@ target_link_libraries(bitcoinqt Boost::headers $ $ + $ $<$:-framework\ AppKit> $<$:shlwapi> )