From 3f348f5cace207038e7b910db89c9be2a767104e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Mon, 5 Jun 2023 20:51:09 +0100 Subject: [PATCH] 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. --- CMakeOptions.txt | 16 +++++++++++++--- packaging/nsis/CMakeLists.txt | 7 +++---- packaging/nsis/wireshark-config.nsh.in | 1 + packaging/nsis/wireshark.nsi | 3 +++ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/CMakeOptions.txt b/CMakeOptions.txt index 664aeea957..e8ab212af3 100644 --- a/CMakeOptions.txt +++ b/CMakeOptions.txt @@ -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() diff --git a/packaging/nsis/CMakeLists.txt b/packaging/nsis/CMakeLists.txt index 0953df178f..ac3f9edff5 100644 --- a/packaging/nsis/CMakeLists.txt +++ b/packaging/nsis/CMakeLists.txt @@ -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} $<$:-DBUNDLE_DEBUG_DLLS> $<$:-DUSE_VCREDIST> - $<$:-DSKIP_UNINSTALLER> wireshark.nsi WORKING_DIRECTORY ${_nsis_source_dir} ) diff --git a/packaging/nsis/wireshark-config.nsh.in b/packaging/nsis/wireshark-config.nsh.in index ace70b9520..713649b10e 100644 --- a/packaging/nsis/wireshark-config.nsh.in +++ b/packaging/nsis/wireshark-config.nsh.in @@ -37,3 +37,4 @@ #cmakedefine QT_DIR "@QT_DIR@" #cmakedefine ENABLE_SIGNED_NSIS +#cmakedefine SKIP_NSIS_QT_DLLS diff --git a/packaging/nsis/wireshark.nsi b/packaging/nsis/wireshark.nsi index 9e2d29b746..9bd677713b 100644 --- a/packaging/nsis/wireshark.nsi +++ b/packaging/nsis/wireshark.nsi @@ -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