cmLocalNinjaGenerator.cxx 19.2 KB
Newer Older
1
2
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
   file Copyright.txt or https://cmake.org/licensing for details.  */
3
#include "cmLocalNinjaGenerator.h"
Brad King's avatar
Brad King committed
4

5
6
7
#include <algorithm>
#include <assert.h>
#include <iterator>
8
#include <memory> // IWYU pragma: keep
9
10
11
12
#include <sstream>
#include <stdio.h>
#include <utility>

13
#include "cmCryptoHash.h"
14
#include "cmCustomCommand.h"
15
#include "cmCustomCommandGenerator.h"
16
#include "cmGeneratedFileStream.h"
17
18
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
19
#include "cmGlobalNinjaGenerator.h"
20
#include "cmLocalGenerator.h"
21
#include "cmMakefile.h"
22
#include "cmNinjaTargetGenerator.h"
23
#include "cmRulePlaceholderExpander.h"
24
#include "cmSourceFile.h"
25
#include "cmState.h"
26
#include "cmStateTypes.h"
27
#include "cmSystemTools.h"
28
#include "cmake.h"
29
#include "cmsys/FStream.hxx"
30

31
cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg,
32
                                             cmMakefile* mf)
33
  : cmLocalCommonGenerator(gg, mf, mf->GetState()->GetBinaryDirectory())
34
35
36
37
38
39
  , HomeRelativeOutputPath("")
{
}

// Virtual public methods.

40
41
42
cmRulePlaceholderExpander*
cmLocalNinjaGenerator::CreateRulePlaceholderExpander() const
{
43
  cmRulePlaceholderExpander* ret =
44
    this->cmLocalGenerator::CreateRulePlaceholderExpander();
45
46
47
48
  ret->SetTargetImpLib("$TARGET_IMPLIB");
  return ret;
}

49
50
51
52
53
54
cmLocalNinjaGenerator::~cmLocalNinjaGenerator()
{
}

void cmLocalNinjaGenerator::Generate()
{
55
56
  // Compute the path to use when referencing the current output
  // directory from the top output directory.
57
  this->HomeRelativeOutputPath = this->ConvertToRelativePath(
58
    this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory());
59
  if (this->HomeRelativeOutputPath == ".") {
60
    this->HomeRelativeOutputPath.clear();
61
  }
62

63
  this->WriteProcessedMakefile(this->GetBuildFileStream());
64
#ifdef NINJA_GEN_VERBOSE_FILES
65
  this->WriteProcessedMakefile(this->GetRulesFileStream());
66
#endif
67

68
  // We do that only once for the top CMakeLists.txt file.
69
  if (this->IsRootMakefile()) {
70
71
    this->WriteBuildFileTop();

72
73
    this->WritePools(this->GetRulesFileStream());

74
75
76
    const std::string showIncludesPrefix =
      this->GetMakefile()->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX");
    if (!showIncludesPrefix.empty()) {
77
78
      cmGlobalNinjaGenerator::WriteComment(this->GetRulesFileStream(),
                                           "localized /showIncludes string");
79
80
      this->GetRulesFileStream()
        << "msvc_deps_prefix = " << showIncludesPrefix << "\n\n";
81
    }
82
  }
83

84
  const std::vector<cmGeneratorTarget*>& targets = this->GetGeneratorTargets();
85
86
  for (cmGeneratorTarget* target : targets) {
    if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
87
      continue;
88
    }
89
    cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(target);
90
    if (tg) {
91
92
93
      tg->Generate();
      // Add the target to "all" if required.
      if (!this->GetGlobalNinjaGenerator()->IsExcluded(
94
95
96
            this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0],
            target)) {
        this->GetGlobalNinjaGenerator()->AddDependencyToAll(target);
97
      }
98
99
      delete tg;
    }
100
  }
101
102
103
104
105

  this->WriteCustomCommandBuildStatements();
}

// TODO: Picked up from cmLocalUnixMakefileGenerator3.  Refactor it.
106
107
std::string cmLocalNinjaGenerator::GetTargetDirectory(
  cmGeneratorTarget const* target) const
