0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-08 10:31:50 -05:00

cmake: Build test_bitcoin-qt executable

This commit is contained in:
Hennadii Stepanov 2024-08-16 19:28:59 +01:00
parent 10fcc668a3
commit 975d67369b
No known key found for this signature in database
GPG key ID: 410108112E7EA81F
3 changed files with 66 additions and 0 deletions

View file

@ -152,6 +152,7 @@ if(WITH_QRENCODE)
endif()
cmake_dependent_option(WITH_DBUS "Enable DBus support." ON "CMAKE_SYSTEM_NAME STREQUAL \"Linux\" AND BUILD_GUI" OFF)
cmake_dependent_option(BUILD_GUI_TESTS "Build test_bitcoin-qt executable." ON "BUILD_GUI;BUILD_TESTS" OFF)
if(BUILD_GUI)
set(qt_components Core Gui Widgets LinguistTools)
if(ENABLE_WALLET)
@ -161,6 +162,9 @@ if(BUILD_GUI)
list(APPEND qt_components DBus)
set(USE_DBUS TRUE)
endif()
if(BUILD_GUI_TESTS)
list(APPEND qt_components Test)
endif()
find_package(Qt5 5.11.3 MODULE REQUIRED
COMPONENTS ${qt_components}
)
@ -208,6 +212,7 @@ if(BUILD_FOR_FUZZING)
set(WITH_MINIUPNPC OFF)
set(WITH_ZMQ OFF)
set(BUILD_TESTS OFF)
set(BUILD_GUI_TESTS OFF)
set(BUILD_BENCH OFF)
set(BUILD_FUZZ_BINARY ON)
@ -506,6 +511,7 @@ message(" QR code (GUI) ....................... ${WITH_QRENCODE}")
message(" DBus (GUI, Linux only) .............. ${WITH_DBUS}")
message("Tests:")
message(" test_bitcoin ........................ ${BUILD_TESTS}")
message(" test_bitcoin-qt ..................... ${BUILD_GUI_TESTS}")
message(" bench_bitcoin ....................... ${BUILD_BENCH}")
message(" fuzz binary ......................... ${BUILD_FUZZ_BINARY}")
message("")

View file

@ -243,6 +243,10 @@ if(WIN32)
set_target_properties(bitcoin-qt PROPERTIES WIN32_EXECUTABLE TRUE)
endif()
if(BUILD_GUI_TESTS)
add_subdirectory(test)
endif()
# Gets sources to be parsed to gather translatable strings.
function(get_translatable_sources var)

View file

@ -0,0 +1,56 @@
# Copyright (c) 2024-present The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or https://opensource.org/license/mit/.
add_executable(test_bitcoin-qt
apptests.cpp
optiontests.cpp
rpcnestedtests.cpp
test_main.cpp
uritests.cpp
util.cpp
../../init/bitcoin-qt.cpp
)
target_link_libraries(test_bitcoin-qt
core_interface
bitcoinqt
test_util
bitcoin_node
Boost::headers
Qt5::Test
)
import_plugins(test_bitcoin-qt)
if(ENABLE_WALLET)
target_sources(test_bitcoin-qt
PRIVATE
addressbooktests.cpp
wallettests.cpp
../../wallet/test/wallet_test_fixture.cpp
)
endif()
if(NOT QT_IS_STATIC)
add_custom_command(
TARGET test_bitcoin-qt POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_PROPERTY:Qt5::QMinimalIntegrationPlugin,LOCATION_$<UPPER_CASE:$<CONFIG>>> $<TARGET_FILE_DIR:test_bitcoin-qt>/plugins/platforms
VERBATIM
)
endif()
add_test(NAME test_bitcoin-qt
COMMAND test_bitcoin-qt
)
if(WIN32 AND VCPKG_TARGET_TRIPLET)
# On Windows, vcpkg configures Qt with `-opengl dynamic`, which makes
# the "minimal" platform plugin unusable due to internal Qt bugs.
set_tests_properties(test_bitcoin-qt PROPERTIES
ENVIRONMENT "QT_QPA_PLATFORM=windows"
)
endif()
install(TARGETS test_bitcoin-qt
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)