sq epan/dissectors/packet-dcerpc-netlogon.c
[wireshark-sm.git] / packaging / wix / CMakeLists.txt
blob8c9f93764b9bbe1e1625e526b1639e66434e063f
1 # CMakeLists.txt
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)
23 set(WIX_SOURCE_FILES
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)
31 set(WIX_FILES
32         ComponentGroups.wxi
33         COPYING.rtf
34         DirectoryStructure.wxi
35         Features.wxi
36         InputPaths.wxi
37         Plugins.wxi
38         Prerequisites.wxi
39         UserInterface.wxi
40         ${WIX_SOURCE_FILES}
41         PARENT_SCOPE
44 set(WIX_OUT_FILES
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)
65 # To do:
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")
81 endif()
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")
92 endif()
94 find_path(MERGE_MODULE_DIR ${MERGE_MODULE}
95         PATHS
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"
100         NO_DEFAULT_PATH
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")
119 endforeach()
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")
126 endforeach()
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}
134         ${SPEEXDSP_DLL}
135         # Required for mmdbresolve
136         ${MAXMINDDB_DLL}
137         )
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}(;|$)")
147 endforeach()
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")
156 endforeach()
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")
161 endforeach()
162 file(APPEND "${_all_manifest_wix}" "      <?endif?>\n")
163 SET(unique_file "")
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}(;|$)")
171 endforeach()
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")
176 if(SMI_DIR)
177         set(d_smi_dir "-dSMI_DIR")
178 endif()
180 if (MAXMINDDB_FOUND)
181         set(d_mmdbresolve_exe "-dMMDBRESOLVE_EXE")
182 endif()
184 set(WIX_CANDLE_DEFINES
185         -v
186         -sw1076
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}
202         ${d_smi_dir}
203         ${d_mmdbresolve_exe}
204         -arch ${WIRESHARK_TARGET_PLATFORM}
205         -ext WixUIExtension
206         -I${CMAKE_SOURCE_DIR}/packaging/wix
207         -out ${CMAKE_CURRENT_BINARY_DIR}/
208         PARENT_SCOPE
211 # The NSIS CMakeFile sets the program name + version slightly differently.
212 set(WIX_LIGHT_DEFINES
213         -v
214         -out ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}-${WIRESHARK_TARGET_PLATFORM}.msi
215         -sw1076
216         -ext WixUIExtension
217         -loc ${CMAKE_CURRENT_SOURCE_DIR}/StringOverrides.wxl
218         PARENT_SCOPE
221 set(WIX_HEAT_FLAGS
222         -v
223         -ag
224         -nologo
225         -srd
226         -sreg
227         PARENT_SCOPE
230 macro( ADD_WIX_PACKAGE_TARGET )
231         #
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.
236         #
237         # This should probably be fixed, so that people can produce
238         # command-line-only installer packages.
239         if(BUILD_wireshark)
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"
250                 )
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
258                 )
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
266                 )
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
274                 )
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
282                 )
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
290                 )
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
297                         DEPENDS
298                                 ${WIX_FILES}
299                                 copy_data_files
300                                 user_guide_html
301                                 release_notes_html
302                 )
303                 set_target_properties(wireshark_wix_prep PROPERTIES
304                         FOLDER "Packaging"
305                         EXCLUDE_FROM_DEFAULT_BUILD True
306                 )
308                 # Dump the installer into
309                 # ${CMAKE_CURRENT_SOURCE_DIR}/packaging/wix
310                 # Note that executables and DLLs *must* be built separately
311                 # XXX Rename this to wireshark_wix
312                 add_custom_target(wireshark_wix
313                         COMMAND ${WIX_CANDLE_EXECUTABLE} ${WIX_CANDLE_DEFINES}
314                                 $<$<CONFIG:Debug>:-dBUNDLE_DEBUG_DLLS>
315                                 ${WIX_SOURCE_FILES}
316                         WORKING_DIRECTORY ${_wix_source_dir}
318                         COMMAND ${WIX_LIGHT_EXECUTABLE} ${WIX_LIGHT_DEFINES} ${WIX_OUT_FILES}
319                         WORKING_DIRECTORY ${_wix_binary_dir}
320                 )
321                 set_target_properties(wireshark_wix PROPERTIES
322                         FOLDER "Packaging"
323                         EXCLUDE_FROM_DEFAULT_BUILD True
324                 )
325         else()
326                 message(WARNING "The WiX installer cannot be built if the Wireshark program isn't built.")
327         endif()
328 endmacro( ADD_WIX_PACKAGE_TARGET )
330 set(CLEAN_FILES
331         DependentComponents.wxs
332         QtDependentComponents.wxs
333         UsersGuide.wxs
334         SNMPMibs.wxs
335         RadiusDict.wxs
336         Diameter.wxs
337         QtTranslation.wxs
338         wireshark-${VERSION}-${WIRESHARK_TARGET_PLATFORM}.msi