Coverage Report

Created: 2026-10-28 06:38

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 <cm/optional>
13
#include <cmext/string_view>
14
15
#include "cmCustomCommand.h"
16
#include "cmCustomCommandLines.h"
17
#include "cmCustomCommandTypes.h"
18
#include "cmExecutionStatus.h"
19
#include "cmGeneratorExpression.h"
20
#include "cmGlobalGenerator.h"
21
#include "cmMakefile.h"
22
#include "cmMessageType.h"
23
#include "cmPolicies.h"
24
#include "cmStringAlgorithms.h"
25
#include "cmSystemTools.h"
26
#include "cmValue.h"
27
28
bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
29
                               cmExecutionStatus& status)
30
0
{
31
  /* Let's complain at the end of this function about the lack of a particular
32
     arg. For the moment, let's say that COMMAND, and either TARGET or SOURCE
33
     are required.
34
  */
35
0
  if (args.size() < 4) {
36
0
    status.SetError("called with wrong number of arguments.");
37
0
    return false;
38
0
  }
39
40
0
  cmMakefile& mf = status.GetMakefile();
41
0
  std::string source;
42
0
  std::string target;
43
0
  std::string main_dependency;
44
0
  std::string working;
45
0
  std::string depfile;
46
0
  std::string job_pool;
47
0
  std::string job_server_aware;
48
0
  cm::optional<std::string> comment;
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 && !comment->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 = copy;
385
0
          break;
386
0
        default:
387
0
          status.SetError("Wrong syntax. Unknown type of argument.");
388
0
          return false;
389
0
      }
390
0
    }
391
0
  }
392
393
  // Store the last command line finished.
394
0
  if (!currentLine.empty()) {
395
0
    commandLines.push_back(currentLine);
396
0
    currentLine.clear();
397
0
  }
398
399
  // At this point we could complain about the lack of arguments.  For
400
  // the moment, let's say that COMMAND, TARGET are always required.
401
0
  if (output.empty() && target.empty()) {
402
0
    status.SetError("Wrong syntax. A TARGET or OUTPUT must be specified.");
403
0
    return false;
404
0
  }
405
406
0
  if (source.empty() && !target.empty() && !output.empty()) {
407
0
    status.SetError(
408
0
      "Wrong syntax. A TARGET and OUTPUT can not both be specified.");
409
0
    return false;
410
0
  }
411
0
  if (append && output.empty()) {
412
0
    status.SetError("given APPEND option with no OUTPUT.");
413
0
    return false;
414
0
  }
415
0
  if (!implicit_depends.empty() && !depfile.empty() &&
416
0
      mf.GetGlobalGenerator()->GetName() != "Ninja") {
417
    // Makefiles generators does not support both at the same time
418
0
    status.SetError("IMPLICIT_DEPENDS and DEPFILE can not both be specified.");
419
0
    return false;
420
0
  }
421
422
0
  if (codegen) {
423
0
    if (output.empty()) {
424
0
      status.SetError("CODEGEN requires at least 1 OUTPUT.");
425
0
      return false;
426
0
    }
427
428
0
    if (append) {
429
0
      status.SetError("CODEGEN may not be used with APPEND.");
430
0
      return false;
431
0
    }
432
433
0
    if (!implicit_depends.empty()) {
434
0
      status.SetError("CODEGEN is not compatible with IMPLICIT_DEPENDS.");
435
0
      return false;
436
0
    }
437
438
0
    if (mf.GetPolicyStatus(cmPolicies::CMP0171) != cmPolicies::NEW) {
439
0
      status.SetError("CODEGEN option requires policy CMP0171 be set to NEW!");
440
0
      return false;
441
0
    }
442
0
  }
443
444
  // Check for an append request.
445
0
  if (append) {
446
0
    std::vector<std::string> unsupportedKeywordsUsed;
447
0
    std::set_difference(keywordsSeen.begin(), keywordsSeen.end(),
448
0
                        supportedAppendKeywords.begin(),
449
0
                        supportedAppendKeywords.end(),
450
0
                        std::back_inserter(unsupportedKeywordsUsed));
451
0
    if (!unsupportedKeywordsUsed.empty()) {
452
0
      std::string const msg =
453
0
        cmJoin(unsupportedKeywordsUsed, ", "_s,
454
0
               "The following keywords are not supported when using "
455
0
               "APPEND with add_custom_command(OUTPUT): "_s);
456
0
      if (cmp0175 == cmPolicies::NEW) {
457
0
        mf.IssueMessage(MessageType::FATAL_ERROR, msg);
458
0
        return false;
459
0
      }
460
0
      if (cmp0175 == cmPolicies::WARN) {
461
0
        mf.IssuePolicyWarning(cmPolicies::CMP0175, cmStrCat(msg, '.'));
462
0
      }
463
0
    }
464
0
    mf.AppendCustomCommandToOutput(output[0], depends, implicit_depends,
465
0
                                   commandLines);
466
0
    return true;
467
0
  }
468
469
0
  if (uses_terminal && !job_pool.empty()) {
470
0
    status.SetError("JOB_POOL is shadowed by USES_TERMINAL.");
471
0
    return false;
472
0
  }
473
474
  // Choose which mode of the command to use.
475
0
  auto cc = cm::make_unique<cmCustomCommand>();
476
0
  cc->SetByproducts(byproducts);
477
0
  cc->SetCommandLines(commandLines);
