message: Re-merge two PR's
diff: @@ -1408,25 +1408,13 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
  */
  async runBuild(targets_?: string[], showCommandOnly?: boolean): Promise<number> {
  log.info(localize('run.build', 'Building folder: {0}', this.folderName), (targets_ && targets_.length > 0) ? targets_.join(', ') : '');
  - let targets = targets_;
  - let targetName: string;
  - const defaultBuildTargets = await this.getDefaultBuildTargets();
  - if (this.useCMakePresets) {
  - targets = (targets && targets.length > 0) ? targets : defaultBuildTargets;
  - targetName = `${this.buildPreset?.displayName || this.buildPreset?.name || ''}${targets ? (': ' + targets.join(', ')) : ''}`;
  - targetName = targetName || this.buildPreset?.displayName || this.buildPreset?.name || '';
  - } else {
  - targets = (targets && targets.length > 0) ? targets : defaultBuildTargets!;
  - targetName = targets.join(', ');
  - }
  -
  let drv: CMakeDriver | null;
  if (showCommandOnly) {
  drv = await this.getCMakeDriverInstance();
  if (!drv) {
  throw new Error(localize('failed.to.get.cmake.driver', 'Failed to get CMake driver'));
  }
  - const buildCmd = await drv.getCMakeBuildCommand(targets);
  + const buildCmd = await drv.getCMakeBuildCommand(targets_);
  if (buildCmd) {
  log.showChannel();
  log.info(buildCmdStr(buildCmd.command, buildCmd.args));
  @@ -1446,6 +1434,18 @@ export class CMakeTools implements vscode.Disposable, api.CMakeToolsAPI {
  if (!drv) {
  throw new Error(localize('driver.died.after.successful.configure', 'CMake driver died immediately after successful configure'));
  }
  + let targets = targets_;
  + let targetName: string;
  + const defaultBuildTargets = await this.getDefaultBuildTargets();
  + if (this.useCMakePresets) {
  + targets = (targets && targets.length > 0) ? targets : defaultBuildTargets;
  + targetName = `${this.buildPreset?.displayName || this.buildPreset?.name || ''}${targets ? (': ' + targets.join(', ')) : ''}`;
  + targetName = targetName || this.buildPreset?.displayName || this.buildPreset?.name || '';
  + } else {
  + targets = (targets && targets.length > 0) ? targets : defaultBuildTargets!;
  + targetName = targets.join(', ');
  + }
  +
  this.updateDriverAndTargetsInTaskProvider(drv, targets);
  const consumer = new CMakeBuildConsumer(BUILD_LOGGER, drv.config);
  const IS_BUILDING_KEY = 'cmake:isBuilding';
  