3 # Wireshark - Network traffic analyzer
4 # By Gerald Combs <gerald@wireshark.org>
5 # Copyright 1998 Gerald Combs
7 # SPDX-License-Identifier: GPL-2.0-or-later
10 # We should use CPack to help generate a .msi using WIX.
12 set(WIX_GENERATED_FILES
13 ${CMAKE_CURRENT_BINARY_DIR}/DependentComponents.wxs
14 ${CMAKE_CURRENT_BINARY_DIR}/Diameter.wxs
15 ${CMAKE_CURRENT_BINARY_DIR}/QtDependentComponents.wxs
16 ${CMAKE_CURRENT_BINARY_DIR}/QtTranslation.wxs
17 ${CMAKE_CURRENT_BINARY_DIR}/RadiusDict.wxs
18 ${CMAKE_CURRENT_BINARY_DIR}/SNMPMibs.wxs
19 ${CMAKE_CURRENT_BINARY_DIR}/UsersGuide.wxs
21 set(WIX_GENERATED_FILES ${WIX_GENERATED_FILES} PARENT_SCOPE)
24 ${CMAKE_SOURCE_DIR}/packaging/wix/Wireshark.wxs
25 ${CMAKE_SOURCE_DIR}/packaging/wix/WiresharkOptionsDlg.wxs
26 ${CMAKE_SOURCE_DIR}/packaging/wix/WiresharkWixUI.wxs
27 ${WIX_GENERATED_FILES}
29 set(WIX_SOURCE_FILES ${WIX_SOURCE_FILES} PARENT_SCOPE)
34 DirectoryStructure.wxi
45 ${CMAKE_CURRENT_BINARY_DIR}/DependentComponents.wixobj
46 ${CMAKE_CURRENT_BINARY_DIR}/Diameter.wixobj
47 ${CMAKE_CURRENT_BINARY_DIR}/QtDependentComponents.wixobj
48 ${CMAKE_CURRENT_BINARY_DIR}/QtTranslation.wixobj
49 ${CMAKE_CURRENT_BINARY_DIR}/RadiusDict.wixobj
50 ${CMAKE_CURRENT_BINARY_DIR}/SNMPMibs.wixobj
51 ${CMAKE_CURRENT_BINARY_DIR}/UsersGuide.wixobj
52 ${CMAKE_CURRENT_BINARY_DIR}/Wireshark.wixobj
53 ${CMAKE_CURRENT_BINARY_DIR}/WiresharkOptionsDlg.wixobj
54 ${CMAKE_CURRENT_BINARY_DIR}/WiresharkWixUI.wixobj
56 set(WIX_OUT_FILES ${WIX_OUT_FILES} PARENT_SCOPE)
58 # Variables required for Wireshark.wxs
59 set(PROGRAM_NAME ${CMAKE_PROJECT_NAME})
60 file(TO_NATIVE_PATH "${CMAKE_SOURCE_DIR}" TOP_SRC_DIR)
61 # STAGING_DIR depends on the build configuration so we pass it
62 # on the command line below.
63 file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/doc" DOC_DIR)
66 # - Sync the various version names between CMake and Wix.
67 # - Set CMakeLists.txt version strings in tools/make-version.py
68 # - Add a VERSION_EXTRA cmake option
69 set (VERSION "${PROJECT_VERSION}")
70 set(PRODUCT_VERSION ${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_PATCH_VERSION}.${PROJECT_BUILD_VERSION})
72 # Use the merge module that comes with our version of Visual Studio
73 if(MSVC_VERSION GREATER_EQUAL 1930)
74 set (MSVC_CRT_VERSION "VC143")
75 elseif(MSVC_VERSION GREATER_EQUAL 1920)
76 set (MSVC_CRT_VERSION "VC142")
77 elseif(MSVC_VERSION GREATER_EQUAL 1910)
78 set (MSVC_CRT_VERSION "VC141")
79 elseif(MSVC_VERSION GREATER_EQUAL 1900)
80 set (MSVC_CRT_VERSION "VC140")
83 # Starting with Visual Studio 2019 merge modules are deprecated but
84 # are available as an individual component.
85 # https://docs.microsoft.com/en-us/visualstudio/releases/2019/release-notes#-deprecations
86 set(MERGE_MODULE "Microsoft_${MSVC_CRT_VERSION}_CRT_${WIRESHARK_TARGET_PLATFORM}.msm")
87 set (PF86_ENV "ProgramFiles(x86)")
89 set(VC_TOOLS_MERGE_MODULES_DIR)
90 if (DEFINED ENV{VCToolsRedistDir})
91 set(VC_TOOLS_MERGE_MODULES_DIR "$ENV{VCToolsRedistDir}/MergeModules")
94 find_path(MERGE_MODULE_DIR ${MERGE_MODULE}
96 #"$ENV{VCINSTALLDIR}/VC/Redist/MSVC/how-do-we-get-this-version/Merge Modules"
97 ${VC_TOOLS_MERGE_MODULES_DIR}
98 "$ENV{${PF86_ENV}}/Common Files/Merge Modules"
99 "$ENV{PROGRAMFILES}/Common Files/Merge Modules"
102 file(TO_NATIVE_PATH "${MERGE_MODULE_DIR}/Microsoft_${MSVC_CRT_VERSION}_CRT_${WIRESHARK_TARGET_PLATFORM}.msm" MSM_NATIVE_PATH)
103 message(STATUS "Using ${MSM_NATIVE_PATH} for the WiX installer")
105 # DependentComponents.wxi. Can be created at configure time.
106 set(_all_manifest_wix "${CMAKE_CURRENT_BINARY_DIR}/DependentComponents.wxs")
107 file(WRITE "${_all_manifest_wix}" "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n")
108 file(APPEND "${_all_manifest_wix}" "<Wix xmlns=\"http://schemas.microsoft.com/wix/2006/wi\">\n\n")
109 file(APPEND "${_all_manifest_wix}" " <!-- Files required for all sections. Generated by CMake. -->\n")
110 file(APPEND "${_all_manifest_wix}" "<?include InputPaths.wxi ?>\n")
111 file(APPEND "${_all_manifest_wix}" " <Fragment>\n")
112 file(APPEND "${_all_manifest_wix}" " <DirectoryRef Id=\"INSTALLFOLDER\">\n")
113 file(APPEND "${_all_manifest_wix}" " <?ifdef BUNDLE_DEBUG_DLLS ?>\n")
114 foreach(_dll ${GLIB2_DLLS_DEBUG})
115 STRING(REGEX REPLACE "[-|\\.]" "_" _wix_name ${_dll})
116 file(APPEND "${_all_manifest_wix}" " <Component Id=\"cmp${_wix_name}\" Guid=\"*\">\n")
117 file(APPEND "${_all_manifest_wix}" " <File Id=\"fil${_wix_name}\" KeyPath=\"yes\" Source=\"$(var.Staging.Dir)\\${_dll}\"/>\n")
118 file(APPEND "${_all_manifest_wix}" " </Component>\n")
120 file(APPEND "${_all_manifest_wix}" " <?else?>\n")
121 foreach(_dll ${GLIB2_DLLS_RELEASE})
122 STRING(REGEX REPLACE "[-|\\.]" "_" _wix_name ${_dll})
123 file(APPEND "${_all_manifest_wix}" " <Component Id=\"cmp${_wix_name}\" Guid=\"*\">\n")
124 file(APPEND "${_all_manifest_wix}" " <File Id=\"fil${_wix_name}\" KeyPath=\"yes\" Source=\"$(var.Staging.Dir)\\${_dll}\"/>\n")
125 file(APPEND "${_all_manifest_wix}" " </Component>\n")
127 file(APPEND "${_all_manifest_wix}" " <?endif?>\n")
128 SET(unique_component "")
129 set (_dll_list ${AMRNB_DLL} ${CARES_DLL} ${PCRE2_RELEASE_DLL} ${GCRYPT_DLLS}
130 ${GNUTLS_DLLS} ${KERBEROS_DLLS} ${LIBSSH_DLLS} ${LUA_DLL}
131 ${LZ4_DLL} ${MINIZIP_DLL} ${MINIZIPNG_DLLS} ${NGHTTP2_DLL} ${NGHTTP3_DLL} ${SBC_DLL} ${SMI_DLL}
132 ${SNAPPY_DLL} ${SPANDSP_DLL} ${BCG729_DLL} ${LIBXML2_DLLS} ${WINSPARKLE_DLL}
133 ${ZLIB_DLL} ${ZLIBNG_DLL} ${BROTLI_DLLS} ${ZSTD_DLL} ${ILBC_DLL} ${OPUS_DLL}
135 # Required for mmdbresolve
138 foreach(_dll ${_dll_list})
139 #ensure uniqueness of files
140 IF(NOT "${unique_component}" MATCHES "(^|;)${_dll}(;|$)")
141 STRING(REGEX REPLACE "[-|\\.]" "_" _wix_name ${_dll})
142 file(APPEND "${_all_manifest_wix}" " <Component Id=\"cmp${_wix_name}\" Guid=\"*\">\n")
143 file(APPEND "${_all_manifest_wix}" " <File Id=\"fil${_wix_name}\" KeyPath=\"yes\" Source=\"$(var.Staging.Dir)\\${_dll}\"/>\n")
144 file(APPEND "${_all_manifest_wix}" " </Component>\n")
145 SET(unique_component ${unique_component} ${_dll})
146 ENDIF(NOT "${unique_component}" MATCHES "(^|;)${_dll}(;|$)")
148 file(APPEND "${_all_manifest_wix}" " </DirectoryRef>\n")
149 file(APPEND "${_all_manifest_wix}" " </Fragment>\n")
150 file(APPEND "${_all_manifest_wix}" " <Fragment>\n")
151 file(APPEND "${_all_manifest_wix}" " <ComponentGroup Id=\"CG.RequiredDependencies\">\n")
152 file(APPEND "${_all_manifest_wix}" " <?ifdef BUNDLE_DEBUG_DLLS ?>\n")
153 foreach(_dll ${GLIB2_DLLS_DEBUG})
154 STRING(REGEX REPLACE "[-|\\.]" "_" _wix_name ${_dll})
155 file(APPEND "${_all_manifest_wix}" " <ComponentRef Id=\"cmp${_wix_name}\" />\n")
157 file(APPEND "${_all_manifest_wix}" " <?else?>\n")
158 foreach(_dll ${GLIB2_DLLS_RELEASE})
159 STRING(REGEX REPLACE "[-|\\.]" "_" _wix_name ${_dll})
160 file(APPEND "${_all_manifest_wix}" " <ComponentRef Id=\"cmp${_wix_name}\" />\n")
162 file(APPEND "${_all_manifest_wix}" " <?endif?>\n")
164 foreach(_dll ${_dll_list})
165 #ensure uniqueness of files
166 IF(NOT "${unique_file}" MATCHES "(^|;)${_dll}(;|$)")
167 STRING(REGEX REPLACE "[-|\\.]" "_" _wix_name ${_dll})
168 file(APPEND "${_all_manifest_wix}" " <ComponentRef Id=\"cmp${_wix_name}\" />\n")
169 SET(unique_file ${unique_file} ${_dll})
170 ENDIF(NOT "${unique_file}" MATCHES "(^|;)${_dll}(;|$)")
172 file(APPEND "${_all_manifest_wix}" " </ComponentGroup>\n")
173 file(APPEND "${_all_manifest_wix}" " </Fragment>\n")
174 file(APPEND "${_all_manifest_wix}" "\n</Wix>\n")
177 set(d_smi_dir "-dSMI_DIR")
181 set(d_mmdbresolve_exe "-dMMDBRESOLVE_EXE")
184 set(WIX_CANDLE_DEFINES
187 -dPlatform=${WIRESHARK_TARGET_PLATFORM}
188 -dWiresharkName=${CMAKE_PROJECT_NAME}
189 -dWiresharkVersion=${PRODUCT_VERSION}
190 -dWiresharkMajorVersion=${PROJECT_MAJOR_VERSION}
191 -dWiresharkMinorVersion=${PROJECT_MINOR_VERSION}
192 -dAssetDir=${CMAKE_SOURCE_DIR}/packaging/wix
193 -dBuildOutputDir=${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}
194 -dDiameterDir=${ARCHIVE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/diameter
195 -dIconDir=${CMAKE_SOURCE_DIR}/resources/icons
196 -dQtTranslationDir=${ARCHIVE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/translations
197 -dRadiusDictDir=${ARCHIVE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/radius
198 -dSnmpMibDir=${ARCHIVE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/snmp/mibs
199 -dUsersGuideDir=${ARCHIVE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/doc/wsug_html_chunked
200 -dVCRedistVersion=${MSVC_CRT_VERSION}
201 -dVCRedistDir=${MERGE_MODULE_DIR}
204 -arch ${WIRESHARK_TARGET_PLATFORM}
206 -I${CMAKE_SOURCE_DIR}/packaging/wix
207 -out ${CMAKE_CURRENT_BINARY_DIR}/
211 # The NSIS CMakeFile sets the program name + version slightly differently.
212 set(WIX_LIGHT_DEFINES
214 -out ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}-${WIRESHARK_TARGET_PLATFORM}.msi
217 -loc ${CMAKE_CURRENT_SOURCE_DIR}/StringOverrides.wxl
230 macro( ADD_WIX_PACKAGE_TARGET )
232 # XXX - if we're not building Wireshark, we can't build
233 # QtDependentComponents.wxs.. On the other hand, if we're
234 # not building Wireshark, we have no need to include Qt
235 # in the installer, so it's not clear we need that file.
237 # This should probably be fixed, so that people can produce
238 # command-line-only installer packages.
240 set (_wix_source_dir ${CMAKE_SOURCE_DIR}/packaging/wix )
241 set (_wix_binary_dir ${CMAKE_BINARY_DIR}/packaging/wix )
243 # QtDependentComponents.wxs. Created using Wireshark.exe.
244 add_custom_command(OUTPUT ${_wix_binary_dir}/QtDependentComponents.wxs
245 COMMAND set "PATH=${QT_BIN_PATH};%PATH%"
246 COMMAND ${POWERSHELL_COMMAND} "${_wix_source_dir}/windeployqt-to-wix.ps1"
247 -Executable $<TARGET_FILE:wireshark>
248 -FilePath ${_wix_binary_dir}/QtDependentComponents.wxs
249 DEPENDS "${_wix_source_dir}/windeployqt-to-wix.ps1"
252 # UsersGuide.wxs. Collects the contents of wsug_html_chunked.
253 # Generated with heat.exe
254 add_custom_command(OUTPUT ${_wix_binary_dir}/UsersGuide.wxs
255 COMMAND ${WIX_HEAT_EXECUTABLE} dir ${CMAKE_BINARY_DIR}/doc/wsug_html_chunked
256 ${WIX_HEAT_FLAGS} -cg CG.Documentation -dr dirUsersGuide -var var.UsersGuideDir
257 -out ${_wix_binary_dir}/UsersGuide.wxs
260 # SNMPMibs.wxs. Collects all MIBs in "output" snmp/mibs
261 # directory. Generated with heat.exe
262 add_custom_command(OUTPUT ${_wix_binary_dir}/SNMPMibs.wxs
263 COMMAND ${WIX_HEAT_EXECUTABLE} dir ${ARCHIVE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/snmp/mibs
264 ${WIX_HEAT_FLAGS} -cg CG.Plugins.SNMP -dr dirSnmpMibs -var var.SnmpMibDir
265 -out ${_wix_binary_dir}/SNMPMibs.wxs
268 # RadiusDict.wxs. Collects all Radius dictionary files in
269 # "output" radius directory. Generated with heat.exe
270 add_custom_command(OUTPUT ${_wix_binary_dir}/RadiusDict.wxs
271 COMMAND ${WIX_HEAT_EXECUTABLE} dir ${ARCHIVE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/radius
272 ${WIX_HEAT_FLAGS} -cg CG.RadiusDict -dr dirRadius -var var.RadiusDictDir
273 -out ${_wix_binary_dir}/RadiusDict.wxs
276 # Diameter.wxs. Collects all Diameter XML dictionary files
277 # in "output" diameter directory. Generated with heat.exe
278 add_custom_command(OUTPUT ${_wix_binary_dir}/Diameter.wxs
279 COMMAND ${WIX_HEAT_EXECUTABLE} dir ${ARCHIVE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/diameter
280 ${WIX_HEAT_FLAGS} -cg CG.Diameter -dr dirDiameter -var var.DiameterDir
281 -out ${_wix_binary_dir}/Diameter.wxs
284 # QtTranslation.wxs. Collects all Qt translation files in
285 # "output" translations directory. Generated with heat.exe
286 add_custom_command(OUTPUT ${_wix_binary_dir}/QtTranslation.wxs
287 COMMAND ${WIX_HEAT_EXECUTABLE} dir ${ARCHIVE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/translations
288 ${WIX_HEAT_FLAGS} -cg CG.QtTranslations -dr dirTranslations -var var.QtTranslationDir
289 -out ${_wix_binary_dir}/QtTranslation.wxs
292 # Build WiX package dependencies. We build the package in
293 # two stages so that wireshark_wix below doesn't trigger any
294 # dependencies that might clobber any signed executables.
295 # XXX Rename this to wireshark_wix_prep
296 add_custom_target(wireshark_wix_prep
304 set_target_properties(wireshark_wix_prep PROPERTIES
306 EXCLUDE_FROM_DEFAULT_BUILD True
309 # Dump the installer into
310 # ${CMAKE_CURRENT_SOURCE_DIR}/packaging/wix
311 # Note that executables and DLLs *must* be built separately
312 # XXX Rename this to wireshark_wix
313 add_custom_target(wireshark_wix
314 COMMAND ${WIX_CANDLE_EXECUTABLE} ${WIX_CANDLE_DEFINES}
315 $<$<CONFIG:Debug>:-dBUNDLE_DEBUG_DLLS>
317 WORKING_DIRECTORY ${_wix_source_dir}
319 COMMAND ${WIX_LIGHT_EXECUTABLE} ${WIX_LIGHT_DEFINES} ${WIX_OUT_FILES}
320 WORKING_DIRECTORY ${_wix_binary_dir}
322 set_target_properties(wireshark_wix PROPERTIES
324 EXCLUDE_FROM_DEFAULT_BUILD True
327 message(WARNING "The WiX installer cannot be built if the Wireshark program isn't built.")
329 endmacro( ADD_WIX_PACKAGE_TARGET )
332 DependentComponents.wxs
333 QtDependentComponents.wxs
339 wireshark-${VERSION}-${WIRESHARK_TARGET_PLATFORM}.msi