From f217df3fb506751cf8f6896bc6b2fcb7094aed0e Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Thu, 9 Jun 2022 17:17:01 +0200 Subject: [PATCH] cmake: Build `bitcoin-qt` executable An initial implementation without depends and wallet support. --- CMakeLists.txt | 7 ++-- src/CMakeLists.txt | 7 +++- src/qt/CMakeLists.txt | 88 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 src/qt/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 0dcbedfb4a4bf..94c2934d71cf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,7 @@ option(BUILD_CLI "Build bitcoin-cli" ON) option(BUILD_BITCOINCONSENSUS_LIB "Build bitcoinconsensus shared library" ON) option(BUILD_BITCOINKERNEL_LIB "Build experimental bitcoinkernel shared library" ON) option(ENABLE_WALLET "Enable wallet" ON) +option(BUILD_QT5_GUI "Build Qt5 widget-based GUI" ON) include(cmake/subtree-crc32c.cmake) include(cmake/subtree-leveldb.cmake) @@ -89,7 +90,7 @@ include(cmake/subtree-univalue.cmake) include(FindPkgConfig) -if(BUILD_DAEMON OR BUILD_CLI OR BUILD_BITCOINKERNEL_LIB) +if(BUILD_DAEMON OR BUILD_CLI OR BUILD_BITCOINKERNEL_LIB OR BUILD_QT5_GUI) # Find Boost headers only. find_package(Boost 1.64.0 REQUIRED) @@ -97,14 +98,14 @@ if(BUILD_DAEMON OR BUILD_CLI OR BUILD_BITCOINKERNEL_LIB) find_package(Threads REQUIRED) endif() -if(BUILD_DAEMON OR BUILD_CLI) +if(BUILD_DAEMON OR BUILD_CLI OR BUILD_QT5_GUI) pkg_check_modules(libevent REQUIRED libevent>=2.1.8 IMPORTED_TARGET) if(WIN32) target_link_libraries(PkgConfig::libevent INTERFACE iphlpapi ws2_32) endif() endif() -if(NOT WIN32 AND BUILD_DAEMON) +if(NOT WIN32 AND (BUILD_DAEMON OR BUILD_QT5_GUI)) pkg_check_modules(libevent_pthreads REQUIRED libevent_pthreads>=2.1.8 IMPORTED_TARGET) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6f2b50bebce4d..d8b1bd550f4f2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -205,7 +205,7 @@ if(BUILD_DAEMON) endif() -if(BUILD_CLI) +if(BUILD_CLI OR BUILD_QT5_GUI) add_library(rpc_client STATIC EXCLUDE_FROM_ALL) target_sources(rpc_client PRIVATE rpc/client.cpp) target_include_directories(rpc_client @@ -246,3 +246,8 @@ endif() if(BUILD_BITCOINKERNEL_LIB) add_subdirectory(kernel) endif() + + +if(BUILD_QT5_GUI) + add_subdirectory(qt) +endif() diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt new file mode 100644 index 0000000000000..fb3b9625e40cd --- /dev/null +++ b/src/qt/CMakeLists.txt @@ -0,0 +1,88 @@ +# Copyright (c) 2022 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +# See: +# - https://cmake.org/cmake/help/latest/manual/cmake-qt.7.html +# - https://doc.qt.io/qt-5/cmake-manual.html + +set(CMAKE_AUTOMOC ON) +set(CMAKE_AUTORCC ON) +set(CMAKE_AUTOUIC ON) +set(CMAKE_AUTOUIC_SEARCH_PATHS "${CMAKE_CURRENT_SOURCE_DIR}/forms") + +find_package(Qt5 5.11.3 REQUIRED COMPONENTS Widgets LinguistTools) + +file(GLOB TS_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "locale/*.ts") +set_source_files_properties(${TS_FILES} PROPERTIES OUTPUT_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/locale") +qt5_add_translation(QM_FILES ${TS_FILES}) + +add_library(bitcoinqt STATIC EXCLUDE_FROM_ALL) +target_sources(bitcoinqt + PRIVATE + bantablemodel.cpp + bitcoin.cpp + bitcoin.qrc + bitcoin_locale.qrc + bitcoinaddressvalidator.cpp + bitcoinamountfield.cpp + bitcoingui.cpp + bitcoinunits.cpp + clientmodel.cpp + csvmodelwriter.cpp + guiutil.cpp + initexecutor.cpp + intro.cpp + modaloverlay.cpp + networkstyle.cpp + notificator.cpp + optionsdialog.cpp + optionsmodel.cpp + peertablemodel.cpp + peertablesortproxy.cpp + platformstyle.cpp + qvalidatedlineedit.cpp + qvaluecombobox.cpp + rpcconsole.cpp + splashscreen.cpp + trafficgraphwidget.cpp + utilitydialog.cpp +) +# TODO: Rename `node/ui_interface.h`, and drop `SKIP_AUTOUIC ON`. +set_property( + SOURCE + bitcoin.cpp + bitcoingui.cpp + PROPERTY + SKIP_AUTOUIC ON +) +target_include_directories(bitcoinqt + PUBLIC + $/src +) +target_link_libraries(bitcoinqt + PRIVATE + Qt5::Widgets + rpc_client + leveldb +) + +add_executable(bitcoin-qt) +target_sources(bitcoin-qt + PRIVATE + main.cpp + ../init/bitcoin-qt.cpp +) +target_link_libraries(bitcoin-qt + PRIVATE + Qt5::Widgets + bitcoinqt + bitcoin_node + bitcoin_consensus + bitcoin_common + bitcoin_util + bitcoin_crypto +) +if(CMAKE_SYSTEM_NAME STREQUAL Windows) + target_link_options(bitcoin-qt PRIVATE -static) +endif()