Skip to content

Commit d61a847

Browse files
committed
Merge bitcoin#32019: cmake: Check for makensis and zip tools before using them for optional deploy targets
1f9b2e1 cmake: Require `zip` only for `deploy` target (Hennadii Stepanov) 0aeff29 cmake: Check for `makensis` tool before using it (Hennadii Stepanov) Pull request description: For `x86_64-w64-mingw32` and `*-apple-darwin` targets, the optional `deploy` target requires dedicated tools: `makensis` and `zip`, respectively. This PR introduces a uniform checks for those tools when attempting to build the `deploy` target, ensuring they are not required for configuring and building any other targets. Here is an example of workflow for `x86_64-w64-mingw32`: ``` $ # `nsis` is not installed $ cmake -B build -G "GNU Makefiles" --toolchain depends/x86_64-w64-mingw32/toolchain.cmake $ cmake --build build -j $(nproc) $ cmake --build build -t deploy Error: NSIS not found. Please install NSIS and/or ensure that its executable is accessible to the find_program() command— for example, by setting the MAKENSIS_EXECUTABLE variable or another relevant CMake variable. Then re-run cmake to regenerate the build system. Built target deploy $ sudo apt install nsis $ cmake -B build $ cmake --build build -t deploy ... [100%] Generating bitcoin-win64-setup.exe [100%] Built target deploy ``` Fixes bitcoin#32018. ACKs for top commit: hodlinator: re-ACK 1f9b2e1 fanquake: ACK 1f9b2e1 Tree-SHA512: 5e2bd28a13bd8fa7c4ba8cf1756d200a4651afe83c463d76ece10027cca343e124eff97012a5368028f761df60f420ab891106b4e33b50045051d57c7464ff98
2 parents 14fec63 + 1f9b2e1 commit d61a847

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

cmake/module/Maintenance.cmake

+25-11
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ endfunction()
4444

4545
function(add_windows_deploy_target)
4646
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)
47+
find_program(MAKENSIS_EXECUTABLE makensis)
48+
if(NOT MAKENSIS_EXECUTABLE)
49+
add_custom_target(deploy
50+
COMMAND ${CMAKE_COMMAND} -E echo "Error: NSIS not found"
51+
)
52+
return()
53+
endif()
54+
4755
# TODO: Consider replacing this code with the CPack NSIS Generator.
4856
# See https://cmake.org/cmake/help/latest/cpack_gen/nsis.html
4957
include(GenerateSetupNsi)
@@ -58,7 +66,7 @@ function(add_windows_deploy_target)
5866
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:bitcoin-wallet> -o ${PROJECT_BINARY_DIR}/release/$<TARGET_FILE_NAME:bitcoin-wallet>
5967
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:bitcoin-util> -o ${PROJECT_BINARY_DIR}/release/$<TARGET_FILE_NAME:bitcoin-util>
6068
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:test_bitcoin> -o ${PROJECT_BINARY_DIR}/release/$<TARGET_FILE_NAME:test_bitcoin>
61-
COMMAND makensis -V2 ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.nsi
69+
COMMAND ${MAKENSIS_EXECUTABLE} -V2 ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.nsi
6270
VERBATIM
6371
)
6472
add_custom_target(deploy DEPENDS ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.exe)
@@ -112,16 +120,22 @@ function(add_macos_deploy_target)
112120
DEPENDS ${PROJECT_BINARY_DIR}/dist/${macos_app}/Contents/MacOS/Bitcoin-Qt
113121
)
114122

115-
find_program(ZIP_COMMAND zip REQUIRED)
116-
add_custom_command(
117-
OUTPUT ${PROJECT_BINARY_DIR}/dist/${osx_volname}.zip
118-
WORKING_DIRECTORY dist
119-
COMMAND ${PROJECT_SOURCE_DIR}/cmake/script/macos_zip.sh ${ZIP_COMMAND} ${osx_volname}.zip
120-
VERBATIM
121-
)
122-
add_custom_target(deploy
123-
DEPENDS ${PROJECT_BINARY_DIR}/dist/${osx_volname}.zip
124-
)
123+
find_program(ZIP_EXECUTABLE zip)
124+
if(NOT ZIP_EXECUTABLE)
125+
add_custom_target(deploy
126+
COMMAND ${CMAKE_COMMAND} -E echo "Error: ZIP not found"
127+
)
128+
else()
129+
add_custom_command(
130+
OUTPUT ${PROJECT_BINARY_DIR}/dist/${osx_volname}.zip
131+
WORKING_DIRECTORY dist
132+
COMMAND ${PROJECT_SOURCE_DIR}/cmake/script/macos_zip.sh ${ZIP_EXECUTABLE} ${osx_volname}.zip
133+
VERBATIM
134+
)
135+
add_custom_target(deploy
136+
DEPENDS ${PROJECT_BINARY_DIR}/dist/${osx_volname}.zip
137+
)
138+
endif()
125139
endif()
126140
add_dependencies(deploydir bitcoin-qt)
127141
add_dependencies(deploy deploydir)

doc/build-osx.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ brew install python
141141
#### Deploy Dependencies
142142

143143
You can [deploy](#3-deploy-optional) a `.zip` containing the Bitcoin Core application.
144-
It is required that you have `python` installed.
144+
It is required that you have `python` and `zip` installed.
145145

146146
## Building Bitcoin Core
147147

0 commit comments

Comments
 (0)