108
{
109
  std::string dir = "CMakeFiles/";
110
  dir += target->GetName();
111
112
113
114
115
116
117
118
119
120
#if defined(__VMS)
  dir += "_dir";
#else
  dir += ".dir";
#endif
  return dir;
}

// Non-virtual public methods.

121
122
const cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator()
  const
123
{
124
125
  return static_cast<const cmGlobalNinjaGenerator*>(
    this->GetGlobalGenerator());
126
127
128
129
130
131
132
133
134
}

cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator()
{
  return static_cast<cmGlobalNinjaGenerator*>(this->GetGlobalGenerator());
}

// Virtual protected methods.

135
std::string cmLocalNinjaGenerator::ConvertToIncludeReference(
136
137
  std::string const& path, cmOutputConverter::OutputFormat format,
  bool forceFullPaths)
138
{
139
  if (forceFullPaths) {
140
141
    return this->ConvertToOutputFormat(cmSystemTools::CollapseFullPath(path),
                                       format);
142
  }
143
144
  return this->ConvertToOutputFormat(
    this->ConvertToRelativePath(this->GetBinaryDirectory(), path), format);
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
}

// Private methods.

cmGeneratedFileStream& cmLocalNinjaGenerator::GetBuildFileStream() const
{
  return *this->GetGlobalNinjaGenerator()->GetBuildFileStream();
}

cmGeneratedFileStream& cmLocalNinjaGenerator::GetRulesFileStream() const
{
  return *this->GetGlobalNinjaGenerator()->GetRulesFileStream();
}

const cmake* cmLocalNinjaGenerator::GetCMakeInstance() const
{
  return this->GetGlobalGenerator()->GetCMakeInstance();
}

cmake* cmLocalNinjaGenerator::GetCMakeInstance()
{
  return this->GetGlobalGenerator()->GetCMakeInstance();
}

void cmLocalNinjaGenerator::WriteBuildFileTop()
{
  // For the build file.
  this->WriteProjectHeader(this->GetBuildFileStream());
173
  this->WriteNinjaRequiredVersion(this->GetBuildFileStream());
174
175
176
177
178
179
180
181
182
  this->WriteNinjaFilesInclusion(this->GetBuildFileStream());

  // For the rule file.
  this->WriteProjectHeader(this->GetRulesFileStream());
}

void cmLocalNinjaGenerator::WriteProjectHeader(std::ostream& os)
{
  cmGlobalNinjaGenerator::WriteDivider(os);
183
184
  os << "# Project: " << this->GetProjectName() << std::endl
     << "# Configuration: " << this->ConfigName << std::endl;
185
186
187
  cmGlobalNinjaGenerator::WriteDivider(os);
}

188
189
190
void cmLocalNinjaGenerator::WriteNinjaRequiredVersion(std::ostream& os)
{
  // Default required version
191
  std::string requiredVersion = cmGlobalNinjaGenerator::RequiredNinjaVersion();
192
193

  // Ninja generator uses the 'console' pool if available (>= 1.5)
194
  if (this->GetGlobalNinjaGenerator()->SupportsConsolePool()) {
195
    requiredVersion =
196
      cmGlobalNinjaGenerator::RequiredNinjaVersionForConsolePool();
197
  }
198

199
200
201
202
203
204
205
  // The Ninja generator writes rules which require support for restat
  // when rebuilding build.ninja manifest (>= 1.8)
  if (this->GetGlobalNinjaGenerator()->SupportsManifestRestat() &&
      this->GetCMakeInstance()->DoWriteGlobVerifyTarget() &&
      !this->GetGlobalNinjaGenerator()->GlobalSettingIsOn(
        "CMAKE_SUPPRESS_REGENERATION")) {
    requiredVersion =
206
      cmGlobalNinjaGenerator::RequiredNinjaVersionForManifestRestat();
207
208
  }

209
210
211
212
  cmGlobalNinjaGenerator::WriteComment(
    os, "Minimal version of Ninja required by this file");
  os << "ninja_required_version = " << requiredVersion << std::endl
     << std::endl;
213
214
}

