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

Method ConvertToAbsoluteContent

Source/cmTargetSourcesCommand.cxx:124–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122};
123
124std::vector<std::string> TargetSourcesImpl::ConvertToAbsoluteContent(
125 cmTarget* tgt, std::vector<std::string> const& content,
126 IsInterface isInterfaceContent, CheckCMP0076 checkCmp0076)
127{
128 // Skip conversion in case old behavior has been explicitly requested
129 if (checkCmp0076 == CheckCMP0076::Yes &&
130 this->Makefile->GetPolicyStatus(cmPolicies::CMP0076) ==
131 cmPolicies::OLD) {
132 return content;
133 }
134
135 bool changedPath = false;
136 std::vector<std::string> absoluteContent;
137 absoluteContent.reserve(content.size());
138 for (std::string const& src : content) {
139 std::string absoluteSrc;
140 if (cmSystemTools::FileIsFullPath(src) ||
141 cmGeneratorExpression::Find(src) == 0 ||
142 (isInterfaceContent == IsInterface::No &&
143 (this->Makefile->GetCurrentSourceDirectory() ==
144 tgt->GetMakefile()->GetCurrentSourceDirectory()))) {
145 absoluteSrc = src;
146 } else {
147 changedPath = true;
148 absoluteSrc =
149 cmStrCat(this->Makefile->GetCurrentSourceDirectory(), '/', src);
150 }
151 absoluteContent.push_back(absoluteSrc);
152 }
153
154 if (!changedPath) {
155 return content;
156 }
157
158 bool issueMessage = true;
159 bool useAbsoluteContent = false;
160 std::ostringstream e;
161 if (checkCmp0076 == CheckCMP0076::Yes) {
162 switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0076)) {
163 case cmPolicies::WARN:
164 e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0076) << "\n";
165 break;
166 case cmPolicies::OLD:
167 issueMessage = false;
168 break;
169 case cmPolicies::NEW: {
170 issueMessage = false;
171 useAbsoluteContent = true;
172 break;
173 }
174 }
175 } else {
176 issueMessage = false;
177 useAbsoluteContent = true;
178 }
179
180 if (issueMessage) {
181 if (isInterfaceContent == IsInterface::Yes) {

Callers 3

HandleDirectContentMethod · 0.95
HandleOneFileSetMethod · 0.95

Calls 9

reserveMethod · 0.80
push_backMethod · 0.80
strMethod · 0.80
cmStrCatFunction · 0.70
GetPolicyStatusMethod · 0.45
sizeMethod · 0.45
GetMakefileMethod · 0.45
GetNameMethod · 0.45
IssueMessageMethod · 0.45

Tested by

no test coverage detected