function isInstalled = isToolchainInstalled(tcAlias)
%isToolchainInstalled Returns whether the mex compiler for the toolchain is
%installed

% Copyright 2012-2019 The MathWorks, Inc.

if isempty(tcAlias) || isequal(tcAlias,{'LCC-x'}) || (iscell(tcAlias) && all(cellfun(@isempty, tcAlias)))
    % This is not a factory host toolchain, we cannot reliably check if it
    % is installed or not. Just return true.
    isInstalled = true;
    return;
end

% Check if the selected compiler is supported
tcs = coder.make.internal.getMexCompilerInfo('getInstalledAndSupportedCompilers');
aliases = tcs.ICompStrs;

isInstalled = ~isempty(aliases) && any(ismember(tcAlias, aliases));     
