fix(cpn): bundle MSVC++ redist with win64 installer (#6603)
Co-authored-by: Peter Feerick <peter.feerick@gmail.com>
This commit is contained in:
co-authored by
Peter Feerick
parent
e6ac5f088a
commit
44fcd35591
@@ -0,0 +1,27 @@
|
|||||||
|
if(WIN32)
|
||||||
|
include(InstallRequiredSystemLibraries)
|
||||||
|
|
||||||
|
# Determine architecture
|
||||||
|
# if(CMAKE_CL_64)
|
||||||
|
set(MSVC_ARCH x64)
|
||||||
|
# else()
|
||||||
|
# set(MSVC_ARCH x86)
|
||||||
|
# endif()
|
||||||
|
|
||||||
|
# Attempt to find the vcredist executable
|
||||||
|
find_program(MSVC_REDIST_EXE
|
||||||
|
NAMES vc_redist.${MSVC_ARCH}.exe
|
||||||
|
PATHS
|
||||||
|
"${MSVC_REDIST_DIR}" # If set by InstallRequiredSystemLibraries
|
||||||
|
"$ENV{VCINSTALLDIR}Redist/MSVC/v143/" # For VS 2022
|
||||||
|
"C:/Program Files (x86)/Microsoft Visual Studio/*/VC/Redist/MSVC/*/"
|
||||||
|
"C:/Program Files/Microsoft Visual Studio/*/*/VC/Redist/MSVC/*/"
|
||||||
|
NO_DEFAULT_PATH
|
||||||
|
)
|
||||||
|
|
||||||
|
if(MSVC_REDIST_EXE)
|
||||||
|
message(STATUS "Found VC Redistributable: ${MSVC_REDIST_EXE}")
|
||||||
|
else()
|
||||||
|
message(WARNING "VC Redistributable not found.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
@@ -407,6 +407,13 @@ elseif(WIN32)
|
|||||||
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include(FindMSVCRedist)
|
||||||
|
|
||||||
|
if(MSVC_REDIST_EXE)
|
||||||
|
install(FILES ${MSVC_REDIST_EXE}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
elseif(APPLE)
|
elseif(APPLE)
|
||||||
# Qt + Cmake + Mac is poorly documented. A lot of this is guesswork
|
# Qt + Cmake + Mac is poorly documented. A lot of this is guesswork
|
||||||
# and trial and error. Do not hesitate to fix it for the better
|
# and trial and error. Do not hesitate to fix it for the better
|
||||||
@@ -514,6 +521,7 @@ if(WIN32)
|
|||||||
|
|
||||||
cmake_path(NATIVE_PATH CMAKE_INSTALL_PREFIX NORMALIZE NSIS_DISTRO) # all files in here will be included in installer
|
cmake_path(NATIVE_PATH CMAKE_INSTALL_PREFIX NORMALIZE NSIS_DISTRO) # all files in here will be included in installer
|
||||||
cmake_path(NATIVE_PATH COMPANION_TARGETS_DIR NORMALIZE NSIS_TARGETS_DIR) # all files in here will be included in installer
|
cmake_path(NATIVE_PATH COMPANION_TARGETS_DIR NORMALIZE NSIS_TARGETS_DIR) # all files in here will be included in installer
|
||||||
|
cmake_path(GET MSVC_REDIST_EXE FILENAME NSIS_MSVC_REDIST_EXE)
|
||||||
set(NSI_FILE "${PROJECT_BINARY_DIR}/companion/companion.nsi")
|
set(NSI_FILE "${PROJECT_BINARY_DIR}/companion/companion.nsi")
|
||||||
configure_file("${COMPANION_TARGETS_DIR}/companion.nsi.in" "${NSI_FILE}" @ONLY)
|
configure_file("${COMPANION_TARGETS_DIR}/companion.nsi.in" "${NSI_FILE}" @ONLY)
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -7,8 +7,10 @@
|
|||||||
|
|
||||||
!include "MUI2.nsh"
|
!include "MUI2.nsh"
|
||||||
!include "nsDialogs.nsh"
|
!include "nsDialogs.nsh"
|
||||||
|
!include "LogicLib.nsh"
|
||||||
!include "@NSIS_TARGETS_DIR@\FileAssociation.nsh"
|
!include "@NSIS_TARGETS_DIR@\FileAssociation.nsh"
|
||||||
|
!include "@NSIS_TARGETS_DIR@\FileFunc.nsh"
|
||||||
|
!include "@NSIS_TARGETS_DIR@\WordFunc.nsh"
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
;General
|
;General
|
||||||
|
|
||||||
@@ -23,6 +25,7 @@
|
|||||||
InstallDirRegKey HKCU "Software\@PROJECT_NAME@\Companion @VERSION_FAMILY@" ""
|
InstallDirRegKey HKCU "Software\@PROJECT_NAME@\Companion @VERSION_FAMILY@" ""
|
||||||
|
|
||||||
;Compressor options
|
;Compressor options
|
||||||
|
;SetCompress off
|
||||||
SetCompressor /FINAL /SOLID lzma
|
SetCompressor /FINAL /SOLID lzma
|
||||||
SetCompressorDictSize 64
|
SetCompressorDictSize 64
|
||||||
|
|
||||||
@@ -102,7 +105,75 @@
|
|||||||
;--------------------------------
|
;--------------------------------
|
||||||
;Installer Sections
|
;Installer Sections
|
||||||
|
|
||||||
Section "@PROJECT_NAME@ Companion @VERSION_FAMILY@" SecDummy
|
; Visual C++ Redistributable (x64) is a required dependency
|
||||||
|
;
|
||||||
|
|
||||||
|
!macro GetInstalledVCVersionCall _RESULT
|
||||||
|
Call GetInstalledVCVersion
|
||||||
|
Pop ${_RESULT}
|
||||||
|
!macroend
|
||||||
|
|
||||||
|
!macro GetInstalledVCVersion
|
||||||
|
!ifndef GetInstalledVCVersion
|
||||||
|
!define GetInstalledVCVersion `!insertmacro GetInstalledVCVersionCall`
|
||||||
|
|
||||||
|
Function GetInstalledVCVersion
|
||||||
|
ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64" "Version"
|
||||||
|
StrCpy $R1 "$R0" 1 # get first character
|
||||||
|
${If} $R1 == "v"
|
||||||
|
StrCpy $R1 "$R0" "" 1 # strip off v prefix
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
Push $R1
|
||||||
|
FunctionEnd
|
||||||
|
!endif
|
||||||
|
!macroend
|
||||||
|
|
||||||
|
!define VCREDISTNAME "Microsoft Visual C++ 2015-2022 Redistributable"
|
||||||
|
!define VCREDISTFILE "@NSIS_DISTRO@\bin\@NSIS_MSVC_REDIST_EXE@"
|
||||||
|
!define VCREDISTEXE "@NSIS_MSVC_REDIST_EXE@"
|
||||||
|
Var VCRedistExeVers
|
||||||
|
Var VCInstVers
|
||||||
|
|
||||||
|
!insertmacro GetFileVersion
|
||||||
|
!insertmacro VersionCompare
|
||||||
|
!insertmacro GetInstalledVCVersion
|
||||||
|
|
||||||
|
Section "${VCREDISTNAME}" SecMSVC
|
||||||
|
Push $0
|
||||||
|
Push $1
|
||||||
|
SetOutPath "$TEMP"
|
||||||
|
File "${VCREDISTFILE}"
|
||||||
|
${GetFileVersion} "$TEMP\${VCREDISTEXE}" $VCRedistExeVers
|
||||||
|
${GetInstalledVCVersion} $VCInstVers
|
||||||
|
${VersionCompare} "$VCInstVers" "$VCRedistExeVers" $R0
|
||||||
|
DetailPrint "VC++ Installed: $VCInstVers Redist: $VCRedistExeVers Result: $R0"
|
||||||
|
${If} $R0 == "2"
|
||||||
|
DetailPrint "Installing ${VCREDISTNAME}..."
|
||||||
|
ExecWait "$TEMP\${VCREDISTEXE} /install /passive /norestart"
|
||||||
|
;IfErrors InstallError ContinueInstall ; vc_redist exit code is unreliable
|
||||||
|
${GetInstalledVCVersion} $VCInstVers
|
||||||
|
${VersionCompare} "$VCInstVers" "$VCRedistExeVers" $R0
|
||||||
|
${If} $R0 == "0"
|
||||||
|
Goto ContinueInstall
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
MessageBox MB_ICONSTOP "\
|
||||||
|
There was an unexpected error installing$\r$\n\
|
||||||
|
${VCREDISTNAME}.$\r$\n\
|
||||||
|
The installation of @PROJECT_NAME@ cannot continue."
|
||||||
|
Abort
|
||||||
|
${EndIf}
|
||||||
|
|
||||||
|
ContinueInstall:
|
||||||
|
Delete "$TEMP\${VCREDISTEXE}"
|
||||||
|
SetOutPath "$INSTDIR" ; Restore original output path
|
||||||
|
Pop $1
|
||||||
|
Pop $0
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
|
Section "@PROJECT_NAME@ Companion @VERSION_FAMILY@" SecCpn
|
||||||
|
|
||||||
SetOutPath "$INSTDIR"
|
SetOutPath "$INSTDIR"
|
||||||
|
|
||||||
@@ -147,8 +218,11 @@ SectionEnd
|
|||||||
;Descriptions
|
;Descriptions
|
||||||
|
|
||||||
;Language strings
|
;Language strings
|
||||||
LangString DESC_SecDummy ${LANG_ENGLISH} "Models and settings editor for @PROJECT_NAME@"
|
LangString DESC_SecCpn ${LANG_ENGLISH} "Models and settings editor for @PROJECT_NAME@"
|
||||||
LangString DESC_SecDummy ${LANG_FRENCH} "Editeur de r�glages et mod�les pour @PROJECT_NAME@"
|
LangString DESC_SecCpn ${LANG_FRENCH} "Editeur de r glages et mod les pour @PROJECT_NAME@"
|
||||||
|
LangString DESC_SecMSVC ${LANG_ENGLISH} "Install or update runtime library support files necessary for Companion"
|
||||||
|
LangString DESC_SecMSVC ${LANG_FRENCH} "Fichiers de support de bibliothèque d'exécution nécessaires pour Companion"
|
||||||
|
|
||||||
LangString SML_SubTitle ${LANG_ENGLISH} "Choose a location for the Start Menu shortcuts"
|
LangString SML_SubTitle ${LANG_ENGLISH} "Choose a location for the Start Menu shortcuts"
|
||||||
LangString SML_SubTitle ${LANG_FRENCH} "Choisissez un emplacement pour les raccourcis de l'application"
|
LangString SML_SubTitle ${LANG_FRENCH} "Choisissez un emplacement pour les raccourcis de l'application"
|
||||||
LangString SML_MainLabel ${LANG_ENGLISH} "Create start menu shortcuts for:"
|
LangString SML_MainLabel ${LANG_ENGLISH} "Create start menu shortcuts for:"
|
||||||
@@ -160,12 +234,17 @@ SectionEnd
|
|||||||
|
|
||||||
;Assign language strings to sections
|
;Assign language strings to sections
|
||||||
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
|
||||||
!insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy)
|
!insertmacro MUI_DESCRIPTION_TEXT ${SecCpn} $(DESC_SecCpn)
|
||||||
|
!insertmacro MUI_DESCRIPTION_TEXT ${SecMSVC} $(DESC_SecMSVC)
|
||||||
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
!insertmacro MUI_FUNCTION_DESCRIPTION_END
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
;Uninstaller Section
|
;Uninstaller Section
|
||||||
|
|
||||||
|
Section "un.${VCREDISTNAME}"
|
||||||
|
|
||||||
|
SectionEnd
|
||||||
|
|
||||||
Section "un.@PROJECT_NAME@ Companion @VERSION_FAMILY@"
|
Section "un.@PROJECT_NAME@ Companion @VERSION_FAMILY@"
|
||||||
|
|
||||||
SectionIn RO ; Not deselectable
|
SectionIn RO ; Not deselectable
|
||||||
|
|||||||
Reference in New Issue
Block a user