BUG: CMake crashed if it failed to find its own executable. Also added better error messages when this occurs.
This commit is contained in:
parent
c487718844
commit
a1a05a5fbc
|
@ -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
|
// 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.
|
// Find our own executable.
|
||||||
|
std::vector<cmStdString> failures;
|
||||||
std::string cMakeSelf = args[0];
|
std::string cMakeSelf = args[0];
|
||||||
cmSystemTools::ConvertToUnixSlashes(cMakeSelf);
|
cmSystemTools::ConvertToUnixSlashes(cMakeSelf);
|
||||||
|
failures.push_back(cMakeSelf);
|
||||||
cMakeSelf = cmSystemTools::FindProgram(cMakeSelf.c_str());
|
cMakeSelf = cmSystemTools::FindProgram(cMakeSelf.c_str());
|
||||||
if(!cmSystemTools::FileExists(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
|
#ifdef CMAKE_PREFIX
|
||||||
if(!cmSystemTools::FileExists(cMakeSelf.c_str()))
|
if(!cmSystemTools::FileExists(cMakeSelf.c_str()))
|
||||||
{
|
{
|
||||||
|
failures.push_back(cMakeSelf);
|
||||||
cMakeSelf = CMAKE_PREFIX "/bin/cmake";
|
cMakeSelf = CMAKE_PREFIX "/bin/cmake";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(!cmSystemTools::FileExists(cMakeSelf.c_str()))
|
if(!cmSystemTools::FileExists(cMakeSelf.c_str()))
|
||||||
{
|
{
|
||||||
cmSystemTools::Error("CMAKE can not find the command line program cmake. "
|
failures.push_back(cMakeSelf);
|
||||||
"Attempted path: ", cMakeSelf.c_str());
|
cmStringStream msg;
|
||||||
return;
|
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
|
// Save the value in the cache
|
||||||
cmCacheManager::GetInstance()->AddCacheEntry
|
cmCacheManager::GetInstance()->AddCacheEntry
|
||||||
|
@ -337,11 +349,12 @@ void cmake::AddCMakePaths(const std::vector<std::string>& args)
|
||||||
cmSystemTools::Error("Could not find CMAKE_ROOT !!!\n",
|
cmSystemTools::Error("Could not find CMAKE_ROOT !!!\n",
|
||||||
"Modules directory not in directory:\n",
|
"Modules directory not in directory:\n",
|
||||||
modules.c_str());
|
modules.c_str());
|
||||||
return;
|
return 0;
|
||||||
}
|
}
|
||||||
cmCacheManager::GetInstance()->AddCacheEntry
|
cmCacheManager::GetInstance()->AddCacheEntry
|
||||||
("CMAKE_ROOT", cMakeRoot.c_str(),
|
("CMAKE_ROOT", cMakeRoot.c_str(),
|
||||||
"Path to CMake installation.", cmCacheManager::INTERNAL);
|
"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
|
// setup CMAKE_ROOT and CMAKE_COMMAND
|
||||||
this->AddCMakePaths(args);
|
if(!this->AddCMakePaths(args))
|
||||||
|
{
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
// reset any system configuration information
|
// reset any system configuration information
|
||||||
cmMakefileGenerator::ClearEnabledLanguages();
|
cmMakefileGenerator::ClearEnabledLanguages();
|
||||||
|
|
|
@ -55,7 +55,7 @@ class cmake
|
||||||
/**
|
/**
|
||||||
* Generate CMAKE_ROOT and CMAKE_COMMAND cache entries
|
* Generate CMAKE_ROOT and CMAKE_COMMAND cache entries
|
||||||
*/
|
*/
|
||||||
void AddCMakePaths(const std::vector<std::string>&);
|
int AddCMakePaths(const std::vector<std::string>&);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* constructor
|
* constructor
|
||||||
|
|
Loading…
Reference in New Issue