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