diff --git a/cmake/modules/FindQREncode.cmake b/cmake/modules/FindQREncode.cmake new file mode 100644 --- /dev/null +++ b/cmake/modules/FindQREncode.cmake @@ -0,0 +1,27 @@ +# Try to find libqrencode +# QRENCODE_FOUND - system has libqrencode +# QRENCODE_INCLUDE_DIR - the libqrencode include directory +# QRENCODE_LIBRARY - Library needed to use libqrencode + +if (QRENCODE_INCLUDE_DIR AND QRENCODE_LIBRARY) + # Already in cache, be silent + set(QRENCODE_FIND_QUIETLY TRUE) +endif() + +find_path(QRENCODE_INCLUDE_DIR qrencode.h) + +find_library(QRENCODE_LIBRARY NAMES qrencode libqrencode) + +message(STATUS "QREncode lib: " ${QRENCODE_LIBRARY}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args( + QREncode DEFAULT_MSG + QRENCODE_INCLUDE_DIR + QRENCODE_LIBRARY +) + +mark_as_advanced(QRENCODE_INCLUDE_DIR QRENCODE_LIBRARY) + +set(QREncode_LIBRARIES ${QRENCODE_LIBRARY}) +set(QREncode_INCLUDE_DIRS ${QRENCODE_INCLUDE_DIR}) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,6 +19,7 @@ option(ENABLE_REDUCE_EXPORTS "Reduce the amount of exported symbols" OFF) option(ENABLE_STATIC_LIBSTDCXX "Statically link libstdc++" OFF) option(ENABLE_GLIBC_BACK_COMPAT "Enable Glibc compatibility features" OFF) +option(ENABLE_QRCODE "Enable QR code display" ON) # Allow usage of sanitizers by setting ECM_ENABLE_SANITIZERS if(ENABLE_SANITIZERS) diff --git a/src/config/CMakeLists.txt b/src/config/CMakeLists.txt --- a/src/config/CMakeLists.txt +++ b/src/config/CMakeLists.txt @@ -157,5 +157,12 @@ # Activate ZeroMQ set(ENABLE_ZMQ ${BUILD_BITCOIN_ZMQ}) +# Try to find libqrencode +# Only used in the wallet GUI +if(ENABLE_QRCODE AND BUILD_BITCOIN_WALLET AND BUILD_BITCOIN_QT) + find_package(QREncode REQUIRED) + set(USE_QRCODE 1 CACHE INTERNAL "QR code is enabled") +endif() + # Generate the config configure_file(bitcoin-config.h.cmake.in bitcoin-config.h ESCAPE_QUOTES) diff --git a/src/config/bitcoin-config.h.cmake.in b/src/config/bitcoin-config.h.cmake.in --- a/src/config/bitcoin-config.h.cmake.in +++ b/src/config/bitcoin-config.h.cmake.in @@ -55,4 +55,7 @@ #cmakedefine ENABLE_WALLET 1 #cmakedefine ENABLE_ZMQ 1 +/* Define if QR support should be compiled in */ +#cmakedefine USE_QRCODE 1 + #endif // BITCOIN_BITCOIN_CONFIG_H diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -225,6 +225,11 @@ ) target_link_libraries(bitcoin-qt-base wallet) + + if(ENABLE_QRCODE) + target_include_directories(bitcoin-qt-base PUBLIC ${QRENCODE_INCLUDE_DIR}) + target_link_libraries(bitcoin-qt-base ${QRENCODE_LIBRARY}) + endif() endif() # The executable