From ec22a9b5217c2110db9af1791a61a7552144f028 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 21 Aug 2012 10:59:48 -0400 Subject: [PATCH] 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 CMakeCompiler.cmake file from the first directory. Load the file whenever it exists and is not left from a different version of CMake. --- Source/cmGlobalGenerator.cxx | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index a47ca3677..52b451cd0 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -376,22 +376,24 @@ cmGlobalGenerator::EnableLanguage(std::vectorconst& 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())) {