summaryrefslogtreecommitdiffstats
path: root/Source/cmake.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmake.cxx')
-rw-r--r--Source/cmake.cxx27
1 files changed, 27 insertions, 0 deletions
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index dad04ba..fdfc11f 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -544,6 +544,7 @@ void CMakeCommandUsage(const char* program)
errorStream
<< "Usage: " << program << " -E [command] [arguments ...]\n"
<< "Available commands: \n"
+ << " chdir dir cmd [args]... - run command in a given directory\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";
@@ -618,6 +619,32 @@ int cmake::CMakeCommand(std::vector<std::string>& args)
return 0;
}
+ // Clock command
+ else if (args[1] == "chdir" && args.size() > 2)
+ {
+ std::string directory = args[2];
+ std::string command = args[3];
+ std::string output;
+ for (std::string::size_type cc = 4; cc < args.size(); cc ++)
+ {
+ command += " ";
+ command += args[cc];
+ }
+
+ if ( cmSystemTools::ChangeDirectory( directory.c_str() ) == 0 )
+ {
+ std::cout << "Change directory to: " << directory << std::endl;
+ cmSystemTools::RunCommand(command.c_str(), output, 0, true);
+ std::cout << output.c_str();
+ }
+ else
+ {
+ std::cout << "Cannot change directory to: " << directory << std::endl;
+ }
+
+ return 0;
+ }
+
#if defined(_WIN32) && !defined(__CYGWIN__)
// Write registry value
else if (args[1] == "write_regv" && args.size() > 3)