Add command that runs program in given directory
This commit is contained in:
parent
32ad30e883
commit
120b2523f5
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue