diff --git a/packaging/nsis/CMakeLists.txt b/packaging/nsis/CMakeLists.txt index 7d9eda0fae..0d727ffbe6 100644 --- a/packaging/nsis/CMakeLists.txt +++ b/packaging/nsis/CMakeLists.txt @@ -81,8 +81,6 @@ endif() # 1912 = VS2017 15.5 / 14.12 # 1913 = VS2017 15.6 / 14.13 # 1914 = VS2017 15.7 / 14.14 -set(_vcredist_dot_name "vc_redist.${TARGET_MACHINE}.exe") # Visual Studio 2022 and later -set(_vcredist_underscore_name "vcredist_${TARGET_MACHINE}.exe") # Visual Studio 2019 and earlier if(MSVC_VERSION GREATER_EQUAL 1930) set(_ws_vcredist_subdir "vcredist_MSVC2022") elseif(MSVC_VERSION GREATER_EQUAL 1920) @@ -118,14 +116,19 @@ if(MSVC_VERSION GREATER_EQUAL 1910 AND VCINSTALLDIR) "${VCINSTALLDIR}/Redist/MSVC/14.*.*") endif() -find_program(VCREDIST_EXE NAMES "${_vcredist_dot_name}" "${_vcredist_underscore_name}" +find_program(_vcredist + NAMES + "vc_redist.${TARGET_MACHINE}.exe" # Visual Studio 2022 and later + "vcredist_${TARGET_MACHINE}.exe" # Visual Studio 2019 and earlier PATHS "${_PROJECT_LIB_DIR}" $ENV{VCToolsRedistDir} "${VCINSTALLDIR}" PATH_SUFFIXES ${_ws_vcredist_subdir} ${_ms_vcredist_subdir} NO_DEFAULT_PATH ) -if(VCREDIST_EXE) - file(TO_NATIVE_PATH "${VCREDIST_EXE}" VCREDIST_EXE) - message(STATUS "Using ${VCREDIST_EXE} for the NSIS installer.") +if(_vcredist) + file(TO_NATIVE_PATH "${_vcredist}" _vcredist) + message(STATUS "Using ${_vcredist} for the NSIS installer.") + get_filename_component(VCREDIST_DIR ${_vcredist} DIRECTORY) + get_filename_component(VCREDIST_EXE ${_vcredist} NAME) endif() # Ideally we would generate this at compile time using a separate cmake diff --git a/packaging/nsis/config.nsh.in b/packaging/nsis/config.nsh.in index c20ff93471..704eb02c49 100644 --- a/packaging/nsis/config.nsh.in +++ b/packaging/nsis/config.nsh.in @@ -17,6 +17,7 @@ #define VERSION_MINOR @VERSION_MINOR@ #define PRODUCT_VERSION @PRODUCT_VERSION@ +#define VCREDIST_DIR "@VCREDIST_DIR@" #define VCREDIST_EXE "@VCREDIST_EXE@" # Optional components diff --git a/packaging/nsis/wireshark.nsi b/packaging/nsis/wireshark.nsi index 4f1ff2531b..f27c8d519a 100644 --- a/packaging/nsis/wireshark.nsi +++ b/packaging/nsis/wireshark.nsi @@ -535,16 +535,16 @@ File "${STAGING_DIR}\extcap.html" File "${STAGING_DIR}\ipmap.html" ; C-runtime redistributable -; vcredist_x64.exe or vc_redist_x86.exe - copy and execute the redistributable installer -File "${VCREDIST_EXE}" +; vc_redist.x64.exe or vc_redist.x86.exe - copy and execute the redistributable installer +File "${VCREDIST_DIR}\${VCREDIST_EXE}" ; If the user already has the redistributable installed they will see a ; Big Ugly Dialog by default, asking if they want to uninstall or repair. ; Ideally we should add a checkbox for this somewhere. In the meantime, ; just do a "quiet" install. ; http://asawicki.info/news_1597_installing_visual_c_redistributable_package_from_command_line.html -ExecWait '"$INSTDIR\vcredist_${TARGET_MACHINE}.exe" /install /quiet /norestart' $0 -DetailPrint "vcredist_${TARGET_MACHINE} returned $0" +ExecWait '"$INSTDIR\${VCREDIST_EXE}" /install /quiet /norestart' $0 +DetailPrint "${VCREDIST_EXE} returned $0" ; https://docs.microsoft.com/en-us/windows/desktop/Msi/error-codes !define ERROR_SUCCESS 0 @@ -565,7 +565,7 @@ ${Switch} $0 ${Break} ${EndSwitch} -Delete "$INSTDIR\vcredist_${TARGET_MACHINE}.exe" +Delete "$INSTDIR\${VCREDIST_EXE}" ; global config files - don't overwrite if already existing