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

Function cmProjectCommand

Source/cmProjectCommand.cxx:59–327  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57} // namespace
58
59bool cmProjectCommand(std::vector<std::string> const& args,
60 cmExecutionStatus& status)
61{
62 std::vector<std::string> unparsedArgs;
63 std::vector<cm::string_view> missingValueKeywords;
64 std::vector<cm::string_view> parsedKeywords;
65 ProjectArguments prArgs;
66 ProjectArgumentParser parser;
67 parser.BindKeywordMissingValue(missingValueKeywords)
68 .BindParsedKeywords(parsedKeywords)
69 .Bind("VERSION"_s, prArgs.Version)
70 .Bind("COMPAT_VERSION"_s, prArgs.CompatVersion)
71 .Bind("SPDX_LICENSE"_s, prArgs.License)
72 .Bind("DESCRIPTION"_s, prArgs.Description)
73 .Bind("HOMEPAGE_URL"_s, prArgs.HomepageURL)
74 .Bind("LANGUAGES"_s, prArgs.Languages);
75
76 if (args.empty()) {
77 status.SetError("PROJECT called with incorrect number of arguments");
78 return false;
79 }
80
81 cmMakefile& mf = status.GetMakefile();
82 std::string const& projectName = args[0];
83 if (parser.HasKeyword(projectName)) {
84 mf.IssueMessage(
85 MessageType::AUTHOR_WARNING,
86 cmStrCat(
87 "project() called with '", projectName,
88 "' as first argument. The first parameter should be the project name, "
89 "not a keyword argument. See the cmake-commands(7) manual for correct "
90 "usage of the project() command."));
91 }
92
93 parser.Parse(cmMakeRange(args).advance(1), &unparsedArgs, 1);
94
95 if (mf.IsRootMakefile() &&
96 !mf.GetDefinition("CMAKE_MINIMUM_REQUIRED_VERSION")) {
97 mf.IssueMessage(
98 MessageType::AUTHOR_WARNING,
99 "cmake_minimum_required() should be called prior to this top-level "
100 "project() call. Please see the cmake-commands(7) manual for usage "
101 "documentation of both commands.");
102 }
103
104 if (!IncludeByVariable(status, "CMAKE_PROJECT_INCLUDE_BEFORE")) {
105 return false;
106 }
107
108 if (!IncludeByVariable(status,
109 "CMAKE_PROJECT_" + projectName + "_INCLUDE_BEFORE")) {
110 return false;
111 }
112
113 mf.SetProjectName(projectName);
114
115 cmPolicies::PolicyStatus cmp0180 = mf.GetPolicyStatus(cmPolicies::CMP0180);
116

Callers

nothing calls this directly

Calls 15

cmMakeRangeFunction · 0.85
IncludeByVariableFunction · 0.85
TopLevelCMakeVarCondSetFunction · 0.85
moveFunction · 0.85
IsNormalDefinitionSetMethod · 0.80
AddDefinitionBoolMethod · 0.80
emplace_backMethod · 0.80
has_valueMethod · 0.80
c_strMethod · 0.80
push_backMethod · 0.80
cmStrCatFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…