diff --git a/CMakeLists.txt b/CMakeLists.txt index ec0422d9f2b7b7..a1f12a354befd3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -387,6 +387,7 @@ include(cmake/tests.cmake) include(Maintenance) setup_split_debug_script() add_maintenance_targets() +add_windows_deploy_target() get_target_property(definitions core_interface INTERFACE_COMPILE_DEFINITIONS) separate_by_configs(definitions) diff --git a/cmake/module/AddWindowsResources.cmake b/cmake/module/AddWindowsResources.cmake new file mode 100644 index 00000000000000..a9b4f51f73d96c --- /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/cmake/module/GenerateSetupNsi.cmake b/cmake/module/GenerateSetupNsi.cmake new file mode 100644 index 00000000000000..7c7457e3609bf1 --- /dev/null +++ b/cmake/module/GenerateSetupNsi.cmake @@ -0,0 +1,22 @@ +# 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/. + +function(generate_setup_nsi) + set(abs_top_srcdir ${PROJECT_SOURCE_DIR}) + set(abs_top_builddir ${PROJECT_BINARY_DIR}) + set(PACKAGE_VERSION ${PROJECT_VERSION}) + set(CLIENT_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) + set(CLIENT_VERSION_MINOR ${PROJECT_VERSION_MINOR}) + set(CLIENT_VERSION_BUILD ${PROJECT_VERSION_PATCH}) + set(PACKAGE_URL ${PROJECT_HOMEPAGE_URL}) + set(PACKAGE_TARNAME "bitcoin") + set(BITCOIN_GUI_NAME "bitcoin-qt") + set(BITCOIN_DAEMON_NAME "bitcoind") + set(BITCOIN_CLI_NAME "bitcoin-cli") + set(BITCOIN_TX_NAME "bitcoin-tx") + set(BITCOIN_WALLET_TOOL_NAME "bitcoin-wallet") + set(BITCOIN_TEST_NAME "test_bitcoin") + set(EXEEXT ${CMAKE_EXECUTABLE_SUFFIX}) + configure_file(${PROJECT_SOURCE_DIR}/share/setup.nsi.in ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.nsi @ONLY) +endfunction() diff --git a/cmake/module/Maintenance.cmake b/cmake/module/Maintenance.cmake index 9abf4990768c16..9bef503f3a7278 100644 --- a/cmake/module/Maintenance.cmake +++ b/cmake/module/Maintenance.cmake @@ -72,3 +72,26 @@ function(add_maintenance_targets) add_custom_target(check-security) endif() endfunction() + +function(add_windows_deploy_target) + if(MINGW AND TARGET bitcoin-qt AND TARGET bitcoind AND TARGET bitcoin-cli AND TARGET bitcoin-tx AND TARGET bitcoin-wallet AND TARGET bitcoin-util AND TARGET test_bitcoin) + # TODO: Consider replacing this code with the CPack NSIS Generator. + # See https://cmake.org/cmake/help/latest/cpack_gen/nsis.html + include(GenerateSetupNsi) + generate_setup_nsi() + add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/bitcoin-win64-setup.exe + COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/release + COMMAND ${CMAKE_STRIP} $ -o ${CMAKE_BINARY_DIR}/release/$ + COMMAND ${CMAKE_STRIP} $ -o ${CMAKE_BINARY_DIR}/release/$ + COMMAND ${CMAKE_STRIP} $ -o ${CMAKE_BINARY_DIR}/release/$ + COMMAND ${CMAKE_STRIP} $ -o ${CMAKE_BINARY_DIR}/release/$ + COMMAND ${CMAKE_STRIP} $ -o ${CMAKE_BINARY_DIR}/release/$ + COMMAND ${CMAKE_STRIP} $ -o ${CMAKE_BINARY_DIR}/release/$ + COMMAND ${CMAKE_STRIP} $ -o ${CMAKE_BINARY_DIR}/release/$ + COMMAND makensis -V2 ${CMAKE_BINARY_DIR}/bitcoin-win64-setup.nsi + VERBATIM + ) + add_custom_target(deploy DEPENDS ${CMAKE_BINARY_DIR}/bitcoin-win64-setup.exe) + endif() +endfunction() diff --git a/contrib/guix/guix-build b/contrib/guix/guix-build index 5010b63a6012bc..d8cfb367c720cc 100755 --- a/contrib/guix/guix-build +++ b/contrib/guix/guix-build @@ -74,11 +74,12 @@ mkdir -p "$VERSION_BASE" ################ # Default to building for all supported HOSTs (overridable by environment) -# TODO: Re-enable Windows and macOS hosts. +# TODO: Re-enable macOS hosts. # export HOSTS="${HOSTS:-x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv64-linux-gnu powerpc64-linux-gnu powerpc64le-linux-gnu # x86_64-w64-mingw32 # x86_64-apple-darwin arm64-apple-darwin}" -export HOSTS="${HOSTS:-x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv64-linux-gnu powerpc64-linux-gnu powerpc64le-linux-gnu}" +export HOSTS="${HOSTS:-x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv64-linux-gnu powerpc64-linux-gnu powerpc64le-linux-gnu + x86_64-w64-mingw32}" # Usage: distsrc_for_host HOST # diff --git a/contrib/guix/libexec/build.sh b/contrib/guix/libexec/build.sh index e86bcb34969204..0db04c1aa5edfd 100755 --- a/contrib/guix/libexec/build.sh +++ b/contrib/guix/libexec/build.sh @@ -272,7 +272,8 @@ mkdir -p "$DISTSRC" # Make the os-specific installers case "$HOST" in *mingw*) - make deploy ${V:+V=1} BITCOIN_WIN_INSTALLER="${OUTDIR}/${DISTNAME}-win64-setup-unsigned.exe" + cmake --build build -j "$JOBS" -t deploy ${V:+--verbose} + mv build/bitcoin-win64-setup.exe "${OUTDIR}/${DISTNAME}-win64-setup-unsigned.exe" ;; esac @@ -316,7 +317,8 @@ mkdir -p "$DISTSRC" case "$HOST" in *mingw*) - mv --target-directory="$DISTNAME"/lib/ "$DISTNAME"/bin/*.dll + # TODO: Re-enable code for libbitcoinkernel. + # mv --target-directory="$DISTNAME"/lib/ "$DISTNAME"/bin/*.dll ;; esac @@ -388,7 +390,7 @@ mkdir -p "$DISTSRC" case "$HOST" in *mingw*) - cp -rf --target-directory=. contrib/windeploy + cp -rf --target-directory=. "${DISTSRC}/contrib/windeploy" ( cd ./windeploy mkdir -p unsigned diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a30d6b27e0d3c2..a50c0f8439ac52 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,6 +3,7 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. include(GNUInstallDirs) +include(AddWindowsResources) configure_file(${CMAKE_SOURCE_DIR}/cmake/bitcoin-config.h.in config/bitcoin-config.h @ONLY) add_compile_definitions(HAVE_CONFIG_H) @@ -141,6 +142,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 @@ -270,6 +272,7 @@ if(BUILD_DAEMON) bitcoind.cpp init/bitcoind.cpp ) + add_windows_resources(bitcoind bitcoind-res.rc) target_link_libraries(bitcoind core_interface bitcoin_node @@ -293,6 +296,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 @@ -306,6 +310,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 @@ -318,6 +323,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 8af0a65ccc158f..1a8370cfefd4fa 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -156,6 +156,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