From 29ac5a9e61edcde7d7f517be3b9734bf29ad8dc9 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 16 Feb 2019 13:25:02 -0800 Subject: [PATCH] Don't fail in CMake on Windows if you've disabled building Wireshark. It's possible to do a *build* on Windows without the Wireshark app being built; however, the *installers* can't currently be built. If we have NSIS or WiX, and Wireshark isn't being built, report a warning, and don't have targets for building the installers. Change-Id: I2cc9c1f6ba375dbcb6d5b7520d2fa33ad97ba9fe Reviewed-on: https://code.wireshark.org/review/32061 Petri-Dish: Guy Harris Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris --- packaging/nsis/CMakeLists.txt | 100 +++++++++++++----------- packaging/wix/CMakeLists.txt | 140 ++++++++++++++++++---------------- 2 files changed, 127 insertions(+), 113 deletions(-) diff --git a/packaging/nsis/CMakeLists.txt b/packaging/nsis/CMakeLists.txt index 47bf0dc093..3d06369abc 100644 --- a/packaging/nsis/CMakeLists.txt +++ b/packaging/nsis/CMakeLists.txt @@ -171,63 +171,71 @@ set(NSIS_OPTIONS # installers. This means that uninstall.exe must be built separately AND # that building the installer itself won't overwrite uninstall.exe macro( ADD_NSIS_UNINSTALLER_TARGET ) - set (_nsis_source_dir ${CMAKE_SOURCE_DIR}/packaging/nsis ) - set (_nsis_binary_dir ${CMAKE_BINARY_DIR}/packaging/nsis ) + # + # XXX - if we're not building Wireshark, we can't build + # anything, so there's nothing to uninstall. + # + if(BUILD_wireshark) + set (_nsis_source_dir ${CMAKE_SOURCE_DIR}/packaging/nsis ) + set (_nsis_binary_dir ${CMAKE_BINARY_DIR}/packaging/nsis ) - add_custom_command(OUTPUT ${DATAFILE_DIR}/uninstall.exe - DEPENDS ${_nsis_source_dir}/uninstall.nsi - ${_nsis_source_dir}/common.nsh - COMMAND ${MAKENSIS_EXECUTABLE} ${NSIS_OPTIONS} - uninstall.nsi - COMMAND ${DATAFILE_DIR}/uninstall_installer.exe - COMMAND ${CMAKE_COMMAND} -E remove ${DATAFILE_DIR}/uninstall_installer.exe - WORKING_DIRECTORY ${_nsis_source_dir} - ) + add_custom_command(OUTPUT ${DATAFILE_DIR}/uninstall.exe + DEPENDS ${_nsis_source_dir}/uninstall.nsi + ${_nsis_source_dir}/common.nsh + COMMAND ${MAKENSIS_EXECUTABLE} ${NSIS_OPTIONS} + uninstall.nsi + COMMAND ${DATAFILE_DIR}/uninstall_installer.exe + COMMAND ${CMAKE_COMMAND} -E remove ${DATAFILE_DIR}/uninstall_installer.exe + WORKING_DIRECTORY ${_nsis_source_dir} + ) + else() + message(WARNING "The NSIS installer cannot be built if the Wireshark program isn't built.") + endif() endmacro( ADD_NSIS_UNINSTALLER_TARGET ) macro( ADD_NSIS_PACKAGE_TARGET ) - #set (_nsis_package ${CMAKE_BINARY_DIR}/packaging/nsis/Wireshark-$(WIRESHARK_TARGET_PLATFORM)-$(VERSION).exe) - - # qt-dll-manifest.nsh. Created using Wireshark.exe. # - # XXX - if we're not building Wireshark, we can't build this - # manifest. On the other hand, if we're not building + # XXX - if we're not building Wireshark, we can't build the + # manifest below. On the other hand, if we're not building # Wireshark, we have no need to include Qt in the installer, # so it's not clear we need this manifest. # # This should probably be fixed, so that people can produce # command-line-only installer packages. - if(NOT BUILD_wireshark) - message(FATAL_ERROR "The NSIS installer cannot be built if the Wireshark program isn't built.") + if(BUILD_wireshark) + #set (_nsis_package ${CMAKE_BINARY_DIR}/packaging/nsis/Wireshark-$(WIRESHARK_TARGET_PLATFORM)-$(VERSION).exe) + + # qt-dll-manifest.nsh. Created using Wireshark.exe. + add_custom_command(OUTPUT ${_nsis_binary_dir}/qt-dll-manifest.nsh + COMMAND set "PATH=${QT_BIN_PATH};%PATH%" + COMMAND ${POWERSHELL_COMMAND} "${_nsis_source_dir}/windeployqt-to-nsis.ps1" + -Executable $ + -FilePath ${_nsis_binary_dir}/qt-dll-manifest.nsh + ) + + # Build NSIS package dependencies. We build the package in + # two stages so that nsis_package below doesn't trigger + # any dependencies that might clobber any signed executables. + add_custom_target(nsis_package_prep + DEPENDS + ${NSIS_FILES} + copy_data_files + user_guide_chm + faq_html + ${DATAFILE_DIR}/uninstall.exe + ) + set_target_properties(nsis_package_prep PROPERTIES FOLDER "Packaging") + + # Dump the installer into + # ${CMAKE_CURRENT_SOURCE_DIR}/packaging/nsis + # Note that executables and DLLs *must* be built separately + add_custom_target(nsis_package + COMMAND ${MAKENSIS_EXECUTABLE} ${NSIS_OPTIONS} + wireshark.nsi + WORKING_DIRECTORY ${_nsis_source_dir} + ) + set_target_properties(nsis_package PROPERTIES FOLDER "Packaging") endif() - add_custom_command(OUTPUT ${_nsis_binary_dir}/qt-dll-manifest.nsh - COMMAND set "PATH=${QT_BIN_PATH};%PATH%" - COMMAND ${POWERSHELL_COMMAND} "${_nsis_source_dir}/windeployqt-to-nsis.ps1" - -Executable $ - -FilePath ${_nsis_binary_dir}/qt-dll-manifest.nsh - ) - - # Build NSIS package dependencies. We build the package in two stages - # so that nsis_package below doesn't trigger any dependencies that - # might clobber any signed executables. - add_custom_target(nsis_package_prep - DEPENDS - ${NSIS_FILES} - copy_data_files - user_guide_chm - faq_html - ${DATAFILE_DIR}/uninstall.exe - ) - set_target_properties(nsis_package_prep PROPERTIES FOLDER "Packaging") - - # Dump the installer into ${CMAKE_CURRENT_SOURCE_DIR}/packaging/nsis - # Note that executables and DLLs *must* be built separately - add_custom_target(nsis_package - COMMAND ${MAKENSIS_EXECUTABLE} ${NSIS_OPTIONS} - wireshark.nsi - WORKING_DIRECTORY ${_nsis_source_dir} - ) - set_target_properties(nsis_package PROPERTIES FOLDER "Packaging") endmacro( ADD_NSIS_PACKAGE_TARGET ) set(CLEAN_FILES diff --git a/packaging/wix/CMakeLists.txt b/packaging/wix/CMakeLists.txt index d1db7c2bdf..dd360e87ad 100644 --- a/packaging/wix/CMakeLists.txt +++ b/packaging/wix/CMakeLists.txt @@ -217,78 +217,84 @@ set(WIX_HEAT_FLAGS ) macro( ADD_WIX_PACKAGE_TARGET ) - set (_wix_source_dir ${CMAKE_SOURCE_DIR}/packaging/wix ) - set (_wix_binary_dir ${CMAKE_BINARY_DIR}/packaging/wix ) - - # QtDependentComponents.wxs. Created using Wireshark.exe. # - # XXX - if we're not building Wireshark, we can't build this - # manifest. On the other hand, if we're not building - # Wireshark, we have no need to include Qt in the installer, - # so it's not clear we need this manifest. + # XXX - if we're not building Wireshark, we can't build + # QtDependentComponents.wxs.. On the other hand, if we're + # not building Wireshark, we have no need to include Qt + # in the installer, so it's not clear we need that file. # # This should probably be fixed, so that people can produce # command-line-only installer packages. - if(NOT BUILD_wireshark) - message(FATAL_ERROR "The WiX installer cannot be built if the Wireshark program isn't built.") + if(BUILD_wireshark) + set (_wix_source_dir ${CMAKE_SOURCE_DIR}/packaging/wix ) + set (_wix_binary_dir ${CMAKE_BINARY_DIR}/packaging/wix ) + + # QtDependentComponents.wxs. Created using Wireshark.exe. + add_custom_command(OUTPUT ${_wix_binary_dir}/QtDependentComponents.wxs + COMMAND set "PATH=${QT_BIN_PATH};%PATH%" + COMMAND ${POWERSHELL_COMMAND} "${_wix_source_dir}/windeployqt-to-wix.ps1" + -Executable $ + -FilePath ${_wix_binary_dir}/QtDependentComponents.wxs + ) + + # SNMPMibs.wxs. Collects all MIBs in "output" snmp/mibs + # directory. Generated with heat.exe + add_custom_command(OUTPUT ${_wix_binary_dir}/SNMPMibs.wxs + COMMAND ${WIX_HEAT_EXECUTABLE} dir ${ARCHIVE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/snmp/mibs + ${WIX_HEAT_FLAGS} -cg CG.Plugins.SNMP -dr dirSnmpMibs -var var.SnmpMibDir + -out ${_wix_binary_dir}/SNMPMibs.wxs + ) + + # RadiusDict.wxs. Collects all Radius dictionary files in + # "output" radius directory. Generated with heat.exe + add_custom_command(OUTPUT ${_wix_binary_dir}/RadiusDict.wxs + COMMAND ${WIX_HEAT_EXECUTABLE} dir ${ARCHIVE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/radius + ${WIX_HEAT_FLAGS} -cg CG.RadiusDict -dr dirRadius -var var.RadiusDictDir + -out ${_wix_binary_dir}/RadiusDict.wxs + ) + + # Diameter.wxs. Collects all Diameter XML dictionary files + # in "output" diameter directory. Generated with heat.exe + add_custom_command(OUTPUT ${_wix_binary_dir}/Diameter.wxs + COMMAND ${WIX_HEAT_EXECUTABLE} dir ${ARCHIVE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/diameter + ${WIX_HEAT_FLAGS} -cg CG.Diameter -dr dirDiameter -var var.DiameterDir + -out ${_wix_binary_dir}/Diameter.wxs + ) + + # QtTranslation.wxs. Collects all Qt translation files in + # "output" translations directory. Generated with heat.exe + add_custom_command(OUTPUT ${_wix_binary_dir}/QtTranslation.wxs + COMMAND ${WIX_HEAT_EXECUTABLE} dir ${ARCHIVE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/translations + ${WIX_HEAT_FLAGS} -cg CG.QtTranslations -dr dirTranslations -var var.QtTranslationDir + -out ${_wix_binary_dir}/QtTranslation.wxs + ) + + # Build WiX package dependencies. We build the package in + # two stages so that wix_package below doesn't trigger any + # dependencies that might clobber any signed executables. + add_custom_target(wix_package_prep + DEPENDS + ${WIX_FILES} + copy_data_files + user_guide_chm + faq_html + ) + set_target_properties(wix_package_prep PROPERTIES FOLDER "Packaging") + + # Dump the installer into + # ${CMAKE_CURRENT_SOURCE_DIR}/packaging/wix + # Note that executables and DLLs *must* be built separately + add_custom_target(wix_package + COMMAND ${WIX_CANDLE_EXECUTABLE} ${WIX_CANDLE_DEFINES} ${WIX_SOURCE_FILES} + WORKING_DIRECTORY ${_wix_source_dir} + + COMMAND ${WIX_LIGHT_EXECUTABLE} ${WIX_LIGHT_DEFINES} ${WIX_OUT_FILES} + WORKING_DIRECTORY ${_wix_binary_dir} + ) + set_target_properties(wix_package PROPERTIES FOLDER "Packaging") + else() + message(WARNING "The WiX installer cannot be built if the Wireshark program isn't built.") endif() - add_custom_command(OUTPUT ${_wix_binary_dir}/QtDependentComponents.wxs - COMMAND set "PATH=${QT_BIN_PATH};%PATH%" - COMMAND ${POWERSHELL_COMMAND} "${_wix_source_dir}/windeployqt-to-wix.ps1" - -Executable $ - -FilePath ${_wix_binary_dir}/QtDependentComponents.wxs - ) - - # SNMPMibs.wxs. Collects all MIBs in "output" snmp/mibs directory. Generated with heat.exe - add_custom_command(OUTPUT ${_wix_binary_dir}/SNMPMibs.wxs - COMMAND ${WIX_HEAT_EXECUTABLE} dir ${ARCHIVE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/snmp/mibs - ${WIX_HEAT_FLAGS} -cg CG.Plugins.SNMP -dr dirSnmpMibs -var var.SnmpMibDir - -out ${_wix_binary_dir}/SNMPMibs.wxs - ) - - # RadiusDict.wxs. Collects all Radius dictionary files in "output" radius directory. Generated with heat.exe - add_custom_command(OUTPUT ${_wix_binary_dir}/RadiusDict.wxs - COMMAND ${WIX_HEAT_EXECUTABLE} dir ${ARCHIVE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/radius - ${WIX_HEAT_FLAGS} -cg CG.RadiusDict -dr dirRadius -var var.RadiusDictDir - -out ${_wix_binary_dir}/RadiusDict.wxs - ) - - # Diameter.wxs. Collects all Diameter XML dictionary files in "output" diameter directory. Generated with heat.exe - add_custom_command(OUTPUT ${_wix_binary_dir}/Diameter.wxs - COMMAND ${WIX_HEAT_EXECUTABLE} dir ${ARCHIVE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/diameter - ${WIX_HEAT_FLAGS} -cg CG.Diameter -dr dirDiameter -var var.DiameterDir - -out ${_wix_binary_dir}/Diameter.wxs - ) - - # QtTranslation.wxs. Collects all Qt translation files in "output" translations directory. Generated with heat.exe - add_custom_command(OUTPUT ${_wix_binary_dir}/QtTranslation.wxs - COMMAND ${WIX_HEAT_EXECUTABLE} dir ${ARCHIVE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/translations - ${WIX_HEAT_FLAGS} -cg CG.QtTranslations -dr dirTranslations -var var.QtTranslationDir - -out ${_wix_binary_dir}/QtTranslation.wxs - ) - - # Build WiX package dependencies. We build the package in two stages - # so that wix_package below doesn't trigger any dependencies that - # might clobber any signed executables. - add_custom_target(wix_package_prep - DEPENDS - ${WIX_FILES} - copy_data_files - user_guide_chm - faq_html - ) - set_target_properties(wix_package_prep PROPERTIES FOLDER "Packaging") - - # Dump the installer into ${CMAKE_CURRENT_SOURCE_DIR}/packaging/wix - # Note that executables and DLLs *must* be built separately - add_custom_target(wix_package - COMMAND ${WIX_CANDLE_EXECUTABLE} ${WIX_CANDLE_DEFINES} ${WIX_SOURCE_FILES} - WORKING_DIRECTORY ${_wix_source_dir} - - COMMAND ${WIX_LIGHT_EXECUTABLE} ${WIX_LIGHT_DEFINES} ${WIX_OUT_FILES} - WORKING_DIRECTORY ${_wix_binary_dir} - ) - set_target_properties(wix_package PROPERTIES FOLDER "Packaging") endmacro( ADD_WIX_PACKAGE_TARGET ) set(CLEAN_FILES