@@ -176,40 +176,23 @@ IF(CMAKE_GENERATOR MATCHES "Visual Studio")
176
176
SET (CONFIG_PARAM "-DCMAKE_INSTALL_CONFIG_NAME=${CMAKE_CFG_INTDIR} " )
177
177
ENDIF ()
178
178
179
- IF (MSVC_CRT_TYPE MATCHES "/MD" )
179
+ IF (MSVC_CRT_TYPE MATCHES "/MD" AND ( NOT VCRedist_MSM ) )
180
180
# 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 )
208
190
ENDIF ()
209
- IF (NOT VCRedist_MSM )
191
+ IF (NOT VCRedist_MSM_Location )
210
192
MESSAGE (WARNING "Can't find merge module ${VCREDIST_MSM_FILENAME} " )
211
193
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" )
213
196
# MESSAGE("VCRedist_MSM=${VCRedist_MSM}")
214
197
ENDIF ()
215
198
ENDIF ()
0 commit comments