message: Display an error message and help string when the we fail to find compiler paths. [Fix
diff: @@ -24,6 +24,8 @@ export interface CompileFlagInformation {
  standard: StandardVersion;
  }
  +class MissingCompilerException extends Error {}
  +
  interface TargetDefaults {
  includePath: string[];
  compileFlags: string[];
  @@ -118,6 +120,17 @@ export class CppConfigurationProvider implements cpt.CustomConfigurationProvider
  readonly name = 'CMake Tools';
  /** Our extension ID, visible to cpptools */
  readonly extensionId = 'vector-of-bool.cmake-tools';
  + /**
  + * This value determines if we need to show the user an error message about missing compilers. When an update succeeds
  + * without missing any compilers, we set this to `true`, otherwise `false`.
  + *
  + * If an update fails and the value is `true`, we display the message. If an
  + * update fails and the value is `false`, we do not display the message.
  + *
  + * This ensures that we only show the message the first time an update fails
  + * within a sequence of failing updates.
  + */
  + private _lastUpdateSucceeded = true;
  /**
  * Get the SourceFileConfigurationItem from the index for the given URI
  @@ -165,7 +178,7 @@ export class CppConfigurationProvider implements cpt.CustomConfigurationProvider
  // Try to get the path to the compiler we want to use
  const comp_path = comp_cache ? comp_cache.as<string>() : opts.clCompilerPath;
  if (!comp_path) {
  - rollbar.error('Unable to automatically determine compiler', {lang, fileGroup});
  + throw new MissingCompilerException();
  }
  const is_msvc = comp_path && (path.basename(comp_path).toLocaleLowerCase() === 'cl.exe');
  const flags = fileGroup.compileFlags ? [...shlex.split(fileGroup.compileFlags)] : target.compileFlags;
  @@ -208,6 +221,7 @@ export class CppConfigurationProvider implements cpt.CustomConfigurationProvider
  * @param opts Update parameters
  */
  updateConfigurationData(opts: CodeModelParams) {
  + let hadMissingCompilers = false;
  for (const config of opts.codeModel.configurations) {
  for (const project of config.projects) {
  for (const target of project.targets) {
  @@ -220,6 +234,8 @@ export class CppConfigurationProvider implements cpt.CustomConfigurationProvider
  const compileFlags = [...new Set(util.flatMap(grps, grp => shlex.split(grp.compileFlags || '')))];
  const defines = [...new Set(util.flatMap(grps, grp => grp.defines || []))];
  for (const grp of target.fileGroups || []) {
  + try {
  +
  this._updateFileGroup(
  target.sourceDirectory || '',
  grp,
  @@ -230,9 +246,23 @@ export class CppConfigurationProvider implements cpt.CustomConfigurationProvider
  defines,
  },
  );
  + } catch (e) {
  + if (e instanceof MissingCompilerException) {
  + hadMissingCompilers = true;
  + } else {
  + throw e;
  + }
  + }
  + }
  }
  }
  }
  + if (hadMissingCompilers && this._lastUpdateSucceeded) {
  + vscode.window.showErrorMessage('The path to the compiler for one or more source files was not found in ' +
  + 'the CMake cache. If you are using a toolchain file, this probably means ' +
  + 'that you need to specify the CACHE option when you set your C and/or C++ ' +
  + 'compiler path');
  }
  + this._lastUpdateSucceeded = !hadMissingCompilers;
  }
  }
  \ No newline at end of file
  