Browse Source

ENH: remove abort calls and replace with an IssueMessage INTERANL_ERROR, better to not crash on the end user.

Bill Hoffman 17 years ago
parent
commit
5ab6c0f0ed

+ 4 - 1
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -1915,7 +1915,10 @@ cmLocalUnixMakefileGenerator3
   // Make sure we never hit this old case.
   if(source.GetProperty("MACOSX_PACKAGE_LOCATION"))
     {
-    abort();
+    std::string msg = "MACOSX_PACKAGE_LOCATION set on source file: ";
+    msg += source.GetFullPath();
+    this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR,
+                                      msg.c_str());
     }
 
   // Start with the target directory.

+ 8 - 1
Source/cmMakefile.cxx

@@ -295,6 +295,11 @@ void cmMakefile::IssueMessage(cmake::MessageType t,
     isError = true;
     msg << "CMake Error:";
     }
+  else if(t == cmake::INTERNAL_ERROR)
+    {
+    isError = true;
+    msg << "CMake Internal Error, please report a bug: ";
+    }
   else
     {
     msg << "CMake Warning";
@@ -2029,7 +2034,9 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source,
       {
       // This case should never be called.  At-only is for
       // configure-file/string which always does no escapes.
-      abort();
+      this->IssueMessage(cmake::INTERNAL_ERROR,
+                         "ExpandVariablesInString @ONLY called "
+                         "on something with escapes.");
       }
 
     // Store an original copy of the input.

+ 7 - 1
Source/cmSourceFileLocation.cxx

@@ -173,7 +173,13 @@ bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc)
     // Each side has a directory relative to a different location.
     // This can occur when referencing a source file from a different
     // directory.  This is not yet allowed.
-    abort();
+    this->Makefile->
+      IssueMessage(cmake::INTERNAL_ERROR,
+                   "Matches error: Each side has a directory relative to a different"
+                   " location. This can occur when referencing a "
+                   "source file from a different directory.  "
+                   "This is not yet allowed.");
+    return false;
     }
   else if(this->AmbiguousDirectory)
     {

+ 32 - 6
Source/cmTarget.cxx

@@ -643,7 +643,11 @@ void cmTarget::SetType(TargetType type, const char* name)
      type == cmTarget::INSTALL_PROGRAMS ||
      type == cmTarget::INSTALL_DIRECTORY)
     {
-    abort();
+    this->Makefile->
+      IssueMessage(cmake::INTERNAL_ERROR,
+                   "SetType called on cmTarget for INSTALL_FILES, "
+                   "INSTALL_PROGRAMS, or INSTALL_DIRECTORY ");
+    return;
     }
   // only add dependency information for library targets
   this->TargetTypeValue = type;
@@ -2099,7 +2103,11 @@ std::string cmTarget::NormalGetRealName(const char* config)
   // enforcement of the limited imported target API.
   if(this->IsImported())
     {
-    abort();
+    std::string msg =  "NormalGetRealName called on imported target: ";
+    msg += this->GetName();
+    this->GetMakefile()->
+      IssueMessage(cmake::INTERNAL_ERROR,
+                   msg.c_str());
     }
 
   if(this->GetType() == cmTarget::EXECUTABLE)
@@ -2424,7 +2432,11 @@ void cmTarget::GetLibraryNamesInternal(std::string& name,
   // enforcement of the limited imported target API.
   if(this->IsImported())
     {
-    abort();
+    std::string msg =  "GetLibraryNamesInternal called on imported target: ";
+    msg += this->GetName();
+    this->Makefile->IssueMessage(cmake::INTERNAL_ERROR,
+                                 msg.c_str());
+    return;
     }
 
   // Construct the name of the soname flag variable for this language.
@@ -2553,7 +2565,11 @@ void cmTarget::GetExecutableNamesInternal(std::string& name,
   // enforcement of the limited imported target API.
   if(this->IsImported())
     {
-    abort();
+    std::string msg =  "GetExecutableNamesInternal called on imported target: ";
+    msg += this->GetName();
+    this->GetMakefile()->
+      IssueMessage(cmake::INTERNAL_ERROR,
+                   msg.c_str());
     }
 
   // This versioning is supported only for executables and then only
@@ -2828,11 +2844,21 @@ const char* cmTarget::GetAndCreateOutputDir(bool implib, bool create)
   if(implib &&
      !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX"))
     {
-    abort();
+    std::string msg =  "GetAndCreateOutputDir, imlib set but there is no "
+      "CMAKE_IMPORT_LIBRARY_SUFFIX for target: ";
+    msg += this->GetName();
+    this->GetMakefile()->
+      IssueMessage(cmake::INTERNAL_ERROR,
+                   msg.c_str());
     }
   if(implib && !this->DLLPlatform)
     {
-    abort();
+    std::string msg =  "implib set for platform that does not "
+      " support DLL's for target: ";
+    msg += this->GetName();
+    this->GetMakefile()->
+      IssueMessage(cmake::INTERNAL_ERROR,
+                   msg.c_str());
     }
 
   // Select whether we are constructing the directory for the main

+ 1 - 0
Source/cmake.h

@@ -61,6 +61,7 @@ class cmake
   enum MessageType
   { AUTHOR_WARNING,
     FATAL_ERROR,
+    INTERNAL_ERROR,
     MESSAGE,
     WARNING,
     LOG