summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
authorKen Martin <ken.martin@kitware.com>2002-06-03 17:08:52 (GMT)
committerKen Martin <ken.martin@kitware.com>2002-06-03 17:08:52 (GMT)
commit350f09ae6d267806051873027d47af64dab81547 (patch)
treec95550ea1645b93a2445989855d2be22da11e0de /Source/cmake.cxx
parent5a286f1c90d7dc04188bd3b2f0aa0b9320462f89 (diff)
downloadCMake-350f09ae6d267806051873027d47af64dab81547.zip
CMake-350f09ae6d267806051873027d47af64dab81547.tar.gz
CMake-350f09ae6d267806051873027d47af64dab81547.tar.bz2
removed ccommand use cmake now
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx128
1 files changed, 115 insertions, 13 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 6fef849..a24ddde 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -15,6 +15,7 @@
=========================================================================*/
#include "cmake.h"
+#include "time.h"
#include "cmCacheManager.h"
// include the generator
@@ -230,8 +231,15 @@ void cmake::AddCMakePaths(const std::vector<std::string>& args)
if(!cmSystemTools::FileExists(cMakeSelf.c_str()))
{
#ifdef CMAKE_BUILD_DIR
- cMakeSelf = CMAKE_BUILD_DIR;
- cMakeSelf += "/Source/cmake";
+ std::string intdir = ".";
+#ifdef CMAKE_INTDIR
+ intdir = CMAKE_INTDIR;
+#endif
+ cMakeSelf = CMAKE_BUILD_DIR;
+ cMakeSelf += "/Source/";
+ cMakeSelf += intdir;
+ cMakeSelf += "/cmake";
+ cMakeSelf += cmSystemTools::GetExecutableExtension();
#endif
}
#ifdef CMAKE_PREFIX
@@ -251,17 +259,6 @@ void cmake::AddCMakePaths(const std::vector<std::string>& args)
("CMAKE_COMMAND",cMakeSelf.c_str(), "Path to CMake executable.",
cmCacheManager::INTERNAL);
- // Find ccommand
- std::string cCommand = cmSystemTools::GetFilenamePath(cMakeSelf) +
- "/ccommand" + cmSystemTools::GetFilenameExtension(cMakeSelf);
- if( cmSystemTools::FileExists(cCommand.c_str()))
- {
- // Save the value in the cache
- cmCacheManager::GetInstance()->AddCacheEntry
- ("CCOMMAND_COMMAND",cCommand.c_str(),
- "Path to CMakeCommand executable.", cmCacheManager::INTERNAL);
- }
-
// Find and save the command to edit the cache
std::string editCacheCommand = cmSystemTools::GetFilenamePath(cMakeSelf) +
"/ccmake" + cmSystemTools::GetFilenameExtension(cMakeSelf);
@@ -519,3 +516,108 @@ int cmake::Generate(const std::vector<std::string>& args, bool buildMakefiles)
return 0;
}
+
+void CMakeCommandUsage(const char* program)
+{
+ std::strstream errorStream;
+
+ errorStream
+ << "cmake version " << cmMakefile::GetMajorVersion()
+ << "." << cmMakefile::GetMinorVersion() << "\n";
+
+ errorStream
+ << "Usage: " << program << " -E [command] [arguments ...]\n"
+ << "Available commands: \n"
+ << " copy file destination - copy file to destination (either file or directory)\n"
+ << " remove file1 file2 ... - remove the file(s)\n"
+ << " time command [args] ... - run command and return elapsed time\n"
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ << " write_regv key value - write registry value\n"
+ << " delete_regv key - delete registry value\n"
+#endif
+ << std::ends;
+
+ cmSystemTools::Error(errorStream.str());
+}
+
+int cmake::CMakeCommand(std::vector<std::string>& args)
+{
+ if (args.size() > 1)
+ {
+ // Copy file
+ if (args[1] == "copy" && args.size() == 4)
+ {
+ cmSystemTools::cmCopyFile(args[2].c_str(), args[3].c_str());
+ return cmSystemTools::GetErrorOccuredFlag();
+ }
+
+ // Remove file
+ else if (args[1] == "remove" && args.size() > 2)
+ {
+ for (std::string::size_type cc = 2; cc < args.size(); cc ++)
+ {
+ if(args[cc] != "-f")
+ {
+ if(args[cc] == "\\-f")
+ {
+ args[cc] = "-f";
+ }
+ cmSystemTools::RemoveFile(args[cc].c_str());
+ }
+ }
+ return 0;
+ }
+
+ // Clock command
+ else if (args[1] == "time" && args.size() > 2)
+ {
+ std::string command = args[2];
+ std::string output;
+ for (std::string::size_type cc = 3; cc < args.size(); cc ++)
+ {
+ command += " ";
+ command += args[cc];
+ }
+
+ clock_t clock_start, clock_finish;
+ time_t time_start, time_finish;
+
+ time(&time_start);
+ clock_start = clock();
+
+ cmSystemTools::RunCommand(command.c_str(), output, 0, true);
+
+ clock_finish = clock();
+ time(&time_finish);
+
+ std::cout << output.c_str();
+
+ double clocks_per_sec = (double)CLOCKS_PER_SEC;
+ std::cout << "Elapsed time: "
+ << (long)(time_finish - time_start) << " s. (time)"
+ << ", "
+ << (double)(clock_finish - clock_start) / clocks_per_sec
+ << " s. (clock)"
+ << "\n";
+ return 0;
+ }
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ // Write registry value
+ else if (args[1] == "write_regv" && args.size() > 3)
+ {
+ return cmSystemTools::WriteRegistryValue(args[2].c_str(),
+ args[3].c_str()) ? 0 : 1;
+ }
+
+ // Delete registry value
+ else if (args[1] == "delete_regv" && args.size() > 2)
+ {
+ return cmSystemTools::DeleteRegistryValue(args[2].c_str()) ? 0 : 1;
+ }
+#endif
+ }
+
+ ::CMakeCommandUsage(args[0].c_str());
+ return 1;
+}