Coverage Report

Created: 2026-06-15 07:03

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Source/cmAddCustomCommandCommand.cxx
Line
Count
Source
1
/* Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2
   file LICENSE.rst or https://cmake.org/licensing for details.  */
3
#include "cmAddCustomCommandCommand.h"
4
5
#include <algorithm>
6
#include <iterator>
7
#include <set>
8
#include <unordered_set>
9
#include <utility>
10
11
#include <cm/memory>
12
#include <cmext/string_view>
13
14
#include "cmCustomCommand.h"
15
#include "cmCustomCommandLines.h"
16
#include "cmCustomCommandTypes.h"
17
#include "cmExecutionStatus.h"
18
#include "cmGeneratorExpression.h"
19
#include "cmGlobalGenerator.h"
20
#include "cmMakefile.h"
21
#include "cmMessageType.h"
22
#include "cmPolicies.h"
23
#include "cmStringAlgorithms.h"
24
#include "cmSystemTools.h"
25
#include "cmValue.h"
26
27
bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
28
                               cmExecutionStatus& status)
29
0
{
30
  /* Let's complain at the end of this function about the lack of a particular
31
     arg. For the moment, let's say that COMMAND, and either TARGET or SOURCE
32
     are required.
33
  */
34
0
  if (args.size() < 4) {
35
0
    status.SetError("called with wrong number of arguments.");
36
0
    return false;
37
0
  }
38
39
0
  cmMakefile& mf = status.GetMakefile();
40
0
  std::string source;
41
0
  std::string target;
42
0
  std::string main_dependency;
43
0
  std::string working;
44
0
  std::string depfile;
45
0
  std::string job_pool;
46
0
  std::string job_server_aware;
47
0
  std::string comment_buffer;
48
0
  char const* comment = nullptr;
49
0
  std::vector<std::string> depends;
50
0
  std::vector<std::string> outputs;
51
0
  std::vector<std::string> output;
52
0
  std::vector<std::string> byproducts;
53
0
  bool verbatim = false;
54
0
  bool append = false;
55
0
  bool uses_terminal = false;
56
0
  bool command_expand_lists = false;
57
0
  bool depends_explicit_only =
58
0
    mf.IsOn("CMAKE_ADD_CUSTOM_COMMAND_DEPENDS_EXPLICIT_ONLY");
59
0
  bool codegen = false;
60
0
  std::string implicit_depends_lang;
61
0
  cmImplicitDependsList implicit_depends;
62
63
  // Accumulate one command line at a time.
64
0
  cmCustomCommandLine currentLine;
65
66
  // Save all command lines.
67
0
  cmCustomCommandLines commandLines;
68
69
0
  cmCustomCommandType cctype = cmCustomCommandType::POST_BUILD;
70
71
0
  enum tdoing
72
0
  {
73
0
    doing_source,
74
0
    doing_command,
75
0
    doing_target,
76
0
    doing_depends,
77
0
    doing_implicit_depends_lang,
78
0
    doing_implicit_depends_file,
79
0
    doing_main_dependency,
80
0
    doing_output,
81
0
    doing_outputs,
82
0
    doing_byproducts,
83
0
    doing_comment,
84
0
    doing_working_directory,
85
0
    doing_depfile,
86
0
    doing_job_pool,
87
0
    doing_job_server_aware,
88
0
    doing_nothing
89
0
  };
90
91
0
  tdoing doing = doing_nothing;
92
93
0
#define MAKE_STATIC_KEYWORD(KEYWORD)                                          \
94
0
  static const std::string key##KEYWORD = #KEYWORD
95
0
  MAKE_STATIC_KEYWORD(APPEND);
96
0
  MAKE_STATIC_KEYWORD(ARGS);
97
0
  MAKE_STATIC_KEYWORD(BYPRODUCTS);
98
0
  MAKE_STATIC_KEYWORD(COMMAND);
99
0
  MAKE_STATIC_KEYWORD(COMMAND_EXPAND_LISTS);
100
0
  MAKE_STATIC_KEYWORD(COMMENT);
101
0
  MAKE_STATIC_KEYWORD(DEPENDS);
102
0
  MAKE_STATIC_KEYWORD(DEPFILE);
103
0
  MAKE_STATIC_KEYWORD(IMPLICIT_DEPENDS);
104
0
  MAKE_STATIC_KEYWORD(JOB_POOL);
105
0
  MAKE_STATIC_KEYWORD(JOB_SERVER_AWARE);
106
0
  MAKE_STATIC_KEYWORD(MAIN_DEPENDENCY);
107
0
  MAKE_STATIC_KEYWORD(OUTPUT);
108
0
  MAKE_STATIC_KEYWORD(OUTPUTS);
109
0
  MAKE_STATIC_KEYWORD(POST_BUILD);
110
0
  MAKE_STATIC_KEYWORD(PRE_BUILD);
111
0
  MAKE_STATIC_KEYWORD(PRE_LINK);
112
0
  MAKE_STATIC_KEYWORD(SOURCE);
113
0
  MAKE_STATIC_KEYWORD(TARGET);
114
0
  MAKE_STATIC_KEYWORD(USES_TERMINAL);
115
0
  MAKE_STATIC_KEYWORD(VERBATIM);
116
0
  MAKE_STATIC_KEYWORD(WORKING_DIRECTORY);
117
0
  MAKE_STATIC_KEYWORD(DEPENDS_EXPLICIT_ONLY);
118
0
  MAKE_STATIC_KEYWORD(CODEGEN);
119
0
#undef MAKE_STATIC_KEYWORD
120
0
  static std::unordered_set<std::string> const keywords{
121
0
    keyAPPEND,
122
0
    keyARGS,
123
0
    keyBYPRODUCTS,
124
0
    keyCOMMAND,
125
0
    keyCOMMAND_EXPAND_LISTS,
126
0
    keyCOMMENT,
127
0
    keyDEPENDS,
128
0
    keyDEPFILE,
129
0
    keyIMPLICIT_DEPENDS,
130
0
    keyJOB_POOL,
131
0
    keyMAIN_DEPENDENCY,
132
0
    keyOUTPUT,
133
0
    keyOUTPUTS,
134
0
    keyPOST_BUILD,
135
0
    keyPRE_BUILD,
136
0
    keyPRE_LINK,
137
0
    keySOURCE,
138
0
    keyJOB_SERVER_AWARE,
139
0
    keyTARGET,
140
0
    keyUSES_TERMINAL,
141
0
    keyVERBATIM,
142
0
    keyWORKING_DIRECTORY,
143
0
    keyDEPENDS_EXPLICIT_ONLY,
144
0
    keyCODEGEN
145
0
  };
146
  /* clang-format off */
147
0
  static std::set<std::string> const supportedTargetKeywords{
148
0
    keyARGS,
149
0
    keyBYPRODUCTS,
150
0
    keyCOMMAND,
151
0
    keyCOMMAND_EXPAND_LISTS,
152
0
    keyCOMMENT,
153
0
    keyPOST_BUILD,
154
0
    keyPRE_BUILD,
155
0
    keyPRE_LINK,
156
0
    keyTARGET,
157
0
    keyUSES_TERMINAL,
158
0
    keyVERBATIM,
159
0
    keyWORKING_DIRECTORY
160
0
  };
161
  /* clang-format on */
162
0
  static std::set<std::string> const supportedOutputKeywords{
163
0
    keyAPPEND,
164
0
    keyARGS,
165
0
    keyBYPRODUCTS,
166
0
    keyCODEGEN,
167
0
    keyCOMMAND,
168
0
    keyCOMMAND_EXPAND_LISTS,
169
0
    keyCOMMENT,
170
0
    keyDEPENDS,
171
0
    keyDEPENDS_EXPLICIT_ONLY,
172
0
    keyDEPFILE,
173
0
    keyIMPLICIT_DEPENDS,
174
0
    keyJOB_POOL,
175
0
    keyJOB_SERVER_AWARE,
176
0
    keyMAIN_DEPENDENCY,
177
0
    keyOUTPUT,
178
0
    keyUSES_TERMINAL,
179
0
    keyVERBATIM,
180
0
    keyWORKING_DIRECTORY
181
0
  };
182
  /* clang-format off */
183
0
  static std::set<std::string> const supportedAppendKeywords{
184
0
    keyAPPEND,
185
0
    keyARGS,
186
0
    keyCOMMAND,
187
0
    keyCOMMENT,           // Allowed but ignored
188
0
    keyDEPENDS,
189
0
    keyIMPLICIT_DEPENDS,
190
0
    keyMAIN_DEPENDENCY,   // Allowed but ignored
191
0
    keyOUTPUT,
192
0
    keyWORKING_DIRECTORY  // Allowed but ignored
193
0
  };
194
  /* clang-format on */
195
0
  std::set<std::string> keywordsSeen;
196
0
  std::string const* keywordExpectingValue = nullptr;
197
0
  auto const cmp0175 = mf.GetPolicyStatus(cmPolicies::CMP0175);
198
199
0
  for (std::string const& copy : args) {
200
0
    if (keywords.count(copy)) {
201
      // Check if a preceding keyword expected a value but there wasn't one
202
0
      if (keywordExpectingValue) {
203
0
        std::string const msg =
204
0
          cmStrCat("Keyword ", *keywordExpectingValue,
205
0
                   " requires a value, but none was given.");
206
0
        if (cmp0175 == cmPolicies::NEW) {
207
0
          mf.IssueMessage(MessageType::FATAL_ERROR, msg);
208
0
          return false;
209
0
        }
210
0
        if (cmp0175 == cmPolicies::WARN) {
211
0
          mf.IssuePolicyWarning(cmPolicies::CMP0175, msg);
212
0
        }
213
0
      }
214
0
      keywordExpectingValue = nullptr;
215
0
      keywordsSeen.insert(copy);
216
217
0
      if (copy == keySOURCE) {
218
0
        doing = doing_source;
219
0
        keywordExpectingValue = &keySOURCE;
220
0
      } else if (copy == keyCOMMAND) {
221
0
        doing = doing_command;
222
223
        // Save the current command before starting the next command.
224
0
        if (!currentLine.empty()) {
225
0
          commandLines.push_back(currentLine);
226
0
          currentLine.clear();
227
0
        }
228
0
      } else if (copy == keyPRE_BUILD) {
229
0
        cctype = cmCustomCommandType::PRE_BUILD;
230
0
      } else if (copy == keyPRE_LINK) {
231
0
        cctype = cmCustomCommandType::PRE_LINK;
232
0
      } else if (copy == keyPOST_BUILD) {
233
0
        cctype = cmCustomCommandType::POST_BUILD;
234
0
      } else if (copy == keyVERBATIM) {
235
0
        verbatim = true;
236
0
      } else if (copy == keyAPPEND) {
237
0
        append = true;
238
0
      } else if (copy == keyUSES_TERMINAL) {
239
0
        uses_terminal = true;
240
0
      } else if (copy == keyCOMMAND_EXPAND_LISTS) {
241
0
        command_expand_lists = true;
242
0
      } else if (copy == keyDEPENDS_EXPLICIT_ONLY) {
243
0
        depends_explicit_only = true;
244
0
      } else if (copy == keyCODEGEN) {
245
0
        codegen = true;
246
0
      } else if (copy == keyTARGET) {
247
0
        doing = doing_target;
248
0
        keywordExpectingValue = &keyTARGET;
249
0
      } else if (copy == keyARGS) {
250
        // Ignore this old keyword.
251
0
      } else if (copy == keyDEPENDS) {
252
0
        doing = doing_depends;
253
0
      } else if (copy == keyOUTPUTS) {
254
0
        doing = doing_outputs;
255
0
      } else if (copy == keyOUTPUT) {
256
0
        doing = doing_output;
257
0
        keywordExpectingValue = &keyOUTPUT;
258
0
      } else if (copy == keyBYPRODUCTS) {
259
0
        doing = doing_byproducts;
260
0
      } else if (copy == keyWORKING_DIRECTORY) {
261
0
        doing = doing_working_directory;
262
0
        keywordExpectingValue = &keyWORKING_DIRECTORY;
263
0
      } else if (copy == keyMAIN_DEPENDENCY) {
264
0
        doing = doing_main_dependency;
265
0
        keywordExpectingValue = &keyMAIN_DEPENDENCY;
266
0
      } else if (copy == keyIMPLICIT_DEPENDS) {
267
0
        doing = doing_implicit_depends_lang;
268
0
      } else if (copy == keyCOMMENT) {
269
0
        doing = doing_comment;
270
0
        keywordExpectingValue = &keyCOMMENT;
271
0
      } else if (copy == keyDEPFILE) {
272
0
        doing = doing_depfile;
273
0
        if (!mf.GetGlobalGenerator()->SupportsCustomCommandDepfile()) {
274
0
          status.SetError(cmStrCat("Option DEPFILE not supported by ",
275
0
                                   mf.GetGlobalGenerator()->GetName()));
276
0
          return false;
277
0
        }
278
0
        keywordExpectingValue = &keyDEPFILE;
279
0
      } else if (copy == keyJOB_POOL) {
280
0
        doing = doing_job_pool;
281
0
        keywordExpectingValue = &keyJOB_POOL;
282
0
      } else if (copy == keyJOB_SERVER_AWARE) {
283
0
        doing = doing_job_server_aware;
284
0
        keywordExpectingValue = &keyJOB_SERVER_AWARE;
285
0
      }
286
0
    } else {
287
0
      keywordExpectingValue = nullptr; // Value is being processed now
288
0
      std::string filename;
289
0
      switch (doing) {
290
0
        case doing_output:
291
0
        case doing_outputs:
292
0
        case doing_byproducts:
293
0
          if (!cmSystemTools::FileIsFullPath(copy) &&
294
0
              cmGeneratorExpression::Find(copy) != 0) {
295
            // This is an output to be generated, so it should be
296
            // under the build tree.
297
0
            filename = cmStrCat(mf.GetCurrentBinaryDirectory(), '/');
298
0
          }
299
0
          filename += copy;
300
0
          cmSystemTools::ConvertToUnixSlashes(filename);
301
0
          break;
302
0
        case doing_source:
303
        // We do not want to convert the argument to SOURCE because
304
        // that option is only available for backward compatibility.
305
        // Old-style use of this command may use the SOURCE==TARGET
306
        // trick which we must preserve.  If we convert the source
307
        // to a full path then it will no longer equal the target.
308
0
        default:
309
0
          break;
310
0
      }
311
312
0
      if (cmSystemTools::FileIsFullPath(filename)) {
313
0
        filename = cmSystemTools::CollapseFullPath(filename);
314
0
      }
315
0
      switch (doing) {
316
0
        case doing_depfile:
317
0
          depfile = copy;
318
0
          break;
319
0
        case doing_job_pool:
320
0
          job_pool = copy;
321
0
          break;
322
0
        case doing_job_server_aware:
323
0
          job_server_aware = copy;
324
0
          break;
325
0
        case doing_working_directory:
326
0
          working = copy;
327
0
          break;
328
0
        case doing_source:
329
0
          source = copy;
330
0
          break;
331
0
        case doing_output:
332
0
          output.push_back(filename);
333
0
          break;
334
0
        case doing_main_dependency:
335
0
          main_dependency = copy;
336
0
          break;
337
0
        case doing_implicit_depends_lang:
338
0
          implicit_depends_lang = copy;
339
0
          doing = doing_implicit_depends_file;
340
0
          break;
341
0
        case doing_implicit_depends_file: {
342
          // An implicit dependency starting point is also an
343
          // explicit dependency.
344
0
          std::string dep = copy;
345
          // Upfront path conversion is correct because Genex
346
          // are not supported.
347
0
          cmSystemTools::ConvertToUnixSlashes(dep);
348
0
          depends.push_back(dep);
349
350
          // Add the implicit dependency language and file.
351
0
          implicit_depends.emplace_back(implicit_depends_lang, dep);
352
353
          // Switch back to looking for a language.
354
0
          doing = doing_implicit_depends_lang;
355
0
        } break;
356
0
        case doing_command:
357
0
          currentLine.push_back(copy);
358
0
          break;
359
0
        case doing_target:
360
0
          target = copy;
361
0
          break;
362
0
        case doing_depends:
363
0
          depends.push_back(copy);
364
0
          break;
365
0
        case doing_outputs:
366
0
          outputs.push_back(filename);
367
0
          break;
368
0
        case doing_byproducts:
369
0
          byproducts.push_back(filename);
370
0
          break;
371
0
        case doing_comment:
372
0
          if (!comment_buffer.empty()) {
373
0
            std::string const msg =
374
0
              "COMMENT requires exactly one argument, but multiple values "
375
0
              "or COMMENT keywords have been given.";
376
0
            if (cmp0175 == cmPolicies::NEW) {
377
0
              mf.IssueMessage(MessageType::FATAL_ERROR, msg);
378
0
              return false;
379
0
            }
380
0
            if (cmp0175 == cmPolicies::WARN) {
381
0
              mf.IssuePolicyWarning(cmPolicies::CMP0175, msg);
382
0
            }
383
0
          }
384
0
          comment_buffer = copy;
385
0
          comment = comment_buffer.c_str();
386
0
          break;
387
0
        default:
388
0
          status.SetError("Wrong syntax. Unknown type of argument.");
389
0
          return false;
390
0
      }
391
0
    }
392
0
  }
393
394
  // Store the last command line finished.
395
0
  if (!currentLine.empty()) {
396
0
    commandLines.push_back(currentLine);
397
0
    currentLine.clear();
398
0
  }
399
400
  // At this point we could complain about the lack of arguments.  For
401
  // the moment, let's say that COMMAND, TARGET are always required.
402
0
  if (output.empty() && target.empty()) {
403
0
    status.SetError("Wrong syntax. A TARGET or OUTPUT must be specified.");
404
0
    return false;
405
0
  }
406
407
0
  if (source.empty() && !target.empty() && !output.empty()) {
408
0
    status.SetError(
409
0
      "Wrong syntax. A TARGET and OUTPUT can not both be specified.");
410
0
    return false;
411
0
  }
412
0
  if (append && output.empty()) {
413
0
    status.SetError("given APPEND option with no OUTPUT.");
414
0
    return false;
415
0
  }
416
0
  if (!implicit_depends.empty() && !depfile.empty() &&
417
0
      mf.GetGlobalGenerator()->GetName() != "Ninja") {
418
    // Makefiles generators does not support both at the same time
419
0
    status.SetError("IMPLICIT_DEPENDS and DEPFILE can not both be specified.");
420
0
    return false;
421
0
  }
422
423
0
  if (codegen) {
424
0
    if (output.empty()) {
425
0
      status.SetError("CODEGEN requires at least 1 OUTPUT.");
426
0
      return false;
427
0
    }
428
429
0
    if (append) {
430
0
      status.SetError("CODEGEN may not be used with APPEND.");
431
0
      return false;
432
0
    }
433
434
0
    if (!implicit_depends.empty()) {
435
0
      status.SetError("CODEGEN is not compatible with IMPLICIT_DEPENDS.");
436
0
      return false;
437
0
    }
438
439
0
    if (mf.GetPolicyStatus(cmPolicies::CMP0171) != cmPolicies::NEW) {
440
0
      status.SetError("CODEGEN option requires policy CMP0171 be set to NEW!");
441
0
      return false;
442
0
    }
443
0
  }
444
445
  // Check for an append request.
446
0
  if (append) {
447
0
    std::vector<std::string> unsupportedKeywordsUsed;
448
0
    std::set_difference(keywordsSeen.begin(), keywordsSeen.end(),
449
0
                        supportedAppendKeywords.begin(),
450
0
                        supportedAppendKeywords.end(),
451
0
                        std::back_inserter(unsupportedKeywordsUsed));
452
0
    if (!unsupportedKeywordsUsed.empty()) {
453
0
      std::string const msg =
454
0
        cmJoin(unsupportedKeywordsUsed, ", "_s,
455
0
               "The following keywords are not supported when using "
456
0
               "APPEND with add_custom_command(OUTPUT): "_s);
457
0
      if (cmp0175 == cmPolicies::NEW) {
458
0
        mf.IssueMessage(MessageType::FATAL_ERROR, msg);
459
0
        return false;
460
0
      }
461
0
      if (cmp0175 == cmPolicies::WARN) {
462
0
        mf.IssuePolicyWarning(cmPolicies::CMP0175, cmStrCat(msg, '.'));
463
0
      }
464
0
    }
465
0
    mf.AppendCustomCommandToOutput(output[0], depends, implicit_depends,
466
0
                                   commandLines);
467
0
    return true;
468
0
  }
469
470
0
  if (uses_terminal && !job_pool.empty()) {
471
0
    status.SetError("JOB_POOL is shadowed by USES_TERMINAL.");
472
0
    return false;
473
0
  }
474
475
  // Choose which mode of the command to use.
476
0
  auto cc = cm::make_unique<cmCustomCommand>();
477
0
  cc->SetByproducts(byproducts);
478
0
  cc->SetCommandLines(commandLines);
479
0
  cc->SetComment(comment);
480
0
  cc->SetWorkingDirectory(working.c_str());
481
0
  cc->SetEscapeOldStyle(!verbatim);
482
0
  cc->SetUsesTerminal(uses_terminal);
483
0
  cc->SetDepfile(depfile);
484
0
  cc->SetJobPool(job_pool);
485
0
  cc->SetJobserverAware(cmIsOn(job_server_aware));
486
0
  cc->SetCommandExpandLists(command_expand_lists);
487
0
  cc->SetDependsExplicitOnly(depends_explicit_only);
488
0
  if (source.empty() && output.empty()) {
489
    // Source is empty, use the target.
490
0
    if (commandLines.empty()) {
491
0
      std::string const msg = "At least one COMMAND must be given.";
492
0
      if (cmp0175 == cmPolicies::NEW) {
493
0
        mf.IssueMessage(MessageType::FATAL_ERROR, msg);
494
0
        return false;
495
0
      }
496
0
      if (cmp0175 == cmPolicies::WARN) {
497
0
        mf.IssuePolicyWarning(cmPolicies::CMP0175, msg);
498
0
      }
499
0
    }
500
501
0
    std::vector<std::string> unsupportedKeywordsUsed;
502
0
    std::set_difference(keywordsSeen.begin(), keywordsSeen.end(),
503
0
                        supportedTargetKeywords.begin(),
504
0
                        supportedTargetKeywords.end(),
505
0
                        std::back_inserter(unsupportedKeywordsUsed));
506
0
    if (!unsupportedKeywordsUsed.empty()) {
507
0
      std::string const msg =
508
0
        cmJoin(unsupportedKeywordsUsed, ", "_s,
509
0
               "The following keywords are not supported when using "
510
0
               "add_custom_command(TARGET): "_s);
511
0
      if (cmp0175 == cmPolicies::NEW) {
512
0
        mf.IssueMessage(MessageType::FATAL_ERROR, msg);
513
0
        return false;
514
0
      }
515
0
      if (cmp0175 == cmPolicies::WARN) {
516
0
        mf.IssuePolicyWarning(cmPolicies::CMP0175, cmStrCat(msg, '.'));
517
0
      }
518
0
    }
519
0
    auto const prePostCount = keywordsSeen.count(keyPRE_BUILD) +
520
0
      keywordsSeen.count(keyPRE_LINK) + keywordsSeen.count(keyPOST_BUILD);
521
0
    if (prePostCount != 1) {
522
0
      std::string msg =
523
0
        "Exactly one of PRE_BUILD, PRE_LINK, or POST_BUILD must be given.";
524
0
      if (cmp0175 == cmPolicies::NEW) {
525
0
        mf.IssueMessage(MessageType::FATAL_ERROR, msg);
526
0
        return false;
527
0
      }
528
0
      if (cmp0175 == cmPolicies::WARN) {
529
0
        msg += " Assuming ";
530
0
        switch (cctype) {
531
0
          case cmCustomCommandType::PRE_BUILD:
532
0
            msg += "PRE_BUILD";
533
0
            break;
534
0
          case cmCustomCommandType::PRE_LINK:
535
0
            msg += "PRE_LINK";
536
0
            break;
537
0
          case cmCustomCommandType::POST_BUILD:
538
0
            msg += "POST_BUILD";
539
0
        }
540
0
        mf.IssuePolicyWarning(
541
0
          cmPolicies::CMP0175,
542
0
          cmStrCat(msg, " to preserve backward compatibility."_s));
543
0
      }
544
0
    }
545
0
    mf.AddCustomCommandToTarget(target, cctype, std::move(cc));
546
0
  } else if (target.empty()) {
547
    // Target is empty, use the output.
548
0
    std::vector<std::string> unsupportedKeywordsUsed;
549
0
    std::set_difference(keywordsSeen.begin(), keywordsSeen.end(),
550
0
                        supportedOutputKeywords.begin(),
551
0
                        supportedOutputKeywords.end(),
552
0
                        std::back_inserter(unsupportedKeywordsUsed));
553
0
    if (!unsupportedKeywordsUsed.empty()) {
554
0
      std::string const msg =
555
0
        cmJoin(unsupportedKeywordsUsed, ", "_s,
556
0
               "The following keywords are not supported when using "
557
0
               "add_custom_command(OUTPUT): "_s);
558
0
      if (cmp0175 == cmPolicies::NEW) {
559
0
        mf.IssueMessage(MessageType::FATAL_ERROR, msg);
560
0
        return false;
561
0
      }
562
0
      if (cmp0175 == cmPolicies::WARN) {
563
0
        mf.IssuePolicyWarning(cmPolicies::CMP0175, cmStrCat(msg, '.'));
564
0
      }
565
0
    }
566
0
    cc->SetOutputs(output);
567
0
    cc->SetMainDependency(main_dependency);
568
0
    cc->SetDepends(depends);
569
0
    cc->SetCodegen(codegen);
570
0
    cc->SetImplicitDepends(implicit_depends);
571
0
    mf.AddCustomCommandToOutput(std::move(cc));
572
0
  } else {
573
0
    mf.IssueMessage(
574
0
      MessageType::FATAL_ERROR,
575
0
      "The SOURCE signatures of add_custom_command are no longer supported.");
576
0
    return false;
577
0
  }
578
579
0
  return true;
580
0
}