summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2007-12-13 22:56:50 (GMT)
committerBrad King <brad.king@kitware.com>2007-12-13 22:56:50 (GMT)
commit9f61e2a235fc04e57237dc932aee61b264ef8916 (patch)
tree482f697639a0e55198f198eaf67282f088dee202 /Source/cmake.cxx
parentebc036bbdaa602c9276ad91469a305b42fda7cbc (diff)
downloadCMake-9f61e2a235fc04e57237dc932aee61b264ef8916.zip
CMake-9f61e2a235fc04e57237dc932aee61b264ef8916.tar.gz
CMake-9f61e2a235fc04e57237dc932aee61b264ef8916.tar.bz2
ENH: Centralized and globalized computation of CMake program locations. This eliminates startup paths that failed to produce this information.
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx54
1 files changed, 7 insertions, 47 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index a3c95be..fd59808 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -739,56 +739,16 @@ void cmake::SetDirectoriesFromFile(const char* arg)
// at the end of this CMAKE_ROOT and CMAKE_COMMAND should be added to the
// cache
-int cmake::AddCMakePaths(const char *arg0)
+int cmake::AddCMakePaths()
{
// Find the cmake executable
- std::vector<cmStdString> failures;
- std::string cMakeSelf = arg0;
- cmSystemTools::ConvertToUnixSlashes(cMakeSelf);
- if ((strstr(arg0, "cpack")!=0) || (strstr(arg0, "ctest")!=0))
- {
- // when called from cpack or ctest CMAKE_COMMAND would otherwise point
- // to cpack or ctest and not cmake
- cMakeSelf = cmSystemTools::GetFilenamePath(cMakeSelf) +
- "/cmake" + cmSystemTools::GetFilenameExtension(cMakeSelf);
- }
- failures.push_back(cMakeSelf);
- cMakeSelf = cmSystemTools::FindProgram(cMakeSelf.c_str());
- cmSystemTools::ConvertToUnixSlashes(cMakeSelf);
- if(!cmSystemTools::FileExists(cMakeSelf.c_str()))
- {
-#ifdef CMAKE_BUILD_DIR
- std::string intdir = ".";
-#ifdef CMAKE_INTDIR
- intdir = CMAKE_INTDIR;
-#endif
- cMakeSelf = CMAKE_BUILD_DIR;
- cMakeSelf += "/bin/";
- cMakeSelf += intdir;
+ std::string cMakeSelf = cmSystemTools::GetExecutableDirectory();
cMakeSelf += "/cmake";
cMakeSelf += cmSystemTools::GetExecutableExtension();
-#endif
- }
-#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()))
- {
- failures.push_back(cMakeSelf);
- cmOStringStream msg;
- msg << "CMAKE can not find the command line program cmake.\n";
- msg << " argv[0] = \"" << arg0 << "\"\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());
+ cmSystemTools::Error("CMake executable cannot be found at ",
+ cMakeSelf.c_str());
return 0;
}
// Save the value in the cache
@@ -2157,7 +2117,7 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
}
else
{
- this->AddCMakePaths(this->CMakeCommand.c_str());
+ this->AddCMakePaths();
}
// Add any cache args
@@ -2376,7 +2336,7 @@ int cmake::LoadCache()
}
// setup CMAKE_ROOT and CMAKE_COMMAND
- if(!this->AddCMakePaths(this->CMakeCommand.c_str()))
+ if(!this->AddCMakePaths())
{
return -3;
}
@@ -3503,7 +3463,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
// we have to find the module directory, so we can copy the files
- this->AddCMakePaths(args[0].c_str());
+ this->AddCMakePaths();
std::string modulesPath =
this->CacheManager->GetCacheValue("CMAKE_ROOT");
modulesPath += "/Modules";