Cleanly enable a language in multiple subdirectories

When a language is not enabled at the top level of a project but is
enabled in multiple disjoint subdirectories we should re-use the
CMake<lang>Compiler.cmake file from the first directory.  Load the file
whenever it exists and is not left from a different version of CMake.
This commit is contained in:
Brad King 2012-08-21 10:59:48 -04:00
parent 66cb3356f5
commit ec22a9b521
1 changed files with 13 additions and 11 deletions

View File

@ -376,6 +376,13 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
std::string loadedLang = "CMAKE_"; std::string loadedLang = "CMAKE_";
loadedLang += lang; loadedLang += lang;
loadedLang += "_COMPILER_LOADED"; loadedLang += "_COMPILER_LOADED";
if(!mf->GetDefinition(loadedLang.c_str()))
{
fpath = rootBin;
fpath += "/CMake";
fpath += lang;
fpath += "Compiler.cmake";
// If the existing build tree was already configured with this // If the existing build tree was already configured with this
// version of CMake then try to load the configured file first // version of CMake then try to load the configured file first
// to avoid duplicate compiler tests. // to avoid duplicate compiler tests.
@ -384,14 +391,9 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
unsigned int selfMajor = cmVersion::GetMajorVersion(); unsigned int selfMajor = cmVersion::GetMajorVersion();
unsigned int selfMinor = cmVersion::GetMinorVersion(); unsigned int selfMinor = cmVersion::GetMinorVersion();
if((this->CMakeInstance->GetIsInTryCompile() || if((this->CMakeInstance->GetIsInTryCompile() ||
(selfMajor == cacheMajor && selfMinor == cacheMinor)) (cacheMajor == 0 && cacheMinor == 0) ||
&& !mf->GetDefinition(loadedLang.c_str())) (selfMajor == cacheMajor && selfMinor == cacheMinor)) &&
{ cmSystemTools::FileExists(fpath.c_str()))
fpath = rootBin;
fpath += "/CMake";
fpath += lang;
fpath += "Compiler.cmake";
if(cmSystemTools::FileExists(fpath.c_str()))
{ {
if(!mf->ReadListFile(0,fpath.c_str())) if(!mf->ReadListFile(0,fpath.c_str()))
{ {