Merge topic 'recursive-CMAKE_USER_MAKE_RULES_OVERRIDE'
c83a834
try_compile: Allow only languages loaded in caller (#11469)
This commit is contained in:
commit
833b8aa902
|
@ -56,6 +56,7 @@ cmGlobalGenerator::cmGlobalGenerator()
|
||||||
|
|
||||||
this->ExtraGenerator = 0;
|
this->ExtraGenerator = 0;
|
||||||
this->CurrentLocalGenerator = 0;
|
this->CurrentLocalGenerator = 0;
|
||||||
|
this->TryCompileOuterMakefile = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cmGlobalGenerator::~cmGlobalGenerator()
|
cmGlobalGenerator::~cmGlobalGenerator()
|
||||||
|
@ -199,6 +200,34 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
|
||||||
cmSystemTools::SetFatalErrorOccured();
|
cmSystemTools::SetFatalErrorOccured();
|
||||||
return;
|
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);
|
mf->AddDefinition("RUN_CONFIGURE", true);
|
||||||
std::string rootBin = mf->GetHomeOutputDirectory();
|
std::string rootBin = mf->GetHomeOutputDirectory();
|
||||||
rootBin += cmake::GetCMakeFilesDirectory();
|
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
|
// files from the parent cmake bin dir, into the try compile bin dir
|
||||||
if(this->ConfiguredFilesPath.size())
|
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;
|
rootBin = this->ConfiguredFilesPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,6 +441,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
|
||||||
{
|
{
|
||||||
this->SetLanguageEnabledMaps(lang, mf);
|
this->SetLanguageEnabledMaps(lang, mf);
|
||||||
}
|
}
|
||||||
|
this->LanguagesReady.insert(lang);
|
||||||
|
|
||||||
std::string compilerName = "CMAKE_";
|
std::string compilerName = "CMAKE_";
|
||||||
compilerName += lang;
|
compilerName += lang;
|
||||||
|
@ -1333,9 +1354,11 @@ cmLocalGenerator *cmGlobalGenerator::CreateLocalGenerator()
|
||||||
return lg;
|
return lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen )
|
void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen,
|
||||||
|
cmMakefile* mf)
|
||||||
{
|
{
|
||||||
this->SetConfiguredFilesPath(gen);
|
this->SetConfiguredFilesPath(gen);
|
||||||
|
this->TryCompileOuterMakefile = mf;
|
||||||
const char* make =
|
const char* make =
|
||||||
gen->GetCMakeInstance()->GetCacheDefinition("CMAKE_MAKE_PROGRAM");
|
gen->GetCMakeInstance()->GetCacheDefinition("CMAKE_MAKE_PROGRAM");
|
||||||
this->GetCMakeInstance()->AddCacheEntry("CMAKE_MAKE_PROGRAM", make,
|
this->GetCMakeInstance()->AddCacheEntry("CMAKE_MAKE_PROGRAM", make,
|
||||||
|
@ -1343,6 +1366,7 @@ void cmGlobalGenerator::EnableLanguagesFromGenerator(cmGlobalGenerator *gen )
|
||||||
cmCacheManager::FILEPATH);
|
cmCacheManager::FILEPATH);
|
||||||
// copy the enabled languages
|
// copy the enabled languages
|
||||||
this->LanguageEnabled = gen->LanguageEnabled;
|
this->LanguageEnabled = gen->LanguageEnabled;
|
||||||
|
this->LanguagesReady = gen->LanguagesReady;
|
||||||
this->ExtensionToLanguage = gen->ExtensionToLanguage;
|
this->ExtensionToLanguage = gen->ExtensionToLanguage;
|
||||||
this->IgnoreExtensions = gen->IgnoreExtensions;
|
this->IgnoreExtensions = gen->IgnoreExtensions;
|
||||||
this->LanguageToOutputExtension = gen->LanguageToOutputExtension;
|
this->LanguageToOutputExtension = gen->LanguageToOutputExtension;
|
||||||
|
|
|
@ -79,7 +79,8 @@ public:
|
||||||
/**
|
/**
|
||||||
* Try to determine system infomation, get it from another generator
|
* Try to determine system infomation, get it from another generator
|
||||||
*/
|
*/
|
||||||
virtual void EnableLanguagesFromGenerator(cmGlobalGenerator *gen);
|
virtual void EnableLanguagesFromGenerator(cmGlobalGenerator *gen,
|
||||||
|
cmMakefile* mf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Try running cmake and building a file. This is used for dynalically
|
* Try running cmake and building a file. This is used for dynalically
|
||||||
|
@ -325,11 +326,13 @@ protected:
|
||||||
virtual bool UseFolderProperty();
|
virtual bool UseFolderProperty();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
cmMakefile* TryCompileOuterMakefile;
|
||||||
float FirstTimeProgress;
|
float FirstTimeProgress;
|
||||||
// If you add a new map here, make sure it is copied
|
// If you add a new map here, make sure it is copied
|
||||||
// in EnableLanguagesFromGenerator
|
// in EnableLanguagesFromGenerator
|
||||||
std::map<cmStdString, bool> IgnoreExtensions;
|
std::map<cmStdString, bool> IgnoreExtensions;
|
||||||
std::map<cmStdString, bool> LanguageEnabled;
|
std::map<cmStdString, bool> LanguageEnabled;
|
||||||
|
std::set<cmStdString> LanguagesReady; // Ready for try_compile
|
||||||
std::map<cmStdString, cmStdString> OutputExtensions;
|
std::map<cmStdString, cmStdString> OutputExtensions;
|
||||||
std::map<cmStdString, cmStdString> LanguageToOutputExtension;
|
std::map<cmStdString, cmStdString> LanguageToOutputExtension;
|
||||||
std::map<cmStdString, cmStdString> ExtensionToLanguage;
|
std::map<cmStdString, cmStdString> ExtensionToLanguage;
|
||||||
|
|
|
@ -2737,7 +2737,7 @@ int cmMakefile::TryCompile(const char *srcdir, const char *bindir,
|
||||||
}
|
}
|
||||||
// to save time we pass the EnableLanguage info directly
|
// to save time we pass the EnableLanguage info directly
|
||||||
gg->EnableLanguagesFromGenerator
|
gg->EnableLanguagesFromGenerator
|
||||||
(this->LocalGenerator->GetGlobalGenerator());
|
(this->LocalGenerator->GetGlobalGenerator(), this);
|
||||||
if(this->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS"))
|
if(this->IsOn("CMAKE_SUPPRESS_DEVELOPER_WARNINGS"))
|
||||||
{
|
{
|
||||||
cm.AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS",
|
cm.AddCacheEntry("CMAKE_SUPPRESS_DEVELOPER_WARNINGS",
|
||||||
|
|
Loading…
Reference in New Issue