215
216
217
218
void cmLocalNinjaGenerator::WritePools(std::ostream& os)
{
  cmGlobalNinjaGenerator::WriteDivider(os);

219
220
  const char* jobpools =
    this->GetCMakeInstance()->GetState()->GetGlobalProperty("JOB_POOLS");
221
222
223
  if (!jobpools) {
    jobpools = this->GetMakefile()->GetDefinition("CMAKE_JOB_POOLS");
  }
224
225
226
  if (jobpools) {
    cmGlobalNinjaGenerator::WriteComment(
      os, "Pools defined by global property JOB_POOLS");
227
228
    std::vector<std::string> pools;
    cmSystemTools::ExpandListArgument(jobpools, pools);
229
    for (std::string const& pool : pools) {
230
      const std::string::size_type eq = pool.find('=');
231
232
      unsigned int jobs;
      if (eq != std::string::npos &&
233
          sscanf(pool.c_str() + eq, "=%u", &jobs) == 1) {
234
235
236
        os << "pool " << pool.substr(0, eq) << std::endl;
        os << "  depth = " << jobs << std::endl;
        os << std::endl;
237
      } else {
238
239
240
241
        cmSystemTools::Error("Invalid pool defined by property 'JOB_POOLS': ",
                             pool.c_str());
      }
    }
242
  }
243
244
}

245
246
247
void cmLocalNinjaGenerator::WriteNinjaFilesInclusion(std::ostream& os)
{
  cmGlobalNinjaGenerator::WriteDivider(os);
248
249
  os << "# Include auxiliary files.\n"
     << "\n";
250
251
252
  cmGlobalNinjaGenerator* ng = this->GetGlobalNinjaGenerator();
  std::string const ninjaRulesFile =
    ng->NinjaOutputPath(cmGlobalNinjaGenerator::NINJA_RULES_FILE);
253
  std::string const rulesFilePath = ng->EncodePath(ninjaRulesFile);
254
255
  cmGlobalNinjaGenerator::WriteInclude(os, rulesFilePath,
                                       "Include rules file.");
256
257
258
259
260
261
  os << "\n";
}

void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
{
  cmGlobalNinjaGenerator::WriteDivider(os);
262
263
264
  os << "# Write statements declared in CMakeLists.txt:" << std::endl
     << "# " << this->Makefile->GetDefinition("CMAKE_CURRENT_LIST_FILE")
     << std::endl;
265
  if (this->IsRootMakefile()) {
266
    os << "# Which is the root file." << std::endl;
267
  }
268
269
270
271
  cmGlobalNinjaGenerator::WriteDivider(os);
  os << std::endl;
}

272
273
void cmLocalNinjaGenerator::AppendTargetOutputs(cmGeneratorTarget* target,
                                                cmNinjaDeps& outputs)
274
275
276
277
{
  this->GetGlobalNinjaGenerator()->AppendTargetOutputs(target, outputs);
}

278
void cmLocalNinjaGenerator::AppendTargetDepends(cmGeneratorTarget* target,
279
280
                                                cmNinjaDeps& outputs,
                                                cmNinjaTargetDepends depends)
281
{
282
283
  this->GetGlobalNinjaGenerator()->AppendTargetDepends(target, outputs,
                                                       depends);
284
285
}

286
void cmLocalNinjaGenerator::AppendCustomCommandDeps(
287
  cmCustomCommandGenerator const& ccg, cmNinjaDeps& ninjaDeps)
288
{
289
  const std::vector<std::string>& deps = ccg.GetDepends();
290
  for (std::string const& i : deps) {
291
    std::string dep;
292
    if (this->GetRealDependency(i, this->GetConfigName(), dep)) {
293
294
      ninjaDeps.push_back(
        this->GetGlobalNinjaGenerator()->ConvertToNinjaPath(dep));
295
    }
296
297
298
  }
}

