diff options
author | Brad King <brad.king@kitware.com> | 2002-06-27 13:35:21 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2002-06-27 13:35:21 (GMT) |
commit | a1a05a5fbcd0d34aa5ab0dde7da2ba4c5082916a (patch) | |
tree | e98b4f523cb584062eef5f86213ab9a448d70c83 /Source/cmake.cxx | |
parent | c48771884467ab1c43dfc80c20c4fccc5a73df68 (diff) | |
download | CMake-a1a05a5fbcd0d34aa5ab0dde7da2ba4c5082916a.zip CMake-a1a05a5fbcd0d34aa5ab0dde7da2ba4c5082916a.tar.gz CMake-a1a05a5fbcd0d34aa5ab0dde7da2ba4c5082916a.tar.bz2 |
BUG: CMake crashed if it failed to find its own executable. Also added better error messages when this occurs.
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r-- | Source/cmake.cxx | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx index b93a62c..dad04ba 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -222,11 +222,13 @@ void cmake::SetArgs(cmMakefile& builder, const std::vector<std::string>& args) } // at the end of this CMAKE_ROOT and CMAKE_COMMAND should be added to the cache -void cmake::AddCMakePaths(const std::vector<std::string>& args) +int cmake::AddCMakePaths(const std::vector<std::string>& args) { // Find our own executable. + std::vector<cmStdString> failures; std::string cMakeSelf = args[0]; cmSystemTools::ConvertToUnixSlashes(cMakeSelf); + failures.push_back(cMakeSelf); cMakeSelf = cmSystemTools::FindProgram(cMakeSelf.c_str()); if(!cmSystemTools::FileExists(cMakeSelf.c_str())) { @@ -245,14 +247,24 @@ void cmake::AddCMakePaths(const std::vector<std::string>& args) #ifdef CMAKE_PREFIX if(!cmSystemTools::FileExists(cMakeSelf.c_str())) { + failures.push_back(cMakeSelf); cMakeSelf = CMAKE_PREFIX "/bin/cmake"; } #endif if(!cmSystemTools::FileExists(cMakeSelf.c_str())) { - cmSystemTools::Error("CMAKE can not find the command line program cmake. " - "Attempted path: ", cMakeSelf.c_str()); - return; + failures.push_back(cMakeSelf); + cmStringStream msg; + msg << "CMAKE can not find the command line program cmake.\n"; + msg << " argv[0] = \"" << args[0].c_str() << "\"\n"; + msg << " Attempted paths:\n"; + std::vector<cmStdString>::iterator i; + for(i=failures.begin(); i != failures.end(); ++i) + { + msg << " \"" << i->c_str() << "\"\n"; + } + cmSystemTools::Error(msg.str().c_str()); + return 0; } // Save the value in the cache cmCacheManager::GetInstance()->AddCacheEntry @@ -337,11 +349,12 @@ void cmake::AddCMakePaths(const std::vector<std::string>& args) cmSystemTools::Error("Could not find CMAKE_ROOT !!!\n", "Modules directory not in directory:\n", modules.c_str()); - return; + return 0; } cmCacheManager::GetInstance()->AddCacheEntry ("CMAKE_ROOT", cMakeRoot.c_str(), "Path to CMake installation.", cmCacheManager::INTERNAL); + return 1; } @@ -452,7 +465,10 @@ int cmake::Generate(const std::vector<std::string>& args, bool buildMakefiles) // setup CMAKE_ROOT and CMAKE_COMMAND - this->AddCMakePaths(args); + if(!this->AddCMakePaths(args)) + { + return -3; + } // reset any system configuration information cmMakefileGenerator::ClearEnabledLanguages(); |