function setBuildItemProperty(h,propName,varargin)
%

%   Copyright 2014-2018 The MathWorks, Inc.

narginchk( 3, 4 );
propName = convertStringsToChars(propName);
[varargin{:}] = convertStringsToChars(varargin{:});

if nargin==3
    if isa( varargin{ 1 }, 'coder.make.BuildItem' )
        % setBuildItemProperty(PROP, OBJ)
        propObj = varargin{ 1 };
        propObj.setValue( h.verifyBuildItemValue( propName, propObj.getValue() ) );
        h.(propName) = propObj;
    else
        % setBuildItemProperty(PROP, VALUE)
        propValue = varargin{ 1 };
        h.(propName).setValue( h.verifyBuildItemValue( propName, propValue ) );
    end
else
    % setBuildItemProperty(PROP, MACRO, VALUE)
    propMacro = varargin{ 1 };
    propValue = varargin{ 2 };
    h.(propName) = coder.make.BuildItem( propMacro, h.verifyBuildItemValue( propName, propValue ) );
end
end
