function buildMethod = getBuildMethod
%getBuildMethod retrieves the 'buildMethod' value from the base workspace
%If 'buildMethod' does not have a value, the function specifies a default
%build method. If the retrieved value is invalid, the function produces an error.

% Copyright 2020 The MathWorks, Inc.

if evalin('base', 'exist(''buildMethod'', ''var'')')
buildMethod = evalin('base', 'buildMethod');

% Propose matching toolchains if buildMethod does not exist
coder.make.internal.resolveToolchainOrTMF(buildMethod);
else
% Throw a graceful error
error(message('coder_compile:CoderCompile:UndefinedBuildMethod'));
end
end