MCPcopy Create free account
hub / github.com/Kitware/CMake / cmAddExecutableCommand

Function cmAddExecutableCommand

Source/cmAddExecutableCommand.cxx:13–166  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11#include "cmTarget.h"
12
13bool cmAddExecutableCommand(std::vector<std::string> const& args,
14 cmExecutionStatus& status)
15{
16 if (args.empty()) {
17 status.SetError("called with incorrect number of arguments");
18 return false;
19 }
20
21 cmMakefile& mf = status.GetMakefile();
22 auto s = args.begin();
23
24 std::string const& exename = *s;
25
26 ++s;
27 bool use_win32 = false;
28 bool use_macbundle = false;
29 bool excludeFromAll = false;
30 bool importTarget = false;
31 bool importGlobal = false;
32 bool isAlias = false;
33 while (s != args.end()) {
34 if (*s == "WIN32") {
35 ++s;
36 use_win32 = true;
37 } else if (*s == "MACOSX_BUNDLE") {
38 ++s;
39 use_macbundle = true;
40 } else if (*s == "EXCLUDE_FROM_ALL") {
41 ++s;
42 excludeFromAll = true;
43 } else if (*s == "IMPORTED") {
44 ++s;
45 importTarget = true;
46 } else if (importTarget && *s == "GLOBAL") {
47 ++s;
48 importGlobal = true;
49 } else if (*s == "ALIAS") {
50 ++s;
51 isAlias = true;
52 } else {
53 break;
54 }
55 }
56
57 if (importTarget && !importGlobal) {
58 importGlobal = mf.IsImportedTargetGlobalScope();
59 }
60
61 bool nameOk = cmGeneratorExpression::IsValidTargetName(exename) &&
62 !cmGlobalGenerator::IsReservedTarget(exename);
63
64 if (nameOk && !importTarget && !isAlias) {
65 nameOk = exename.find(':') == std::string::npos;
66 }
67 if (!nameOk) {
68 mf.IssueInvalidTargetNameError(exename);
69 return false;
70 }

Callers

nothing calls this directly

Calls 15

FindTargetToUseMethod · 0.80
AddImportedTargetMethod · 0.80
EnforceUniqueNameMethod · 0.80
cmStrCatFunction · 0.70
emptyMethod · 0.45
SetErrorMethod · 0.45
GetMakefileMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…