function msvc170SetupFcn(setupFile)
% This function is used by copies of the old msvc toolchain in
% 'toolbox/gpucoder/gpucoder/foundation/build/tools/cuda_win64_tc.m'
% It remains here until these toolchains can be updated to
% use msvcSetupFcn instead, which works for all versions of msvc.

% Microsoft Visual C++ 2022 does not set environment variable
% "VS170COMNTOOLS" like previous versions so we need to set it up to
% call vcvarsall.bat.

% Copyright 2019-2022 The MathWorks, Inc.

comp = coder.make.internal.getMexCompInfoFromKey('Microsoft-17.0');

if isempty(comp)
    error(message('MATLAB:mex:NoCompilerFound_Win64'));
else
    msvc170Mex = comp.comp;
    if regexp(msvc170Mex.Location,'^[\\/]')
        fsep = filesep;
    else
        fsep = '';
    end
    lPath = [msvc170Mex.Location fsep 'Common7\Tools\'];
    contentToWrite = ['set "VS170COMNTOOLS=', lPath, '"' ];
    setupFile = fullfile(pwd, setupFile);
    if coder.make.internal.needToUpdateFile( setupFile, contentToWrite )
        fid = fopen( setupFile, 'w+' );
        fprintf( fid, '%s', contentToWrite);
        fclose( fid );
    end
end
end
