summaryrefslogtreecommitdiff
path: root/Source/cmGlobalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2011-01-26 15:25:18 -0500
committerCMake Topic Stage <kwrobot@kitware.com>2011-01-26 15:25:18 -0500
commit833b8aa902f765601ea3209e39bbacf574a77432 (patch)
tree407cfa750ab1cbc2b8bbdf68279831ddaaf7cbaa /Source/cmGlobalGenerator.cxx
parent7f37eac6dd7f26c33b0c80b99f862ac0f53e6a8e (diff)
parentc83a834d29965e245e1e93fcda0e98e58e775f9f (diff)
downloadcmake-833b8aa902f765601ea3209e39bbacf574a77432.tar.gz
Merge topic 'recursive-CMAKE_USER_MAKE_RULES_OVERRIDE'
c83a834 try_compile: Allow only languages loaded in caller (#11469)
Diffstat (limited to 'Source/cmGlobalGenerator.cxx')
-rw-r--r--Source/cmGlobalGenerator.cxx44
1 files changed, 34 insertions, 10 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 123ab5ea20..6c8938e5d3 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -56,6 +56,7 @@ cmGlobalGenerator::cmGlobalGenerator()
this->ExtraGenerator = 0;
this->CurrentLocalGenerator = 0;
+ this->TryCompileOuterMakefile = 0;
}
cmGlobalGenerator::~cmGlobalGenerator()
@@ -199,6 +200,34 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
cmSystemTools::SetFatalErrorOccured();
return;
}
+
+ if(this->TryCompileOuterMakefile)
+ {
+ // In a try-compile we can only enable languages provided by caller.
+ for(std::vector<std::string>::const_iterator li = languages.begin();
+ li != languages.end(); ++li)
+ {
+ if(*li == "NONE")
+ {
+ this->SetLanguageEnabled("NONE", mf);
+ }
+ else
+ {
+ const char* lang = li->c_str();
+ if(this->LanguagesReady.find(lang) == this->LanguagesReady.end())
+ {
+ cmOStringStream e;
+ e << "The test project needs language "
+ << lang << " which is not enabled.";
+ this->TryCompileOuterMakefile
+ ->IssueMessage(cmake::FATAL_ERROR, e.str());
+ cmSystemTools::SetFatalErrorOccured();
+ return;
+ }
+ }
+ }
+ }
+
mf->AddDefinition("RUN_CONFIGURE", true);
std::string rootBin = mf->GetHomeOutputDirectory();
rootBin += cmake::GetCMakeFilesDirectory();
@@ -208,15 +237,6 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
// files from the parent cmake bin dir, into the try compile bin dir
if(this->ConfiguredFilesPath.size())
{
- for(std::vector<std::string>::const_iterator l = languages.begin();
- l != languages.end(); ++l)
- {
- if(*l == "NONE")
- {
- this->SetLanguageEnabled("NONE", mf);
- break;
- }
- }
rootBin = this->ConfiguredFilesPath;
}
@@ -421,6 +441,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
{
this->SetLanguageEnabledMaps(lang, mf);
}
+ this->LanguagesReady.insert(lang);
std::string compilerName = "CMAKE_";
compilerName += lang;
@@ -1333,9 +1354,11 @@ cmLocalGenerator *cmGlobalGenerator::CreateLocalGenerator()
return lg;
}
-void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen )
+void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen,
+ cmMakefile* mf)
{
this->SetConfiguredFilesPath(gen);
+ this->TryCompileOuterMakefile = mf;
const char* make =
gen->GetCMakeInstance()->GetCacheDefinition("CMAKE_MAKE_PROGRAM");
this->GetCMakeInstance()->AddCacheEntry("CMAKE_MAKE_PROGRAM", make,
@@ -1343,6 +1366,7 @@ void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen )
cmCacheManager::FILEPATH);
// copy the enabled languages
this->LanguageEnabled = gen->LanguageEnabled;
+ this->LanguagesReady = gen->LanguagesReady;
this->ExtensionToLanguage = gen->ExtensionToLanguage;
this->IgnoreExtensions = gen->IgnoreExtensions;
this->LanguageToOutputExtension = gen->LanguageToOutputExtension;