diff --git a/CMakeLists.txt b/CMakeLists.txt index f69113e8b0d45..f07a159e34fae 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) cmake_dependent_option(BUILD_GUI_TESTS "Build test_bitcoin-qt executable." ON "BUILD_TESTS" OFF) @@ -479,6 +480,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 d008bbb5165fd..45b8b50da2334 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -134,6 +134,7 @@ target_link_libraries(bitcoinqt Boost::headers $ $ + $ $<$:-framework\ AppKit> $<$:shlwapi> )