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

Method EnableLanguage

Source/cmMakefile.cxx:3155–3210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3153}
3154
3155void cmMakefile::EnableLanguage(std::vector<std::string> const& languages,
3156 bool optional)
3157{
3158 if (this->DeferRunning) {
3159 this->IssueMessage(
3160 MessageType::FATAL_ERROR,
3161 "Languages may not be enabled during deferred execution.");
3162 return;
3163 }
3164 if (char const* def = this->GetGlobalGenerator()->GetCMakeCFGIntDir()) {
3165 this->AddDefinition("CMAKE_CFG_INTDIR", def);
3166 }
3167
3168 std::vector<std::string> unique_languages;
3169 {
3170 std::vector<std::string> duplicate_languages;
3171 for (std::string const& language : languages) {
3172 if (!cm::contains(unique_languages, language)) {
3173 unique_languages.push_back(language);
3174 } else if (!cm::contains(duplicate_languages, language)) {
3175 duplicate_languages.push_back(language);
3176 }
3177 }
3178 if (!duplicate_languages.empty()) {
3179 auto quantity = duplicate_languages.size() == 1 ? " has"_s : "s have"_s;
3180 this->IssueMessage(
3181 MessageType::AUTHOR_WARNING,
3182 cmStrCat("Languages to be enabled may not be specified more "
3183 "than once at the same time. The following language",
3184 quantity, " been specified multiple times: ",
3185 cmJoin(duplicate_languages, ", ")));
3186 }
3187 }
3188
3189 // If RC is explicitly listed we need to do it after other languages.
3190 // On some platforms we enable RC implicitly while enabling others.
3191 // Do not let that look like recursive enable_language(RC).
3192 std::vector<std::string> languages_without_RC;
3193 std::vector<std::string> languages_for_RC;
3194 languages_without_RC.reserve(unique_languages.size());
3195 for (std::string const& language : unique_languages) {
3196 if (language == "RC"_s) {
3197 languages_for_RC.push_back(language);
3198 } else {
3199 languages_without_RC.push_back(language);
3200 }
3201 }
3202 if (!languages_without_RC.empty()) {
3203 this->GetGlobalGenerator()->EnableLanguage(languages_without_RC, this,
3204 optional);
3205 }
3206 if (!languages_for_RC.empty()) {
3207 this->GetGlobalGenerator()->EnableLanguage(languages_for_RC, this,
3208 optional);
3209 }
3210}
3211
3212int cmMakefile::TryCompile(std::string const& srcdir,

Callers 2

cmEnableLanguageCommandFunction · 0.45
cmProjectCommandFunction · 0.45

Calls 10

IssueMessageMethod · 0.95
GetGlobalGeneratorMethod · 0.95
AddDefinitionMethod · 0.95
push_backMethod · 0.80
reserveMethod · 0.80
cmStrCatFunction · 0.70
cmJoinFunction · 0.70
GetCMakeCFGIntDirMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected