cmake: Check for makensis tool before using it

This commit is contained in:
Hennadii Stepanov 2025-03-10 14:57:14 +00:00
parent 4637cb1eec
commit f52377bc8d
No known key found for this signature in database
GPG key ID: 410108112E7EA81F

View file

@ -44,6 +44,20 @@ endfunction()
function(add_windows_deploy_target) 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) 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)
find_program(MAKENSIS_EXECUTABLE makensis)
if(NOT MAKENSIS_EXECUTABLE)
add_custom_target(deploy
COMMAND ${CMAKE_COMMAND} -E echo
COMMAND ${CMAKE_COMMAND} -E echo "Error: NSIS not found."
COMMAND ${CMAKE_COMMAND} -E echo "Please install NSIS and/or ensure that its executable is accessible to the find_program() command"
COMMAND ${CMAKE_COMMAND} -E echo "for example, by setting the MAKENSIS_EXECUTABLE variable or another relevant CMake variable."
COMMAND ${CMAKE_COMMAND} -E echo "Then re-run cmake to regenerate the build system."
COMMAND ${CMAKE_COMMAND} -E echo
VERBATIM
)
return()
endif()
# TODO: Consider replacing this code with the CPack NSIS Generator. # TODO: Consider replacing this code with the CPack NSIS Generator.
# See https://cmake.org/cmake/help/latest/cpack_gen/nsis.html # See https://cmake.org/cmake/help/latest/cpack_gen/nsis.html
include(GenerateSetupNsi) include(GenerateSetupNsi)
@ -58,7 +72,7 @@ function(add_windows_deploy_target)
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:bitcoin-wallet> -o ${PROJECT_BINARY_DIR}/release/$<TARGET_FILE_NAME:bitcoin-wallet> COMMAND ${CMAKE_STRIP} $<TARGET_FILE:bitcoin-wallet> -o ${PROJECT_BINARY_DIR}/release/$<TARGET_FILE_NAME:bitcoin-wallet>
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:bitcoin-util> -o ${PROJECT_BINARY_DIR}/release/$<TARGET_FILE_NAME:bitcoin-util> COMMAND ${CMAKE_STRIP} $<TARGET_FILE:bitcoin-util> -o ${PROJECT_BINARY_DIR}/release/$<TARGET_FILE_NAME:bitcoin-util>
COMMAND ${CMAKE_STRIP} $<TARGET_FILE:test_bitcoin> -o ${PROJECT_BINARY_DIR}/release/$<TARGET_FILE_NAME:test_bitcoin> COMMAND ${CMAKE_STRIP} $<TARGET_FILE:test_bitcoin> -o ${PROJECT_BINARY_DIR}/release/$<TARGET_FILE_NAME:test_bitcoin>
COMMAND makensis -V2 ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.nsi COMMAND ${MAKENSIS_EXECUTABLE} -V2 ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.nsi
VERBATIM VERBATIM
) )
add_custom_target(deploy DEPENDS ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.exe) add_custom_target(deploy DEPENDS ${PROJECT_BINARY_DIR}/bitcoin-win64-setup.exe)