|
| 1 | +# Copyright (c) 2023-present The Bitcoin Core developers |
| 2 | +# Distributed under the MIT software license, see the accompanying |
| 3 | +# file COPYING or https://opensource.org/license/mit/. |
| 4 | + |
| 5 | +# See: |
| 6 | +# - https://cmake.org/cmake/help/latest/manual/cmake-qt.7.html |
| 7 | +# - https://doc.qt.io/qt-5/cmake-manual.html |
| 8 | + |
| 9 | +set(CMAKE_AUTOMOC ON) |
| 10 | +set(CMAKE_AUTORCC ON) |
| 11 | +set(CMAKE_AUTOUIC ON) |
| 12 | +set(CMAKE_AUTOUIC_SEARCH_PATHS forms) |
| 13 | + |
| 14 | +set(qt_minimum_required_version 5.11.3) |
| 15 | + |
| 16 | +set(qt_components Core Gui Widgets Network LinguistTools) |
| 17 | + |
| 18 | +if(CMAKE_CROSSCOMPILING) |
| 19 | + # The find_package(Qt ...) function internally uses find_library() |
| 20 | + # calls for all dependencies to ensure their availability. |
| 21 | + # In turn, the find_library() inspects the well-known locations |
| 22 | + # on the file system; therefore, it must be able to find |
| 23 | + # platform-specific system libraries, for example: |
| 24 | + # /usr/x86_64-w64-mingw32/lib/libm.a or /usr/arm-linux-gnueabihf/lib/libm.a. |
| 25 | + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) |
| 26 | +endif() |
| 27 | + |
| 28 | +find_package(Qt5 ${qt_minimum_required_version} REQUIRED |
| 29 | + COMPONENTS ${qt_components} |
| 30 | + HINTS ${qt5_brew_prefix} |
| 31 | + PATH_SUFFIXES Qt5 # Required on OpenBSD systems. |
| 32 | +) |
| 33 | +unset(qt_components) |
| 34 | +message(STATUS "Found Qt: ${Qt5_DIR} (found suitable version \"${Qt5_VERSION}\", minimum required is \"${qt_minimum_required_version}\")") |
| 35 | +unset(qt_minimum_required_version) |
| 36 | + |
| 37 | +# TODO: The file(GLOB ...) command should be replaced with an explicit |
| 38 | +# file list. Such a change must be synced with the corresponding change |
| 39 | +# to https://github.com/bitcoin-core/bitcoin-maintainer-tools/blob/main/update-translations.py |
| 40 | +file(GLOB ts_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} locale/*.ts) |
| 41 | +set_source_files_properties(${ts_files} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/locale) |
| 42 | +qt5_add_translation(qm_files ${ts_files}) |
| 43 | + |
| 44 | +configure_file(bitcoin_locale.qrc bitcoin_locale.qrc COPYONLY) |
| 45 | + |
| 46 | +add_library(bitcoinqt STATIC EXCLUDE_FROM_ALL |
| 47 | + bantablemodel.cpp |
| 48 | + bitcoin.cpp |
| 49 | + bitcoinaddressvalidator.cpp |
| 50 | + bitcoinamountfield.cpp |
| 51 | + bitcoingui.cpp |
| 52 | + bitcoinunits.cpp |
| 53 | + clientmodel.cpp |
| 54 | + csvmodelwriter.cpp |
| 55 | + guiutil.cpp |
| 56 | + initexecutor.cpp |
| 57 | + intro.cpp |
| 58 | + modaloverlay.cpp |
| 59 | + networkstyle.cpp |
| 60 | + notificator.cpp |
| 61 | + optionsdialog.cpp |
| 62 | + optionsmodel.cpp |
| 63 | + peertablemodel.cpp |
| 64 | + peertablesortproxy.cpp |
| 65 | + platformstyle.cpp |
| 66 | + qvalidatedlineedit.cpp |
| 67 | + qvaluecombobox.cpp |
| 68 | + rpcconsole.cpp |
| 69 | + splashscreen.cpp |
| 70 | + trafficgraphwidget.cpp |
| 71 | + utilitydialog.cpp |
| 72 | + $<$<PLATFORM_ID:Windows>:winshutdownmonitor.cpp> |
| 73 | + $<$<PLATFORM_ID:Darwin>:macdockiconhandler.mm> |
| 74 | + $<$<PLATFORM_ID:Darwin>:macnotificationhandler.mm> |
| 75 | + $<$<PLATFORM_ID:Darwin>:macos_appnap.mm> |
| 76 | + bitcoin.qrc |
| 77 | + ${CMAKE_CURRENT_BINARY_DIR}/bitcoin_locale.qrc |
| 78 | +) |
| 79 | +target_compile_definitions(bitcoinqt |
| 80 | + PUBLIC |
| 81 | + QT_NO_KEYWORDS |
| 82 | + QT_USE_QSTRINGBUILDER |
| 83 | +) |
| 84 | +target_include_directories(bitcoinqt |
| 85 | + PUBLIC |
| 86 | + $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src> |
| 87 | +) |
| 88 | +target_link_libraries(bitcoinqt |
| 89 | + PUBLIC |
| 90 | + Qt5::Widgets |
| 91 | + PRIVATE |
| 92 | + core_interface |
| 93 | + bitcoin_cli |
| 94 | + leveldb |
| 95 | + Boost::headers |
| 96 | + $<TARGET_NAME_IF_EXISTS:NATPMP::NATPMP> |
| 97 | + $<TARGET_NAME_IF_EXISTS:MiniUPnPc::MiniUPnPc> |
| 98 | + $<$<PLATFORM_ID:Darwin>:-framework\ AppKit> |
| 99 | + $<$<CXX_COMPILER_ID:MSVC>:shlwapi> |
| 100 | +) |
| 101 | + |
| 102 | +if(ENABLE_WALLET) |
| 103 | + target_sources(bitcoinqt |
| 104 | + PRIVATE |
| 105 | + addressbookpage.cpp |
| 106 | + addresstablemodel.cpp |
| 107 | + askpassphrasedialog.cpp |
| 108 | + coincontroldialog.cpp |
| 109 | + coincontroltreewidget.cpp |
| 110 | + createwalletdialog.cpp |
| 111 | + editaddressdialog.cpp |
| 112 | + openuridialog.cpp |
| 113 | + overviewpage.cpp |
| 114 | + paymentserver.cpp |
| 115 | + psbtoperationsdialog.cpp |
| 116 | + qrimagewidget.cpp |
| 117 | + receivecoinsdialog.cpp |
| 118 | + receiverequestdialog.cpp |
| 119 | + recentrequeststablemodel.cpp |
| 120 | + sendcoinsdialog.cpp |
| 121 | + sendcoinsentry.cpp |
| 122 | + signverifymessagedialog.cpp |
| 123 | + transactiondesc.cpp |
| 124 | + transactiondescdialog.cpp |
| 125 | + transactionfilterproxy.cpp |
| 126 | + transactionoverviewwidget.cpp |
| 127 | + transactionrecord.cpp |
| 128 | + transactiontablemodel.cpp |
| 129 | + transactionview.cpp |
| 130 | + walletcontroller.cpp |
| 131 | + walletframe.cpp |
| 132 | + walletmodel.cpp |
| 133 | + walletmodeltransaction.cpp |
| 134 | + walletview.cpp |
| 135 | + ) |
| 136 | + target_link_libraries(bitcoinqt |
| 137 | + PRIVATE |
| 138 | + bitcoin_wallet |
| 139 | + Qt5::Network |
| 140 | + ) |
| 141 | +endif() |
| 142 | + |
| 143 | +if(CMAKE_CROSSCOMPILING) |
| 144 | + target_compile_definitions(bitcoinqt PRIVATE QT_STATICPLUGIN) |
| 145 | + if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND TARGET Qt5::QXcbIntegrationPlugin) |
| 146 | + target_compile_definitions(bitcoinqt PRIVATE QT_QPA_PLATFORM_XCB) |
| 147 | + elseif(WIN32 AND TARGET Qt5::QWindowsIntegrationPlugin AND TARGET Qt5::QWindowsVistaStylePlugin) |
| 148 | + target_compile_definitions(bitcoinqt PRIVATE QT_QPA_PLATFORM_WINDOWS) |
| 149 | + elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND TARGET Qt5::QCocoaIntegrationPlugin AND TARGET Qt5::QMacStylePlugin) |
| 150 | + target_compile_definitions(bitcoinqt PRIVATE QT_QPA_PLATFORM_COCOA) |
| 151 | + endif() |
| 152 | +endif() |
| 153 | + |
| 154 | +add_executable(bitcoin-qt |
| 155 | + main.cpp |
| 156 | + ../init/bitcoin-qt.cpp |
| 157 | +) |
| 158 | + |
| 159 | +target_link_libraries(bitcoin-qt |
| 160 | + core_interface |
| 161 | + bitcoinqt |
| 162 | + bitcoin_node |
| 163 | +) |
| 164 | + |
| 165 | +if(WIN32) |
| 166 | + set_target_properties(bitcoin-qt PROPERTIES WIN32_EXECUTABLE TRUE) |
| 167 | +endif() |
| 168 | + |
| 169 | +install(TARGETS bitcoin-qt |
| 170 | + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| 171 | + COMPONENT GUI |
| 172 | +) |
0 commit comments