summaryrefslogtreecommitdiff
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2003-12-08 11:31:16 -0500
committerBrad King <brad.king@kitware.com>2003-12-08 11:31:16 -0500
commit306fc9ea96d56a795b52f04d31ac3f7c800839a3 (patch)
tree60bf234493620a6863c358e8373c26f02068113e /Source/cmake.cxx
parent403f220d25b99ccdf0ceef87ef5f669a047d31cd (diff)
downloadcmake-306fc9ea96d56a795b52f04d31ac3f7c800839a3.tar.gz
ENH: Improved error messages when source tree does not have a CMakeLists.txt file. No matter how many cases we check, there always seems to be a user that finds a case that gives a confusing error message...
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx38
1 files changed, 34 insertions, 4 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 1202835d25..133d71d663 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -392,7 +392,24 @@ void cmake::SetDirectoriesFromFile(const char* arg)
listPath = cmSystemTools::GetFilenamePath(fullPath.c_str());
}
}
-
+ else
+ {
+ // Specified file or directory does not exist. Try to set things
+ // up to produce a meaningful error message.
+ std::string fullPath = cmSystemTools::CollapseFullPath(arg);
+ std::string name = cmSystemTools::GetFilenameName(fullPath.c_str());
+ name = cmSystemTools::LowerCase(name);
+ if(name == "cmakecache.txt" || name == "cmakelists.txt")
+ {
+ argIsFile = true;
+ listPath = cmSystemTools::GetFilenamePath(fullPath.c_str());
+ }
+ else
+ {
+ listPath = fullPath;
+ }
+ }
+
// If there is a CMakeCache.txt file, use its settings.
if(cachePath.length() > 0)
{
@@ -880,9 +897,22 @@ int cmake::DoPreConfigureChecks()
if(!cmSystemTools::FileExists(srcList.c_str()))
{
cmOStringStream err;
- err << "The source directory \"" << this->GetHomeDirectory()
- << "\" does not appear to contain CMakeLists.txt.\n"
- << "Specify --help for usage, or press the help button on the CMake GUI.";
+ if(cmSystemTools::FileIsDirectory(this->GetHomeDirectory()))
+ {
+ err << "The source directory \"" << this->GetHomeDirectory()
+ << "\" does not appear to contain CMakeLists.txt.\n";
+ }
+ else if(cmSystemTools::FileExists(this->GetHomeDirectory()))
+ {
+ err << "The source directory \"" << this->GetHomeDirectory()
+ << "\" is a file, not a directory.\n";
+ }
+ else
+ {
+ err << "The source directory \"" << this->GetHomeDirectory()
+ << "\" does not exist.\n";
+ }
+ err << "Specify --help for usage, or press the help button on the CMake GUI.";
cmSystemTools::Error(err.str().c_str());
return -2;
}