Skip to content

Commit

Permalink
cmake: Add libqrencode optional package support
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Mar 23, 2024
1 parent 5c610a4 commit be130a9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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}")
Expand Down
20 changes: 20 additions & 0 deletions cmake/optional.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
1 change: 1 addition & 0 deletions src/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ target_link_libraries(bitcoinqt
Boost::headers
$<TARGET_NAME_IF_EXISTS:NATPMP::NATPMP>
$<TARGET_NAME_IF_EXISTS:MiniUPnPc::MiniUPnPc>
$<TARGET_NAME_IF_EXISTS:PkgConfig::libqrencode>
$<$<PLATFORM_ID:Darwin>:-framework\ AppKit>
$<$<CXX_COMPILER_ID:MSVC>:shlwapi>
)
Expand Down

0 comments on commit be130a9

Please sign in to comment.