| 57 | } // namespace |
| 58 | |
| 59 | bool 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…