function configureReferenceModelSettings(hCS)
% CONFIGUREREFERENCEMODELSETTINGS Configure reference model settings

%   Copyright 2023 The MathWorks, Inc.

modelName = get(getModel(hCS), 'Name');
buildDirStruct = RTW.getBuildDir(modelName);
childModelFolder = fullfile(buildDirStruct.CodeGenFolder, buildDirStruct.ModelRefRelativeBuildDir);
if isfile(fullfile(childModelFolder,'peripheralInfo.mat'))
    matfileData = load(fullfile(childModelFolder,'peripheralInfo.mat'));
    isPIL = codertarget.tic2000.internal.isPILCodeGeneration(modelName);
    % Check if the previous reference model build was PIL or normal build.
    % If mismatch throw error with fixit option
    if isfield(matfileData.peripheralInfo, 'isPIL') && ...
            ~isequal(matfileData.peripheralInfo.isPIL, isPIL)
        if isPIL
            mode1 = 'PIL';
            mode2 = 'Build';
        else
            mode2 = 'PIL';
            mode1 = 'Build';
        end
        msg = message('TIC2000:codegen:ModelReferenceRegenerateCode', modelName, mode1, mode2, childModelFolder, [modelName, '.slxc']);
        err = MSLException([], msg);
        throw(err)
    end
end
end