enable_language: Initialize system-specific generator info only once

Call SetSystemName, SetGeneratorPlatform, and SetGeneratorToolset
exactly once after reading CMakeSystem.cmake, and not again on another
call to enable_language() or project().
This commit is contained in:
Brad King 2014-09-09 15:01:51 -04:00
parent 09ab207c66
commit 09c8ad9943
1 changed files with 24 additions and 20 deletions

View File

@ -438,7 +438,8 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
// try and load the CMakeSystem.cmake if it is there // try and load the CMakeSystem.cmake if it is there
std::string fpath = rootBin; std::string fpath = rootBin;
if(!mf->GetDefinition("CMAKE_SYSTEM_LOADED")) bool const readCMakeSystem = !mf->GetDefinition("CMAKE_SYSTEM_LOADED");
if(readCMakeSystem)
{ {
fpath += "/CMakeSystem.cmake"; fpath += "/CMakeSystem.cmake";
if(cmSystemTools::FileExists(fpath.c_str())) if(cmSystemTools::FileExists(fpath.c_str()))
@ -472,6 +473,8 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
mf->ReadListFile(0,fpath.c_str()); mf->ReadListFile(0,fpath.c_str());
} }
if(readCMakeSystem)
{
// Tell the generator about the target system. // Tell the generator about the target system.
std::string system = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME"); std::string system = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME");
if(!this->SetSystemName(system, mf)) if(!this->SetSystemName(system, mf))
@ -495,6 +498,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
cmSystemTools::SetFatalErrorOccured(); cmSystemTools::SetFatalErrorOccured();
return; return;
} }
}
// **** Load the system specific initialization if not yet loaded // **** Load the system specific initialization if not yet loaded
if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED")) if (!mf->GetDefinition("CMAKE_SYSTEM_SPECIFIC_INITIALIZE_LOADED"))