Skip to content

Commit 7dfa116

Browse files
committed
MDEV-27446 Windows, MSI - fix redistributable merge module path for VS2022
1 parent 8265d6d commit 7dfa116

File tree

1 file changed

+13
-30
lines changed

1 file changed

+13
-30
lines changed

win/packaging/CMakeLists.txt

Lines changed: 13 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -176,40 +176,23 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio")
176176
SET(CONFIG_PARAM "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_CFG_INTDIR}")
177177
ENDIF()
178178

179-
IF(MSVC_CRT_TYPE MATCHES "/MD")
179+
IF(MSVC_CRT_TYPE MATCHES "/MD" AND (NOT VCRedist_MSM))
180180
# Find out CRT merge module path, we're going to use it in installer
181-
# The path and name depends on VS version
182-
IF(MSVC_VERSION LESS 1900)
183-
# VS2015
184-
SET(VCREDIST_MSM_FILENAME Microsoft_VC140_CRT_${WIX_ARCH_SUFFIX}.msm)
185-
SET(ProgramFilesX86 "ProgramFiles(x86)")
186-
FIND_FILE(${VCREDIST_MSM_FILENAME}
187-
NO_DEFAULT_PATH
188-
PATHS
189-
"$ENV{${ProgramFilesX86}}/Common Files/Merge Modules"
190-
"$ENV{ProgramFiles}/Common Files/Merge Modules"
191-
)
192-
ELSEIF(MSVC_VERSION LESS 1920)
193-
# VS2017
194-
SET(VCREDIST_MSM_FILENAME Microsoft_VC141_CRT_${WIX_ARCH_SUFFIX}.msm)
195-
FILE(GLOB MSM_LIST "C:/Program Files*/Microsoft Visual Studio/2017/*/VC/Redist/MSVC/*/MergeModules/${VCREDIST_MSM_FILENAME}")
196-
LIST(LENGTH MSM_LIST LEN)
197-
IF(LEN GREATER 0)
198-
LIST(GET MSM_LIST 0 VCRedist_MSM)
199-
ENDIF()
200-
ELSE()
201-
# VS2019
202-
SET(VCREDIST_MSM_FILENAME Microsoft_VC142_CRT_${WIX_ARCH_SUFFIX}.msm)
203-
FILE(GLOB MSM_LIST "C:/Program Files*/Microsoft Visual Studio/2019/*/VC/Redist/MSVC/*/MergeModules/${VCREDIST_MSM_FILENAME}")
204-
LIST(LENGTH MSM_LIST LEN)
205-
IF(LEN GREATER 0)
206-
LIST(GET MSM_LIST 0 VCRedist_MSM)
207-
ENDIF()
181+
182+
# merge module file name depends on MSVC version.
183+
MATH(EXPR VC_CRT_VER "(${MSVC_VERSION} - 1900)/10 + 140")
184+
SET(VCREDIST_MSM_FILENAME Microsoft_VC${VC_CRT_VER}_CRT_${WIX_ARCH_SUFFIX}.msm)
185+
186+
FILE(GLOB MSM_LIST "C:/Program Files*/Microsoft Visual Studio/*/*/VC/Redist/MSVC/*/MergeModules/${VCREDIST_MSM_FILENAME}")
187+
LIST(LENGTH MSM_LIST LEN)
188+
IF(LEN GREATER 0)
189+
LIST(GET MSM_LIST 0 VCRedist_MSM_Location)
208190
ENDIF()
209-
IF (NOT VCRedist_MSM)
191+
IF (NOT VCRedist_MSM_Location)
210192
MESSAGE(WARNING "Can't find merge module ${VCREDIST_MSM_FILENAME}")
211193
ELSE()
212-
FILE(TO_NATIVE_PATH ${VCRedist_MSM} VCRedist_MSM)
194+
FILE(TO_NATIVE_PATH ${VCRedist_MSM_Location} VCRedist_MSM_Location)
195+
SET(VCRedist_MSM "${VCRedist_MSM_Location}" CACHE INTERNAL "Location of redistributable merge module")
213196
# MESSAGE("VCRedist_MSM=${VCRedist_MSM}")
214197
ENDIF()
215198
ENDIF()

0 commit comments

Comments
 (0)