diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2002-07-10 18:34:38 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2002-07-10 18:34:38 (GMT) |
commit | 120b2523f5f37618baa10eeb9d480d2d2447b188 (patch) | |
tree | 172dff85f70822e6e48da0884f44aa55e3c31049 | |
parent | 32ad30e883bb8661d3fe5e6f0d969fc821c5f512 (diff) | |
download | CMake-120b2523f5f37618baa10eeb9d480d2d2447b188.zip CMake-120b2523f5f37618baa10eeb9d480d2d2447b188.tar.gz CMake-120b2523f5f37618baa10eeb9d480d2d2447b188.tar.bz2 |
Add command that runs program in given directory
-rw-r--r-- | Source/cmake.cxx | 27 |
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) |