299
300
301
302
303
304
305
306
307
std::string cmLocalNinjaGenerator::WriteCommandScript(
  std::vector<std::string> const& cmdLines, std::string const& customStep,
  cmGeneratorTarget const* target) const
{
  std::string scriptPath;
  if (target) {
    scriptPath = target->GetSupportDirectory();
  } else {
    scriptPath = this->GetCurrentBinaryDirectory();
308
    scriptPath += "/CMakeFiles";
309
310
311
312
313
314
315
316
317
318
319
320
  }
  cmSystemTools::MakeDirectory(scriptPath);
  scriptPath += '/';
  scriptPath += customStep;
#ifdef _WIN32
  scriptPath += ".bat";
#else
  scriptPath += ".sh";
#endif

  cmsys::ofstream script(scriptPath.c_str());

321
#ifdef _WIN32
322
  script << "@echo off\n";
323
324
  int line = 1;
#else
325
326
327
328
329
330
331
332
333
334
  script << "set -e\n\n";
#endif

  for (auto const& i : cmdLines) {
    std::string cmd = i;
    // The command line was built assuming it would be written to
    // the build.ninja file, so it uses '$$' for '$'.  Remove this
    // for the raw shell script.
    cmSystemTools::ReplaceString(cmd, "$$", "$");
#ifdef _WIN32
335
336
    script << cmd << " || (set FAIL_LINE=" << ++line << "& goto :ABORT)"
           << '\n';
337
338
339
340
341
#else
    script << cmd << '\n';
#endif
  }

342
343
344
345
346
347
348
349
350
#ifdef _WIN32
  script << "goto :EOF\n\n"
            ":ABORT\n"
            "set ERROR_CODE=%ERRORLEVEL%\n"
            "echo Batch file failed at line %FAIL_LINE% "
            "with errorcode %ERRORLEVEL%\n"
            "exit /b %ERROR_CODE%";
#endif

351
352
353
  return scriptPath;
}

354
std::string cmLocalNinjaGenerator::BuildCommandLine(
355
356
  std::vector<std::string> const& cmdLines, std::string const& customStep,
  cmGeneratorTarget const* target) const
357
{
358
  // If we have no commands but we need to build a command anyway, use noop.
359
360
  // This happens when building a POST_BUILD value for link targets that
  // don't use POST_BUILD.
361
  if (cmdLines.empty()) {
362
    return cmGlobalNinjaGenerator::SHELL_NOOP;
363
  }
364

365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
  // If this is a custom step then we will have no '$VAR' ninja placeholders.
  // This means we can deal with long command sequences by writing to a script.
  // Do this if the command lines are on the scale of the OS limit.
  if (!customStep.empty()) {
    size_t cmdLinesTotal = 0;
    for (std::string const& cmd : cmdLines) {
      cmdLinesTotal += cmd.length() + 6;
    }
    if (cmdLinesTotal > cmSystemTools::CalculateCommandLineLengthLimit() / 2) {
      std::string const scriptPath =
        this->WriteCommandScript(cmdLines, customStep, target);
      std::string cmd
#ifndef _WIN32
        = "/bin/sh "
#endif
        ;
      cmd += this->ConvertToOutputFormat(
        this->GetGlobalNinjaGenerator()->ConvertToNinjaPath(scriptPath),
        cmOutputConverter::SHELL);

      // Add an unused argument based on script content so that Ninja
      // knows when the command lines change.
      cmd += " ";
      cmCryptoHash hash(cmCryptoHash::AlgoSHA256);
      cmd += hash.HashFile(scriptPath).substr(0, 16);
      return cmd;
    }
  }

394
  std::ostringstream cmd;
395
  for (std::vector<std::string>::const_iterator li = cmdLines.begin();
396
       li != cmdLines.end(); ++li)
397
#ifdef _WIN32
398
399
  {
    if (li != cmdLines.begin()) {
400
      cmd << " && ";
401
    } else if (cmdLines.size() > 1) {
402
      cmd << "cmd.exe /C \"";
403
    }
404
405
406
407
408
409
410
    // Put current cmdLine in brackets if it contains "||" because it has
    // higher precedence than "&&" in cmd.exe
    if (li->find("||") != std::string::npos) {
      cmd << "( " << *li << " )";
    } else {
      cmd << *li;
    }
411
412
  }
  if (cmdLines.size() > 1) {
413
    cmd << "\"";
414
  }
415
#else
416
417
  {
    if (li != cmdLines.begin()) {
418
419
      cmd << " && ";
    }
420
421
    cmd << *li;
  }
422
#endif
423
424
425
  return cmd.str();
}

