Browse Source

ENH: When the initially configured generator is invalid, allow the user to change the generator without deleting the cache by hand.

Brad King 22 years ago
parent
commit
20b198835c
2 changed files with 13 additions and 5 deletions
  1. 5 5
      Source/cmGlobalGenerator.cxx
  2. 8 0
      Source/cmake.cxx

+ 5 - 5
Source/cmGlobalGenerator.cxx

@@ -57,11 +57,11 @@ void cmGlobalGenerator::EnableLanguage(const char* lang,
   if(!mf->GetDefinition("CMAKE_MAKE_PROGRAM")
      || cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM")))
     {
-    cmSystemTools::Error("CMake was unable to find a build program "
-                         "corresponding to the generator you have selected.  "
-                         "CMAKE_MAKE_PROGRAM is not set.  You probably "
-                         "need to re-run CMake and select a different "
-                         "generator.");
+    cmOStringStream err;
+    err << "CMake was unable to find a build program corresponding to \""
+        << this->GetName() << "\".  CMAKE_MAKE_PROGRAM is not set.  You "
+        << "probably need to select a different build tool.";
+    cmSystemTools::Error(err.str().c_str());
     cmSystemTools::SetFatalErrorOccured();
     return;
     }

+ 8 - 0
Source/cmake.cxx

@@ -890,6 +890,14 @@ int cmake::Configure()
                                   cmCacheManager::PATH);
     }  
   
+  if(cmSystemTools::GetFatalErrorOccured() &&
+     (!this->m_CacheManager->GetCacheValue("CMAKE_MAKE_PROGRAM") ||
+      cmSystemTools::IsOff(this->m_CacheManager->GetCacheValue("CMAKE_MAKE_PROGRAM"))))
+    {
+    // We must have a bad generator selection.  Wipe the cache entry so the
+    // user can select another.
+    m_CacheManager->RemoveCacheEntry("CMAKE_GENERATOR");
+    }
   this->m_CacheManager->SaveCache(this->GetHomeOutputDirectory());
   if(cmSystemTools::GetErrorOccuredFlag())
     {