diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2002-08-08 19:13:20 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2002-08-08 19:13:20 (GMT) |
commit | c41c7a6a9a78aef2d1eba25137b75329431a55b5 (patch) | |
tree | 8c60eefcc4bdc9ef906a475196b12cf5a221c5bd /Source/cmExecProgramCommand.cxx | |
parent | 930bed0f71079cfd2f71698d16947a3303144a9f (diff) | |
download | CMake-c41c7a6a9a78aef2d1eba25137b75329431a55b5.zip CMake-c41c7a6a9a78aef2d1eba25137b75329431a55b5.tar.gz CMake-c41c7a6a9a78aef2d1eba25137b75329431a55b5.tar.bz2 |
Add option of storing output to the variable
Diffstat (limited to 'Source/cmExecProgramCommand.cxx')
-rw-r--r-- | Source/cmExecProgramCommand.cxx | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx index 685e2fc..431c316 100644 --- a/Source/cmExecProgramCommand.cxx +++ b/Source/cmExecProgramCommand.cxx @@ -28,9 +28,28 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args) std::string arguments; bool doingargs = false; int count = 0; + std::string variable; + bool havevariable = false; + std::string e_command; for(size_t i=0; i < args.size(); ++i) { - if(doingargs) + if(args[i] == "OUTPUT_VARIABLE") + { + count++; + doingargs = false; + havevariable = true; + } + else if ( havevariable ) + { + if ( variable.size() > 0 ) + { + this->SetError("called with incorrect number of arguments"); + return false; + } + variable = args[i]; + count ++; + } + else if(doingargs) { arguments += args[i]; arguments += " "; @@ -65,6 +84,15 @@ bool cmExecProgramCommand::InitialPass(std::vector<std::string> const& args) { cmSystemTools::RunCommand(command.c_str(), output); } + + if ( variable.size() > 0 ) + { + std::string::size_type first = output.find_first_not_of(" \n\t\r"); + std::string::size_type last = output.find_last_not_of(" \n\t\r"); + std::string coutput = std::string(output, first, last); + m_Makefile->AddDefinition(variable.c_str(), coutput.c_str()); + } + return true; } |