CMakeLists.txt
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 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") 6 enable_language(OBJCXX) 7 set(CMAKE_OBJCXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") 8 set(CMAKE_OBJCXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") 9 set(CMAKE_OBJCXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") 10 set(CMAKE_OBJCXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}") 11 string(APPEND CMAKE_OBJCXX_COMPILE_OBJECT " ${APPEND_CPPFLAGS} ${APPEND_CXXFLAGS}") 12 endif() 13 14 get_target_property(qt_lib_type Qt6::Core TYPE) 15 16 function(import_plugins target) 17 if(qt_lib_type STREQUAL "STATIC_LIBRARY") 18 set(plugins Qt6::QMinimalIntegrationPlugin) 19 if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|FreeBSD)$") 20 list(APPEND plugins Qt6::QXcbIntegrationPlugin) 21 elseif(WIN32) 22 list(APPEND plugins Qt6::QWindowsIntegrationPlugin Qt6::QModernWindowsStylePlugin) 23 elseif(APPLE) 24 list(APPEND plugins Qt6::QCocoaIntegrationPlugin Qt6::QMacStylePlugin) 25 endif() 26 qt6_import_plugins(${target} 27 INCLUDE ${plugins} 28 EXCLUDE_BY_TYPE 29 accessiblebridge 30 platforms 31 platforms_darwin 32 xcbglintegrations 33 platformthemes 34 platforminputcontexts 35 generic 36 iconengines 37 imageformats 38 egldeviceintegrations 39 styles 40 networkaccess 41 networkinformation 42 tls 43 ) 44 endif() 45 endfunction() 46 47 # For Qt-specific commands and variables, please consult: 48 # - https://cmake.org/cmake/help/latest/manual/cmake-qt.7.html 49 # - https://doc.qt.io/qt-5/cmake-manual.html 50 51 set(CMAKE_AUTOMOC ON) 52 set(CMAKE_AUTOMOC_MOC_OPTIONS "-p${CMAKE_CURRENT_SOURCE_DIR}") 53 set(CMAKE_AUTOUIC ON) 54 set(CMAKE_AUTOUIC_SEARCH_PATHS forms) 55 56 set(CMAKE_AUTORCC OFF) 57 configure_file(bitcoin_locale.qrc bitcoin_locale.qrc USE_SOURCE_PERMISSIONS COPYONLY) 58 qt6_add_resources(BITCOIN_QRC bitcoin.qrc) 59 qt6_add_resources(BITCOIN_LOCALE_QRC ${CMAKE_CURRENT_BINARY_DIR}/bitcoin_locale.qrc) 60 # See: https://bugreports.qt.io/browse/QTBUG-141858. 61 get_target_property(warn_flags warn_interface INTERFACE_COMPILE_OPTIONS) 62 if("-Wtrailing-whitespace=any" IN_LIST warn_flags) 63 set_source_files_properties(${BITCOIN_QRC} ${BITCOIN_LOCALE_QRC} PROPERTIES COMPILE_OPTIONS -Wno-trailing-whitespace) 64 endif() 65 unset(warn_flags) 66 67 # The bitcoinqt sources have to include headers in 68 # order to parse them to collect translatable strings. 69 add_library(bitcoinqt STATIC EXCLUDE_FROM_ALL 70 bantablemodel.cpp 71 bantablemodel.h 72 bitcoin.cpp 73 bitcoin.h 74 bitcoinaddressvalidator.cpp 75 bitcoinaddressvalidator.h 76 bitcoinamountfield.cpp 77 bitcoinamountfield.h 78 bitcoingui.cpp 79 bitcoingui.h 80 bitcoinunits.cpp 81 bitcoinunits.h 82 clientmodel.cpp 83 clientmodel.h 84 csvmodelwriter.cpp 85 csvmodelwriter.h 86 freespacechecker.cpp 87 freespacechecker.h 88 guiutil.cpp 89 guiutil.h 90 initexecutor.cpp 91 initexecutor.h 92 intro.cpp 93 intro.h 94 $<$<PLATFORM_ID:Darwin>:macdockiconhandler.h> 95 $<$<PLATFORM_ID:Darwin>:macdockiconhandler.mm> 96 $<$<PLATFORM_ID:Darwin>:macnotificationhandler.h> 97 $<$<PLATFORM_ID:Darwin>:macnotificationhandler.mm> 98 $<$<PLATFORM_ID:Darwin>:macos_appnap.h> 99 $<$<PLATFORM_ID:Darwin>:macos_appnap.mm> 100 modaloverlay.cpp 101 modaloverlay.h 102 networkstyle.cpp 103 networkstyle.h 104 notificator.cpp 105 notificator.h 106 optionsdialog.cpp 107 optionsdialog.h 108 optionsmodel.cpp 109 optionsmodel.h 110 peertablemodel.cpp 111 peertablemodel.h 112 peertablesortproxy.cpp 113 peertablesortproxy.h 114 platformstyle.cpp 115 platformstyle.h 116 qvalidatedlineedit.cpp 117 qvalidatedlineedit.h 118 qvaluecombobox.cpp 119 qvaluecombobox.h 120 rpcconsole.cpp 121 rpcconsole.h 122 splashscreen.cpp 123 splashscreen.h 124 trafficgraphwidget.cpp 125 trafficgraphwidget.h 126 utilitydialog.cpp 127 utilitydialog.h 128 $<$<PLATFORM_ID:Windows>:winshutdownmonitor.cpp> 129 $<$<PLATFORM_ID:Windows>:winshutdownmonitor.h> 130 ${BITCOIN_QRC} 131 ${BITCOIN_LOCALE_QRC} 132 ) 133 target_compile_definitions(bitcoinqt 134 PUBLIC 135 QT_NO_KEYWORDS 136 QT_USE_QSTRINGBUILDER 137 ) 138 target_include_directories(bitcoinqt 139 PUBLIC 140 $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src> 141 ) 142 set_property(SOURCE macnotificationhandler.mm 143 # Ignore warnings "'NSUserNotificationCenter' is deprecated: first deprecated in macOS 11.0". 144 APPEND PROPERTY COMPILE_OPTIONS -Wno-deprecated-declarations 145 ) 146 target_link_libraries(bitcoinqt 147 PUBLIC 148 Qt6::Widgets 149 PRIVATE 150 core_interface 151 bitcoin_cli 152 leveldb 153 Boost::headers 154 $<TARGET_NAME_IF_EXISTS:QRencode::QRencode> 155 $<$<PLATFORM_ID:Darwin>:-framework\ AppKit> 156 $<$<CXX_COMPILER_ID:MSVC>:shlwapi> 157 ) 158 159 if(ENABLE_WALLET) 160 target_sources(bitcoinqt 161 PRIVATE 162 addressbookpage.cpp 163 addressbookpage.h 164 addresstablemodel.cpp 165 addresstablemodel.h 166 askpassphrasedialog.cpp 167 askpassphrasedialog.h 168 coincontroldialog.cpp 169 coincontroldialog.h 170 coincontroltreewidget.cpp 171 coincontroltreewidget.h 172 createwalletdialog.cpp 173 createwalletdialog.h 174 editaddressdialog.cpp 175 editaddressdialog.h 176 openuridialog.cpp 177 openuridialog.h 178 overviewpage.cpp 179 overviewpage.h 180 paymentserver.cpp 181 paymentserver.h 182 psbtoperationsdialog.cpp 183 psbtoperationsdialog.h 184 qrimagewidget.cpp 185 qrimagewidget.h 186 receivecoinsdialog.cpp 187 receivecoinsdialog.h 188 receiverequestdialog.cpp 189 receiverequestdialog.h 190 recentrequeststablemodel.cpp 191 recentrequeststablemodel.h 192 sendcoinsdialog.cpp 193 sendcoinsdialog.h 194 sendcoinsentry.cpp 195 sendcoinsentry.h 196 signverifymessagedialog.cpp 197 signverifymessagedialog.h 198 transactiondesc.cpp 199 transactiondesc.h 200 transactiondescdialog.cpp 201 transactiondescdialog.h 202 transactionfilterproxy.cpp 203 transactionfilterproxy.h 204 transactionoverviewwidget.cpp 205 transactionoverviewwidget.h 206 transactionrecord.cpp 207 transactionrecord.h 208 transactiontablemodel.cpp 209 transactiontablemodel.h 210 transactionview.cpp 211 transactionview.h 212 walletcontroller.cpp 213 walletcontroller.h 214 walletframe.cpp 215 walletframe.h 216 walletmodel.cpp 217 walletmodel.h 218 walletmodeltransaction.cpp 219 walletmodeltransaction.h 220 walletview.cpp 221 walletview.h 222 ) 223 target_link_libraries(bitcoinqt 224 PRIVATE 225 bitcoin_wallet 226 Qt6::Network 227 ) 228 endif() 229 230 if(WITH_DBUS) 231 target_link_libraries(bitcoinqt PRIVATE Qt6::DBus) 232 endif() 233 234 if(qt_lib_type STREQUAL "STATIC_LIBRARY") 235 # We want to define static plugins to link ourselves, thus preventing 236 # automatic linking against a "sane" set of default static plugins. 237 qt6_import_plugins(bitcoinqt 238 EXCLUDE_BY_TYPE 239 accessiblebridge 240 platforms 241 platforms_darwin 242 xcbglintegrations 243 platformthemes 244 platforminputcontexts 245 generic 246 iconengines 247 imageformats 248 egldeviceintegrations 249 styles 250 networkaccess 251 networkinformation 252 tls 253 ) 254 endif() 255 256 add_subdirectory(locale) 257 258 add_executable(bitcoin-qt 259 main.cpp 260 ../init/bitcoin-qt.cpp 261 ) 262 263 add_windows_resources(bitcoin-qt res/bitcoin-qt-res.rc) 264 add_windows_application_manifest(bitcoin-qt) 265 266 target_link_libraries(bitcoin-qt 267 core_interface 268 bitcoinqt 269 bitcoin_node 270 ) 271 272 import_plugins(bitcoin-qt) 273 install_binary_component(bitcoin-qt HAS_MANPAGE) 274 if(WIN32) 275 set_target_properties(bitcoin-qt PROPERTIES WIN32_EXECUTABLE TRUE) 276 endif() 277 278 if(ENABLE_IPC) 279 add_executable(bitcoin-gui 280 main.cpp 281 ../init/bitcoin-gui.cpp 282 ) 283 target_link_libraries(bitcoin-gui 284 core_interface 285 bitcoinqt 286 bitcoin_node 287 bitcoin_ipc 288 ) 289 import_plugins(bitcoin-gui) 290 install_binary_component(bitcoin-gui INTERNAL) 291 if(WIN32) 292 set_target_properties(bitcoin-gui PROPERTIES WIN32_EXECUTABLE TRUE) 293 endif() 294 endif() 295 296 if(BUILD_GUI_TESTS) 297 add_subdirectory(test) 298 endif() 299 300 find_program(XGETTEXT_EXECUTABLE xgettext) 301 if(NOT XGETTEXT_EXECUTABLE) 302 add_custom_target(translate 303 COMMAND ${CMAKE_COMMAND} -E echo "Error: GNU gettext-tools not found" 304 ) 305 else() 306 add_custom_target(translate COMMAND ${CMAKE_COMMAND} 307 -D "PROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}" 308 -D "COPYRIGHT_HOLDERS=${COPYRIGHT_HOLDERS}" 309 -D "LCONVERT_EXECUTABLE=$<TARGET_FILE:Qt6::lconvert>" 310 -D "LUPDATE_EXECUTABLE=$<TARGET_FILE:Qt6::lupdate>" 311 -D "XGETTEXT_EXECUTABLE=${XGETTEXT_EXECUTABLE}" 312 -P ${PROJECT_SOURCE_DIR}/share/qt/translate.cmake 313 ) 314 endif()