478
0
  cc->SetComment(comment);
479
0
  cc->SetWorkingDirectory(working);
480
0
  cc->SetEscapeOldStyle(!verbatim);
481
0
  cc->SetUsesTerminal(uses_terminal);
482
0
  cc->SetDepfile(depfile);
483
0
  cc->SetJobPool(job_pool);
484
0
  cc->SetJobserverAware(cmIsOn(job_server_aware));
485
0
  cc->SetCommandExpandLists(command_expand_lists);
486
0
  cc->SetDependsExplicitOnly(depends_explicit_only);
487
0
  if (source.empty() && output.empty()) {
488
    // Source is empty, use the target.
489
0
    if (commandLines.empty()) {
490
0
      std::string const msg = "At least one COMMAND must be given.";
491
0
      if (cmp0175 == cmPolicies::NEW) {
492
0
        mf.IssueMessage(MessageType::FATAL_ERROR, msg);
493
0
        return false;
494
0
      }
495
0
      if (cmp0175 == cmPolicies::WARN) {
496
0
        mf.IssuePolicyWarning(cmPolicies::CMP0175, msg);
497
0
      }
498
0
    }
499
500
0
    std::vector<std::string> unsupportedKeywordsUsed;
501
0
    std::set_difference(keywordsSeen.begin(), keywordsSeen.end(),
502
0
                        supportedTargetKeywords.begin(),
503
0
                        supportedTargetKeywords.end(),
504
0
                        std::back_inserter(unsupportedKeywordsUsed));
505
0
    if (!unsupportedKeywordsUsed.empty()) {
506
0
      std::string const msg =
507
0
        cmJoin(unsupportedKeywordsUsed, ", "_s,
508
0
               "The following keywords are not supported when using "
509
0
               "add_custom_command(TARGET): "_s);
510
0
      if (cmp0175 == cmPolicies::NEW) {
511
0
        mf.IssueMessage(MessageType::FATAL_ERROR, msg);
512
0
        return false;
513
0
      }
514
0
      if (cmp0175 == cmPolicies::WARN) {
515
0
        mf.IssuePolicyWarning(cmPolicies::CMP0175, cmStrCat(msg, '.'));
516
0
      }
517
0
    }
518
0
    auto const prePostCount = keywordsSeen.count(keyPRE_BUILD) +
519
0
      keywordsSeen.count(keyPRE_LINK) + keywordsSeen.count(keyPOST_BUILD);
520
0
    if (prePostCount != 1) {
521
0
      std::string msg =
522
0
        "Exactly one of PRE_BUILD, PRE_LINK, or POST_BUILD must be given.";
523
0
      if (cmp0175 == cmPolicies::NEW) {
524
0
        mf.IssueMessage(MessageType::FATAL_ERROR, msg);
525
0
        return false;
526
0
      }
527
0
      if (cmp0175 == cmPolicies::WARN) {
528
0
        msg += " Assuming ";
529
0
        switch (cctype) {
530
0
          case cmCustomCommandType::PRE_BUILD:
531
0
            msg += "PRE_BUILD";
532
0
            break;
533
0
          case cmCustomCommandType::PRE_LINK:
534
0
            msg += "PRE_LINK";
535
0
            break;
536
0
          case cmCustomCommandType::POST_BUILD:
537
0
            msg += "POST_BUILD";
538
0
        }
539
0
        mf.IssuePolicyWarning(
540
0
          cmPolicies::CMP0175,
541
0
          cmStrCat(msg, " to preserve backward compatibility."_s));
542
0
      }
543
0
    }
544
0
    mf.AddCustomCommandToTarget(target, cctype, std::move(cc));
545
0
  } else if (target.empty()) {
546
    // Target is empty, use the output.
547
0
    std::vector<std::string> unsupportedKeywordsUsed;
548
0
    std::set_difference(keywordsSeen.begin(), keywordsSeen.end(),
549
0
                        supportedOutputKeywords.begin(),
550
0
                        supportedOutputKeywords.end(),
551
0
                        std::back_inserter(unsupportedKeywordsUsed));
552
0
    if (!unsupportedKeywordsUsed.empty()) {
553
0
      std::string const msg =
554
0
        cmJoin(unsupportedKeywordsUsed, ", "_s,
555
0
               "The following keywords are not supported when using "
556
0
               "add_custom_command(OUTPUT): "_s);
557
0
      if (cmp0175 == cmPolicies::NEW) {
558
0
        mf.IssueMessage(MessageType::FATAL_ERROR, msg);
559
0
        return false;
560
0
      }
561
0
      if (cmp0175 == cmPolicies::WARN) {
562
0
        mf.IssuePolicyWarning(cmPolicies::CMP0175, cmStrCat(msg, '.'));
563
0
      }
564
0
    }
565
0
    cc->SetOutputs(output);
566
0
    cc->SetMainDependency(main_dependency);
567
0
    cc->SetDepends(depends);
568
0
    cc->SetCodegen(codegen);
569
0
    cc->SetImplicitDepends(implicit_depends);
570
0
    mf.AddCustomCommandToOutput(std::move(cc));
571
0
  } else {
572
0
    mf.IssueMessage(
573
0
      MessageType::FATAL_ERROR,
574
0
      "The SOURCE signatures of add_custom_command are no longer supported.");
575
0
    return false;
576
0
  }
577
578
0
  return true;
579
0
}