Skip to content

Commit

Permalink
cmake: Build bitcoin-qt executable
Browse files Browse the repository at this point in the history
An initial implementation without depends and wallet support.
  • Loading branch information
hebasto committed Jun 9, 2022
1 parent e9d4c40 commit f217df3
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 4 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -89,22 +90,22 @@ 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)

set(THREADS_PREFER_PTHREAD_FLAG ON)
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()

Expand Down
7 changes: 6 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -246,3 +246,8 @@ endif()
if(BUILD_BITCOINKERNEL_LIB)
add_subdirectory(kernel)
endif()


if(BUILD_QT5_GUI)
add_subdirectory(qt)
endif()
88 changes: 88 additions & 0 deletions src/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>/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()

0 comments on commit f217df3

Please sign in to comment.