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

Method ApplyCXXStdTargets

Source/cmGeneratorTarget.cxx:5225–5335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5223} // namespace
5224
5225bool cmGeneratorTarget::ApplyCXXStdTargets()
5226{
5227 cmStandardLevelResolver standardResolver(this->Makefile);
5228 cmStandardLevel const cxxStd23 =
5229 *standardResolver.LanguageStandardLevel("CXX", "23");
5230 std::vector<std::string> const& configs =
5231 this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
5232 auto std_prop = this->GetProperty("CXX_MODULE_STD");
5233 if (!std_prop) {
5234 // TODO(cxxmodules): Add a target policy to flip the default here. Set
5235 // `std_prop` based on it.
5236 return true;
5237 }
5238
5239 std::string std_prop_value;
5240 if (std_prop) {
5241 // Evaluate generator expressions.
5242 cmGeneratorExpression ge(*this->LocalGenerator->GetCMakeInstance());
5243 auto cge = ge.Parse(*std_prop);
5244 if (!cge) {
5245 this->Makefile->IssueMessage(
5246 MessageType::FATAL_ERROR,
5247 cmStrCat(R"(The "CXX_MODULE_STD" property on the target ")",
5248 this->GetName(), "\" is not a valid generator expression."));
5249 return false;
5250 }
5251 // But do not allow context-sensitive queries. Whether a target uses
5252 // `import std` should not depend on configuration or properties of the
5253 // consumer (head target). The link language also shouldn't matter, so ban
5254 // it as well.
5255 if (cge->GetHadHeadSensitiveCondition()) {
5256 // Not reachable; all target-sensitive genexes actually fail to parse.
5257 this->Makefile->IssueMessage(
5258 MessageType::FATAL_ERROR,
5259 cmStrCat(R"(The "CXX_MODULE_STD" property on the target ")",
5260 this->GetName(),
5261 "\" contains a condition that queries the "
5262 "consuming target which is not supported."));
5263 return false;
5264 }
5265 if (cge->GetHadLinkLanguageSensitiveCondition()) {
5266 // Not reachable; all link language genexes actually fail to parse.
5267 this->Makefile->IssueMessage(
5268 MessageType::FATAL_ERROR,
5269 cmStrCat(R"(The "CXX_MODULE_STD" property on the target ")",
5270 this->GetName(),
5271 "\" contains a condition that queries the "
5272 "link language which is not supported."));
5273 return false;
5274 }
5275 std_prop_value = cge->Evaluate(this->LocalGenerator, "");
5276 if (cge->GetHadContextSensitiveCondition()) {
5277 this->Makefile->IssueMessage(
5278 MessageType::FATAL_ERROR,
5279 cmStrCat(R"(The "CXX_MODULE_STD" property on the target ")",
5280 this->GetName(),
5281 "\" contains a context-sensitive condition "
5282 "that is not supported."));

Callers 1

Calls 15

GetPropertyMethod · 0.95
HaveCxxModuleSupportMethod · 0.95
cmIsOnFunction · 0.85
CreateCxxStdlibTargetFunction · 0.85
GetGeneratorConfigsMethod · 0.80
GetLevelStringMethod · 0.80
FindTargetToUseMethod · 0.80
cmStrCatFunction · 0.70
LanguageStandardLevelMethod · 0.45
GetCMakeInstanceMethod · 0.45

Tested by

no test coverage detected