CMake: Update some options

Try to autodetect ENABLE_SIGNED_NSIS and enable it if
sign-wireshark.bat is detected on the path.

Instead of skipping the whole Qt deployment, including things like
translations, just skip the DLLs in the manifest. This is useful
if the target machine has Qt installed and the static DLL list
for cross-compiling is not adequate.
This commit is contained in:
João Valverde 2023-06-05 20:51:09 +01:00
parent 9cbc6377eb
commit 3f348f5cac
4 changed files with 20 additions and 7 deletions

View File

@ -148,9 +148,19 @@ if(APPLE)
endif()
if(WIN32)
# Enable signing of NSIS installer by default only if we have 'sign-wireshark.bat' on the path
# of the host system.
set(_enable_signed_nsis False)
if(CMAKE_HOST_WIN32)
find_file(SIGN_WIRESHARK_BAT "sign-wireshark.bat")
if (SIGN_WIRESHARK_BAT)
set(_enable_signed_nsis True)
endif()
endif()
option(ENABLE_SIGNED_NSIS "Enable the code signing step of the NSIS installer build" ${_enable_signed_nsis})
# Advanced options for developers to work-around limitations in the build
# when cross-compiling to Windows.
option(SKIP_NSIS_QT_DEPLOYMENT "Skip deploying Qt runtime with installer" OFF)
mark_as_advanced(SKIP_NSIS_QT_DEPLOYMENT)
option(ENABLE_SIGNED_NSIS "Enable the code signing step of the NSIS installer build" OFF)
option(SKIP_NSIS_QT_DLLS "Skip deploying Qt runtime DLLs with installer" OFF)
mark_as_advanced(SKIP_NSIS_QT_DLLS)
endif()

View File

@ -14,7 +14,7 @@ set(WIRESHARK_NSIS_GENERATED_FILES
${CMAKE_CURRENT_BINARY_DIR}/wireshark-manifest.nsh
${CMAKE_CURRENT_BINARY_DIR}/wireshark-config.nsh
)
if(NOT SKIP_NSIS_QT_DEPLOYMENT)
if(NOT SKIP_NSIS_QT_DLLS)
list(APPEND WIRESHARK_NSIS_GENERATED_FILES ${CMAKE_CURRENT_BINARY_DIR}/wireshark-qt-manifest.nsh)
endif()
set(WIRESHARK_NSIS_GENERATED_FILES ${WIRESHARK_NSIS_GENERATED_FILES} PARENT_SCOPE)
@ -65,7 +65,7 @@ set (MMDBRESOLVE_EXE ${MAXMINDDB_FOUND})
set (PRODUCT_VERSION ${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_PATCH_VERSION}.${PROJECT_BUILD_VERSION})
set (LOG_PRODUCT_VERSION ${LOG_PROJECT_MAJOR_VERSION}.${LOG_PROJECT_MINOR_VERSION}.${PROJECT_PATCH_VERSION}.${PROJECT_BUILD_VERSION})
if((BUILD_wireshark OR BUILD_logray) AND QT_FOUND AND NOT SKIP_NSIS_QT_DEPLOYMENT)
if((BUILD_wireshark OR BUILD_logray) AND QT_FOUND)
set (QT_DIR "\${STAGING_DIR}")
endif()
@ -277,7 +277,7 @@ macro( ADD_NSIS_PACKAGE_TARGETS )
# command-line-only installer packages.
if(BUILD_wireshark)
# wireshark-qt-manifest.nsh. Created using Wireshark.exe.
if(NOT SKIP_NSIS_QT_DEPLOYMENT)
if(NOT SKIP_NSIS_QT_DLLS)
if (USE_REPOSITORY)
add_custom_command(OUTPUT ${_nsis_binary_dir}/wireshark-qt-manifest.nsh
COMMAND set "PATH=${QT_BIN_PATH};%PATH%"
@ -335,7 +335,6 @@ macro( ADD_NSIS_PACKAGE_TARGETS )
COMMAND ${MAKENSIS_EXECUTABLE} ${NSIS_OPTIONS}
$<$<CONFIG:Debug>:-DBUNDLE_DEBUG_DLLS>
$<$<BOOL:${MSVC}>:-DUSE_VCREDIST>
$<$<BOOL:${SKIP_NSIS_UNINSTALLER}>:-DSKIP_UNINSTALLER>
wireshark.nsi
WORKING_DIRECTORY ${_nsis_source_dir}
)

View File

@ -37,3 +37,4 @@
#cmakedefine QT_DIR "@QT_DIR@"
#cmakedefine ENABLE_SIGNED_NSIS
#cmakedefine SKIP_NSIS_QT_DLLS

View File

@ -1005,7 +1005,10 @@ File "${QT_DIR}\${PROGRAM_NAME_PATH}"
; Write an entry for ShellExecute
WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\App Paths\${PROGRAM_NAME_PATH}" "" '$INSTDIR\${PROGRAM_NAME_PATH}'
WriteRegStr HKEY_LOCAL_MACHINE "Software\Microsoft\Windows\CurrentVersion\App Paths\${PROGRAM_NAME_PATH}" "Path" '$INSTDIR'
!ifndef SKIP_NSIS_QT_DLLS
!include wireshark-qt-manifest.nsh
!endif
${!defineifexist} TRANSLATIONS_FOLDER "${QT_DIR}\translations"
SetOutPath $INSTDIR