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

Method SetMetadataFromProject

Source/cmProjectInfoArguments.cxx:61–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59#undef ENFORCE_EXCLUSIVE
60
61bool cmProjectInfoArguments::SetMetadataFromProject(cmExecutionStatus& status)
62{
63 // Determine what project to use for inherited metadata.
64 if (!this->SetEffectiveProject(status)) {
65 return false;
66 }
67
68 if (this->ProjectName.empty()) {
69 // We are not inheriting from a project.
70 return true;
71 }
72
73 cmMakefile& mf = status.GetMakefile();
74 auto mapProjectValue = [&](std::string& arg, cm::string_view suffix) {
75 cmValue const& projectValue =
76 mf.GetDefinition(cmStrCat(this->ProjectName, '_', suffix));
77 if (projectValue) {
78 arg = *projectValue;
79 return true;
80 }
81 return false;
82 };
83
84 if (this->Version.empty()) {
85 if (mapProjectValue(this->Version, "VERSION"_s)) {
86 mapProjectValue(this->VersionCompat, "COMPAT_VERSION"_s);
87 }
88 }
89
90 if (this->License.empty()) {
91 mapProjectValue(this->License, "SPDX_LICENSE"_s);
92 }
93
94 if (this->Description.empty()) {
95 mapProjectValue(this->Description, "DESCRIPTION"_s);
96 }
97
98 if (this->Website.empty()) {
99 mapProjectValue(this->Website, "HOMEPAGE_URL"_s);
100 }
101
102 return true;
103}
104
105bool cmProjectInfoArguments::SetEffectiveProject(cmExecutionStatus& status)
106{

Callers 3

HandlePackageInfoModeFunction · 0.80
HandleSbomModeFunction · 0.80
HandleSpecialExportModeFunction · 0.80

Calls 5

SetEffectiveProjectMethod · 0.95
cmStrCatFunction · 0.70
emptyMethod · 0.45
GetMakefileMethod · 0.45
GetDefinitionMethod · 0.45

Tested by

no test coverage detected