From 2b43c45b13ad00cfd9928a03da8a480977724cb1 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 27 Jan 2024 12:03:58 +0000 Subject: [PATCH] cmake: Add `AddWindowsResources` module --- cmake/module/AddWindowsResources.cmake | 14 ++++++++++++++ src/CMakeLists.txt | 6 ++++++ src/qt/CMakeLists.txt | 2 ++ 3 files changed, 22 insertions(+) create mode 100644 cmake/module/AddWindowsResources.cmake diff --git a/cmake/module/AddWindowsResources.cmake b/cmake/module/AddWindowsResources.cmake new file mode 100644 index 00000000000..a9b4f51f73d --- /dev/null +++ b/cmake/module/AddWindowsResources.cmake @@ -0,0 +1,14 @@ +# 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/. + +include_guard(GLOBAL) + +macro(add_windows_resources target rc_file) + if(WIN32) + target_sources(${target} PRIVATE ${rc_file}) + set_property(SOURCE ${rc_file} + APPEND PROPERTY COMPILE_DEFINITIONS WINDRES_PREPROC + ) + endif() +endmacro() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4f6c0250862..2877cc51f71 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,6 +3,7 @@ # file COPYING or https://opensource.org/license/mit/. include(GNUInstallDirs) +include(AddWindowsResources) configure_file(${PROJECT_SOURCE_DIR}/cmake/bitcoin-config.h.in config/bitcoin-config.h @ONLY) include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) @@ -172,6 +173,7 @@ if(ENABLE_WALLET) init/bitcoin-wallet.cpp wallet/wallettool.cpp ) + add_windows_resources(bitcoin-wallet bitcoin-wallet-res.rc) target_link_libraries(bitcoin-wallet core_interface bitcoin_wallet @@ -303,6 +305,7 @@ if(BUILD_DAEMON) bitcoind.cpp init/bitcoind.cpp ) + add_windows_resources(bitcoind bitcoind-res.rc) target_link_libraries(bitcoind core_interface bitcoin_node @@ -339,6 +342,7 @@ target_link_libraries(bitcoin_cli # Bitcoin Core RPC client if(BUILD_CLI) add_executable(bitcoin-cli bitcoin-cli.cpp) + add_windows_resources(bitcoin-cli bitcoin-cli-res.rc) target_link_libraries(bitcoin-cli core_interface bitcoin_cli @@ -352,6 +356,7 @@ endif() if(BUILD_TX) add_executable(bitcoin-tx bitcoin-tx.cpp) + add_windows_resources(bitcoin-tx bitcoin-tx-res.rc) target_link_libraries(bitcoin-tx core_interface bitcoin_common @@ -364,6 +369,7 @@ endif() if(BUILD_UTIL) add_executable(bitcoin-util bitcoin-util.cpp) + add_windows_resources(bitcoin-util bitcoin-util-res.rc) target_link_libraries(bitcoin-util core_interface bitcoin_common diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index df51782488a..dc62d0f57e2 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -231,6 +231,8 @@ add_executable(bitcoin-qt ../init/bitcoin-qt.cpp ) +add_windows_resources(bitcoin-qt res/bitcoin-qt-res.rc) + target_link_libraries(bitcoin-qt core_interface bitcoinqt