function lIsCMake = buildMethodIsCMake(lBuildMethod)
%BUILDMETHODISCMAKE checks if the BuildMethod is CMake and issues a warning
% if it conflicts with a registered toolchain

% Copyright 2020 The MathWorks, Inc.

% Convert any string input to char
lBuildMethod = convertStringsToChars(lBuildMethod);

lIsCMake = ischar(lBuildMethod) && strcmpi(lBuildMethod, 'cmake');

if lIsCMake
lToolchainInfo = [];
lTMFProperties = [];
try
% Get updated TMF properties and the Toolchain info, if available;
[lToolchainInfo, lTMFProperties] = coder.make.internal.resolveToolchainOrTMF(lBuildMethod);
catch
% An exception is thrown if there are no matching toolchains in
% the registry
end
% Template Makefiles use the extension .tmf and do not conflict with CMake
% Issue a warning if the toolchain's name conflicts with CMake
if ~isempty(lToolchainInfo) && isempty(lTMFProperties) &&...
strcmpi(lToolchainInfo.Name, 'cmake')
msg = message('coder_compile:CoderCompile:ToolchainConflictsCMake', ...
lToolchainInfo.Name);
warning(msg.Identifier, '%s', string(msg));
end
end