426
void cmLocalNinjaGenerator::AppendCustomCommandLines(
427
  cmCustomCommandGenerator const& ccg, std::vector<std::string>& cmdLines)
428
429
{
  if (ccg.GetNumberOfCommands() > 0) {
430
    std::string wd = ccg.GetWorkingDirectory();
431
    if (wd.empty()) {
432
      wd = this->GetCurrentBinaryDirectory();
433
    }
434

435
    std::ostringstream cdCmd;
436
#ifdef _WIN32
437
    std::string cdStr = "cd /D ";
438
#else
439
    std::string cdStr = "cd ";
440
#endif
441
442
    cdCmd << cdStr
          << this->ConvertToOutputFormat(wd, cmOutputConverter::SHELL);
443
444
    cmdLines.push_back(cdCmd.str());
  }
445

446
  std::string launcher = this->MakeCustomLauncher(ccg);
447

448
  for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) {
449
    cmdLines.push_back(launcher +
450
451
                       this->ConvertToOutputFormat(ccg.GetCommand(i),
                                                   cmOutputConverter::SHELL));
452

453
454
455
456
457
    std::string& cmd = cmdLines.back();
    ccg.AppendArguments(i, cmd);
  }
}

458
459
void cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
  cmCustomCommand const* cc, const cmNinjaDeps& orderOnlyDeps)
460
{
461
  if (this->GetGlobalNinjaGenerator()->SeenCustomCommand(cc)) {
462
    return;
463
  }
464

465
  cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this);
466

467
468
469
  const std::vector<std::string>& outputs = ccg.GetOutputs();
  const std::vector<std::string>& byproducts = ccg.GetByproducts();
  cmNinjaDeps ninjaOutputs(outputs.size() + byproducts.size()), ninjaDeps;
470

471
472
  bool symbolic = false;
  for (std::vector<std::string>::const_iterator o = outputs.begin();
473
474
       !symbolic && o != outputs.end(); ++o) {
    if (cmSourceFile* sf = this->Makefile->GetSource(*o)) {
475
476
      symbolic = sf->GetPropertyAsBool("SYMBOLIC");
    }
477
  }
478

479
#if 0
480
#  error TODO: Once CC in an ExternalProject target must provide the \
481
482
483
    file of each imported target that has an add_dependencies pointing \
    at us.  How to know which ExternalProject step actually provides it?
#endif
484
  std::transform(outputs.begin(), outputs.end(), ninjaOutputs.begin(),
485
                 this->GetGlobalNinjaGenerator()->MapToNinjaPath());
486
  std::transform(byproducts.begin(), byproducts.end(),
487
488
                 ninjaOutputs.begin() + outputs.size(),
                 this->GetGlobalNinjaGenerator()->MapToNinjaPath());
489
  this->AppendCustomCommandDeps(ccg, ninjaDeps);
490

491
492
  for (std::string const& ninjaOutput : ninjaOutputs) {
    this->GetGlobalNinjaGenerator()->SeenCustomCommandOutput(ninjaOutput);
493
  }
494
495

  std::vector<std::string> cmdLines;
496
  this->AppendCustomCommandLines(ccg, cmdLines);
497
498

  if (cmdLines.empty()) {
499
500
    this->GetGlobalNinjaGenerator()->WritePhonyBuild(
      this->GetBuildFileStream(),
501
502
      "Phony custom command for " + ninjaOutputs[0], ninjaOutputs, ninjaDeps,
      cmNinjaDeps(), orderOnlyDeps, cmNinjaVars());
503
  } else {
504
505
506
507
508
509
    std::string customStep = cmSystemTools::GetFilenameName(ninjaOutputs[0]);
    // Hash full path to make unique.
    customStep += '-';
    cmCryptoHash hash(cmCryptoHash::AlgoSHA256);
    customStep += hash.HashString(ninjaOutputs[0]).substr(0, 7);

510
    this->GetGlobalNinjaGenerator()->WriteCustomCommandBuild(
511
512
513
      this->BuildCommandLine(cmdLines, customStep),
      this->ConstructComment(ccg), "Custom command for " + ninjaOutputs[0],
      cc->GetDepfile(), cc->GetUsesTerminal(),
514
      /*restat*/ !symbolic || !byproducts.empty(), ninjaOutputs, ninjaDeps,
515
516
517
518
      orderOnlyDeps);
  }
}

