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

Method GetCompileOptionDef

Source/cmStandardLevelResolver.cxx:74–239  ·  view source on GitHub ↗

Note that the logic here is shadowed in `GetEffectiveStandard`; if one is changed, the other needs changed as well.

Source from the content-addressed store, hash-verified

72 // Note that the logic here is shadowed in `GetEffectiveStandard`; if one is
73 // changed, the other needs changed as well.
74 std::string GetCompileOptionDef(cmMakefile* makefile,
75 cmGeneratorTarget const* target,
76 std::string const& config) const
77 {
78
79 auto const& stds = this->Levels;
80 auto const& stdsStrings = this->LevelsAsStrings;
81
82 cmValue defaultStd = makefile->GetDefinition(
83 cmStrCat("CMAKE_", this->Language, "_STANDARD_DEFAULT"));
84 if (!cmNonempty(defaultStd)) {
85 // this compiler has no notion of language standard levels
86 return std::string{};
87 }
88
89 cmPolicies::PolicyStatus const cmp0128{ makefile->GetPolicyStatus(
90 cmPolicies::CMP0128) };
91 bool const defaultExt{ makefile
92 ->GetDefinition(cmStrCat("CMAKE_", this->Language,
93 "_EXTENSIONS_DEFAULT"))
94 .IsOn() };
95 bool ext = true;
96
97 if (cmp0128 == cmPolicies::NEW) {
98 ext = defaultExt;
99 }
100
101 if (cmValue extPropValue = target->GetLanguageExtensions(this->Language)) {
102 ext = extPropValue.IsOn();
103 }
104
105 std::string const type{ ext ? "EXTENSION" : "STANDARD" };
106
107 cmValue standardProp = target->GetLanguageStandard(this->Language, config);
108 if (!standardProp) {
109 if (cmp0128 == cmPolicies::NEW) {
110 // Add extension flag if compiler's default doesn't match.
111 if (ext != defaultExt) {
112 return cmStrCat("CMAKE_", this->Language, *defaultStd, '_', type,
113 "_COMPILE_OPTION");
114 }
115 } else {
116 if (cmp0128 == cmPolicies::WARN &&
117 makefile->PolicyOptionalWarningEnabled(
118 "CMAKE_POLICY_WARNING_CMP0128") &&
119 ext != defaultExt) {
120 char const* state{};
121 if (ext) {
122 if (!makefile->GetDefinition(cmStrCat(
123 "CMAKE_", this->Language, "_EXTENSION_COMPILE_OPTION"))) {
124 state = "enabled";
125 }
126 } else {
127 state = "disabled";
128 }
129 if (state) {
130 makefile->IssueMessage(
131 MessageType::AUTHOR_WARNING,

Callers

nothing calls this directly

Calls 15

cmNonemptyFunction · 0.85
ParseStdFunction · 0.85
GetLanguageExtensionsMethod · 0.80
GetLanguageStandardMethod · 0.80
strMethod · 0.80
cmStrCatFunction · 0.70
findFunction · 0.50
GetDefinitionMethod · 0.45
GetPolicyStatusMethod · 0.45
IsOnMethod · 0.45

Tested by

no test coverage detected