-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmake: Build bitcoin-qt
executable
#77
Changes from all commits
adcb895
2609377
b342887
923d883
de62901
7f4babc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Copyright (c) 2023-present The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or https://opensource.org/license/mit/. | ||
|
||
set(WITH_GUI "AUTO" CACHE STRING "Build GUI ([AUTO], Qt5, OFF)") | ||
set(with_gui_values AUTO Qt5 OFF) | ||
if(NOT WITH_GUI IN_LIST with_gui_values) | ||
message(FATAL_ERROR "WITH_GUI value is \"${WITH_GUI}\", but must be one of \"AUTO\", \"Qt5\" or \"OFF\".") | ||
endif() | ||
|
||
if(WITH_GUI) | ||
set(QT_NO_CREATE_VERSIONLESS_FUNCTIONS ON) | ||
set(QT_NO_CREATE_VERSIONLESS_TARGETS ON) | ||
|
||
if(BREW_COMMAND) | ||
execute_process( | ||
COMMAND ${BREW_COMMAND} --prefix qt@5 | ||
OUTPUT_VARIABLE qt5_brew_prefix | ||
ERROR_QUIET | ||
OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
endif() | ||
|
||
if(WITH_GUI STREQUAL "AUTO") | ||
# The PATH_SUFFIXES option is required on OpenBSD systems. | ||
find_package(QT NAMES Qt5 | ||
COMPONENTS Core | ||
HINTS ${qt5_brew_prefix} | ||
PATH_SUFFIXES Qt5 | ||
) | ||
if(QT_FOUND) | ||
set(WITH_GUI Qt${QT_VERSION_MAJOR}) | ||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") | ||
enable_language(OBJCXX) | ||
set(CMAKE_OBJCXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") | ||
set(CMAKE_OBJCXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") | ||
set(CMAKE_OBJCXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") | ||
set(CMAKE_OBJCXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}") | ||
endif() | ||
else() | ||
message(WARNING "Qt not found, disabling.\n" | ||
"To skip this warning check, use \"-DWITH_GUI=OFF\".\n") | ||
set(WITH_GUI OFF) | ||
endif() | ||
endif() | ||
endif() |
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -91,8 +91,16 @@ set(PKG_CONFIG_PATH "@depends_prefix@/lib/pkgconfig") | |||||||||||
set(PKG_CONFIG_LIBDIR "${PKG_CONFIG_PATH}") | ||||||||||||
set(QT_TRANSLATIONS_DIR "@depends_prefix@/translations") | ||||||||||||
|
||||||||||||
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE) | ||||||||||||
# The find_package(Qt ...) function internally uses find_library() | ||||||||||||
# calls for all dependencies to ensure their availability. | ||||||||||||
# In turn, the find_library() inspects the well-known locations | ||||||||||||
# on the file system; therefore, a hint is required. | ||||||||||||
set(CMAKE_FRAMEWORK_PATH "@OSX_SDK@/System/Library/Frameworks") | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can't remember the exact comments from yesterday, but I think this could use some docs to explain why the SDK is leaking out of the compiler invocation. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've added an explanation comment: bitcoin/depends/toolchain.cmake.in Lines 95 to 99 in b0a1bae
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm still confused by this. Does this relate to the previous commit? If I unset There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
What exactly is the source of your confusion: the code or the comment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code, but I guess I should just look at what cmake does here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. https://cmake.org/cmake/help/latest/command/find_library.html describes the role of the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For Qt's part, please see https://github.com/qt/qtbase/blob/da6e958319e95fe564d3b30c931492dd666bfaff/mkspecs/features/data/cmake/Qt5BasicConfig.cmake.in#L77-L134 The second invocation: find_library(_Qt5$${CMAKE_MODULE_NAME}_${Configuration}_${_lib}_PATH ${_lib} HINTS ${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES}) actually uses the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
No, it doesn't. The Unsetting |
||||||||||||
endif() | ||||||||||||
|
||||||||||||
if(NOT WITH_GUI AND "@no_qt@" STREQUAL "1") | ||||||||||||
set(WITH_GUI "no" CACHE STRING "") | ||||||||||||
set(WITH_GUI OFF CACHE STRING "") | ||||||||||||
endif() | ||||||||||||
|
||||||||||||
if(NOT WITH_QRENCODE AND "@no_qr@" STREQUAL "1") | ||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
# Copyright (c) 2023-present The Bitcoin Core developers | ||
# Distributed under the MIT software license, see the accompanying | ||
# file COPYING or https://opensource.org/license/mit/. | ||
|
||
# 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 forms) | ||
|
||
set(qt_minimum_required_version 5.11.3) | ||
|
||
set(qt_components Core Gui Widgets Network LinguistTools) | ||
|
||
if(CMAKE_CROSSCOMPILING) | ||
# The find_package(Qt ...) function internally uses find_library() | ||
# calls for all dependencies to ensure their availability. | ||
# In turn, the find_library() inspects the well-known locations | ||
# on the file system; therefore, it must be able to find | ||
# platform-specific system libraries, for example: | ||
# /usr/x86_64-w64-mingw32/lib/libm.a or /usr/arm-linux-gnueabihf/lib/libm.a. | ||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) | ||
endif() | ||
|
||
find_package(Qt5 ${qt_minimum_required_version} REQUIRED | ||
COMPONENTS ${qt_components} | ||
HINTS ${qt5_brew_prefix} | ||
PATH_SUFFIXES Qt5 # Required on OpenBSD systems. | ||
) | ||
unset(qt_components) | ||
message(STATUS "Found Qt: ${Qt5_DIR} (found suitable version \"${Qt5_VERSION}\", minimum required is \"${qt_minimum_required_version}\")") | ||
unset(qt_minimum_required_version) | ||
|
||
# TODO: The file(GLOB ...) command should be replaced with an explicit | ||
# file list. Such a change must be synced with the corresponding change | ||
# to https://github.com/bitcoin-core/bitcoin-maintainer-tools/blob/main/update-translations.py | ||
file(GLOB ts_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} locale/*.ts) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why glob rather than listing explicitly? This introduces potential non-determinism based on the builder's environment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right. I would consider this approach as a temporary one until the https://github.com/bitcoin-core/bitcoin-maintainer-tools/blob/main/update-translations.py script is updated. Specifically, its Also the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a comment to make this clear? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Added. |
||
set_source_files_properties(${ts_files} PROPERTIES OUTPUT_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/locale) | ||
qt5_add_translation(qm_files ${ts_files}) | ||
|
||
configure_file(bitcoin_locale.qrc bitcoin_locale.qrc COPYONLY) | ||
|
||
add_library(bitcoinqt STATIC EXCLUDE_FROM_ALL | ||
bantablemodel.cpp | ||
bitcoin.cpp | ||
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 | ||
$<$<PLATFORM_ID:Windows>:winshutdownmonitor.cpp> | ||
$<$<PLATFORM_ID:Darwin>:macdockiconhandler.mm> | ||
$<$<PLATFORM_ID:Darwin>:macnotificationhandler.mm> | ||
$<$<PLATFORM_ID:Darwin>:macos_appnap.mm> | ||
bitcoin.qrc | ||
${CMAKE_CURRENT_BINARY_DIR}/bitcoin_locale.qrc | ||
) | ||
target_compile_definitions(bitcoinqt | ||
PUBLIC | ||
QT_NO_KEYWORDS | ||
QT_USE_QSTRINGBUILDER | ||
) | ||
target_include_directories(bitcoinqt | ||
PUBLIC | ||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src> | ||
) | ||
target_link_libraries(bitcoinqt | ||
PUBLIC | ||
Qt5::Widgets | ||
PRIVATE | ||
core_interface | ||
bitcoin_cli | ||
leveldb | ||
Boost::headers | ||
$<TARGET_NAME_IF_EXISTS:NATPMP::NATPMP> | ||
$<TARGET_NAME_IF_EXISTS:MiniUPnPc::MiniUPnPc> | ||
$<$<PLATFORM_ID:Darwin>:-framework\ AppKit> | ||
$<$<CXX_COMPILER_ID:MSVC>:shlwapi> | ||
) | ||
|
||
if(ENABLE_WALLET) | ||
target_sources(bitcoinqt | ||
PRIVATE | ||
addressbookpage.cpp | ||
addresstablemodel.cpp | ||
askpassphrasedialog.cpp | ||
coincontroldialog.cpp | ||
coincontroltreewidget.cpp | ||
createwalletdialog.cpp | ||
editaddressdialog.cpp | ||
openuridialog.cpp | ||
overviewpage.cpp | ||
paymentserver.cpp | ||
psbtoperationsdialog.cpp | ||
qrimagewidget.cpp | ||
receivecoinsdialog.cpp | ||
receiverequestdialog.cpp | ||
recentrequeststablemodel.cpp | ||
sendcoinsdialog.cpp | ||
sendcoinsentry.cpp | ||
signverifymessagedialog.cpp | ||
transactiondesc.cpp | ||
transactiondescdialog.cpp | ||
transactionfilterproxy.cpp | ||
transactionoverviewwidget.cpp | ||
transactionrecord.cpp | ||
transactiontablemodel.cpp | ||
transactionview.cpp | ||
walletcontroller.cpp | ||
walletframe.cpp | ||
walletmodel.cpp | ||
walletmodeltransaction.cpp | ||
walletview.cpp | ||
) | ||
target_link_libraries(bitcoinqt | ||
PRIVATE | ||
bitcoin_wallet | ||
Qt5::Network | ||
) | ||
endif() | ||
|
||
if(CMAKE_CROSSCOMPILING) | ||
target_compile_definitions(bitcoinqt PRIVATE QT_STATICPLUGIN) | ||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND TARGET Qt5::QXcbIntegrationPlugin) | ||
target_compile_definitions(bitcoinqt PRIVATE QT_QPA_PLATFORM_XCB) | ||
elseif(WIN32 AND TARGET Qt5::QWindowsIntegrationPlugin AND TARGET Qt5::QWindowsVistaStylePlugin) | ||
target_compile_definitions(bitcoinqt PRIVATE QT_QPA_PLATFORM_WINDOWS) | ||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND TARGET Qt5::QCocoaIntegrationPlugin AND TARGET Qt5::QMacStylePlugin) | ||
target_compile_definitions(bitcoinqt PRIVATE QT_QPA_PLATFORM_COCOA) | ||
endif() | ||
endif() | ||
|
||
add_executable(bitcoin-qt | ||
main.cpp | ||
../init/bitcoin-qt.cpp | ||
) | ||
|
||
target_link_libraries(bitcoin-qt | ||
core_interface | ||
bitcoinqt | ||
bitcoin_node | ||
) | ||
|
||
if(WIN32) | ||
set_target_properties(bitcoin-qt PROPERTIES WIN32_EXECUTABLE TRUE) | ||
endif() | ||
|
||
install(TARGETS bitcoin-qt | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
COMPONENT GUI | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
"libevent", | ||
"miniupnpc", | ||
"sqlite3", | ||
"qt5-base", | ||
"qt5-tools", | ||
"zeromq" | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain this change? It's been ages since I've messed with the qt build, but IIRC this was done to keep the installed libs to a minimum. Now we just install everything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Otherwise, the CMake-driven configuration fails. I cannot point at the exact error as I did that change a year ago and just don't remember the exact problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. Sounds like maybe it just added some additional cmake targets added to our list? Otherwise I believe this means
$(package)_qt_libs
is now unused.Mind adding a comment?
"TODO: Investigate whether specific targets can be used here to minimize the amount of files/components installed.".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.