Skip to content

Commit

Permalink
fixup! cmake: Add Maintenance module
Browse files Browse the repository at this point in the history
Add `deploy` target for MINGW builds
  • Loading branch information
hebasto committed Feb 1, 2024
1 parent a7955b5 commit 7827bb4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,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)
Expand Down
22 changes: 22 additions & 0 deletions cmake/module/GenerateSetupNsi.cmake
Original file line number Diff line number Diff line change
@@ -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()
23 changes: 23 additions & 0 deletions cmake/module/Maintenance.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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} $<TARGET_FILE:bitcoin-qt> -o ${CMAKE_BINARY_DIR}/release/$<TARGET_FILE_NAME:bitcoin-qt>
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:bitcoind> -o ${CMAKE_BINARY_DIR}/release/$<TARGET_FILE_NAME:bitcoind>
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:bitcoin-cli> -o ${CMAKE_BINARY_DIR}/release/$<TARGET_FILE_NAME:bitcoin-cli>
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:bitcoin-tx> -o ${CMAKE_BINARY_DIR}/release/$<TARGET_FILE_NAME:bitcoin-tx>
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:bitcoin-wallet> -o ${CMAKE_BINARY_DIR}/release/$<TARGET_FILE_NAME:bitcoin-wallet>
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:bitcoin-util> -o ${CMAKE_BINARY_DIR}/release/$<TARGET_FILE_NAME:bitcoin-util>
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:test_bitcoin> -o ${CMAKE_BINARY_DIR}/release/$<TARGET_FILE_NAME:test_bitcoin>
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()

0 comments on commit 7827bb4

Please sign in to comment.