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

Method EnableLanguage

Source/cmGlobalGenerator.cxx:512–993  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

510//
511
512void cmGlobalGenerator::EnableLanguage(
513 std::vector<std::string> const& languages, cmMakefile* mf, bool optional)
514{
515 if (!this->IsMultiConfig() &&
516 !this->GetCMakeInstance()->GetIsInTryCompile()) {
517 std::string envBuildType;
518 if (!mf->GetDefinition("CMAKE_BUILD_TYPE") &&
519 cmSystemTools::GetEnv("CMAKE_BUILD_TYPE", envBuildType)) {
520 mf->AddCacheDefinition(
521 "CMAKE_BUILD_TYPE", envBuildType,
522 "Choose the type of build. Options include: empty, "
523 "Debug, Release, RelWithDebInfo, MinSizeRel.",
524 cmStateEnums::STRING);
525 }
526 }
527
528 if (languages.empty()) {
529 cmSystemTools::Error("EnableLanguage must have a lang specified!");
530 cmSystemTools::SetFatalErrorOccurred();
531 return;
532 }
533
534 std::set<std::string> cur_languages(languages.begin(), languages.end());
535 for (std::string const& li : cur_languages) {
536 if (!this->LanguagesInProgress.insert(li).second) {
537 std::ostringstream e;
538 e << "Language '" << li
539 << "' is currently being enabled. "
540 "Recursive call not allowed.";
541 mf->IssueMessage(MessageType::FATAL_ERROR, e.str());
542 cmSystemTools::SetFatalErrorOccurred();
543 return;
544 }
545 }
546
547 if (this->TryCompileOuterMakefile) {
548 // In a try-compile we can only enable languages provided by caller.
549 for (std::string const& lang : languages) {
550 if (lang == "NONE") {
551 this->SetLanguageEnabled("NONE", mf);
552 } else {
553 if (!cm::contains(this->LanguagesReady, lang)) {
554 std::ostringstream e;
555 e << "The test project needs language " << lang
556 << " which is not enabled.";
557 this->TryCompileOuterMakefile->IssueMessage(MessageType::FATAL_ERROR,
558 e.str());
559 cmSystemTools::SetFatalErrorOccurred();
560 return;
561 }
562 }
563 }
564 }
565
566 bool fatalError = false;
567
568 mf->AddDefinitionBool("RUN_CONFIGURE", true);
569 std::string rootBin =

Callers

nothing calls this directly

Calls 15

IsMultiConfigMethod · 0.95
GetCMakeInstanceMethod · 0.95
SetLanguageEnabledMethod · 0.95
SetGeneratorInstanceMethod · 0.95
SetSystemNameMethod · 0.95
SetGeneratorPlatformMethod · 0.95
SetGeneratorToolsetMethod · 0.95
FindMakeProgramMethod · 0.95
CheckLanguagesMethod · 0.95
GetLanguageEnabledMethod · 0.95
PrintCompilerAdviceMethod · 0.95

Tested by

no test coverage detected