519
void cmLocalNinjaGenerator::AddCustomCommandTarget(cmCustomCommand const* cc,
520
                                                   cmGeneratorTarget* target)
521
{
522
  CustomCommandTargetMap::value_type v(cc, std::set<cmGeneratorTarget*>());
523
524
525
  std::pair<CustomCommandTargetMap::iterator, bool> ins =
    this->CustomCommandTargets.insert(v);
  if (ins.second) {
526
    this->CustomCommands.push_back(cc);
527
  }
528
  ins.first->second.insert(target);
529
530
531
532
}

void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements()
{
533
534
535
  for (cmCustomCommand const* customCommand : this->CustomCommands) {
    CustomCommandTargetMap::iterator i =
      this->CustomCommandTargets.find(customCommand);
536
537
    assert(i != this->CustomCommandTargets.end());

538
539
540
541
542
543
544
545
546
    // A custom command may appear on multiple targets.  However, some build
    // systems exist where the target dependencies on some of the targets are
    // overspecified, leading to a dependency cycle.  If we assume all target
    // dependencies are a superset of the true target dependencies for this
    // custom command, we can take the set intersection of all target
    // dependencies to obtain a correct dependency list.
    //
    // FIXME: This won't work in certain obscure scenarios involving indirect
    // dependencies.
547
    std::set<cmGeneratorTarget*>::iterator j = i->second.begin();
548
549
    assert(j != i->second.end());
    std::vector<std::string> ccTargetDeps;
550
551
    this->GetGlobalNinjaGenerator()->AppendTargetDependsClosure(*j,
                                                                ccTargetDeps);
552
553
554
555
556
    std::sort(ccTargetDeps.begin(), ccTargetDeps.end());
    ++j;

    for (; j != i->second.end(); ++j) {
      std::vector<std::string> jDeps, depsIntersection;
557
      this->GetGlobalNinjaGenerator()->AppendTargetDependsClosure(*j, jDeps);
558
559
560
561
562
563
564
565
566
567
      std::sort(jDeps.begin(), jDeps.end());
      std::set_intersection(ccTargetDeps.begin(), ccTargetDeps.end(),
                            jDeps.begin(), jDeps.end(),
                            std::back_inserter(depsIntersection));
      ccTargetDeps = depsIntersection;
    }

    this->WriteCustomCommandBuildStatement(i->first, ccTargetDeps);
  }
}
568
569

std::string cmLocalNinjaGenerator::MakeCustomLauncher(
570
  cmCustomCommandGenerator const& ccg)
571
{
572
573
  const char* property_value =
    this->Makefile->GetProperty("RULE_LAUNCH_CUSTOM");
574

575
  if (!property_value || !*property_value) {
576
577
578
    return std::string();
  }

579
  // Expand rule variables referenced in the given launcher command.
580
  cmRulePlaceholderExpander::RuleVariables vars;
581

582
  std::string output;
583
  const std::vector<std::string>& outputs = ccg.GetOutputs();
584
  if (!outputs.empty()) {
585
    output = outputs[0];
586
    if (ccg.GetWorkingDirectory().empty()) {
587
588
      output =
        this->ConvertToRelativePath(this->GetCurrentBinaryDirectory(), output);
589
    }
590
    output = this->ConvertToOutputFormat(output, cmOutputConverter::SHELL);
591
592
593
  }
  vars.Output = output.c_str();

594
  std::unique_ptr<cmRulePlaceholderExpander> rulePlaceholderExpander(
595
596
    this->CreateRulePlaceholderExpander());

597
  std::string launcher = property_value;
598
  rulePlaceholderExpander->ExpandRuleVariables(this, launcher, vars);
599
  if (!launcher.empty()) {
600
601
602
603
604
    launcher += " ";
  }

  return launcher;
}