diff options
author | Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com> | 2016-05-04 17:30:19 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-05-09 12:56:27 (GMT) |
commit | 8c2cedc6243b281a0814b284abbcd1c45c42b085 (patch) | |
tree | b4bd057053fff493dc9ed8f9538e5e039faa6e89 /Source/cmCustomCommandGenerator.cxx | |
parent | eccfc0d185526b746b722ed3d3d1302515698c9e (diff) | |
download | CMake-8c2cedc6243b281a0814b284abbcd1c45c42b085.zip CMake-8c2cedc6243b281a0814b284abbcd1c45c42b085.tar.gz CMake-8c2cedc6243b281a0814b284abbcd1c45c42b085.tar.bz2 |
CustomCommandGenerator: Add support for CROSSCOMPILING_EMULATOR
Teach the `add_custom_command` and `add_custom_target' commands to
substitute argv0 with the crosscompiling emulator if it is a target with
the `CROSSCOMPILING_EMULATOR` property set.
Diffstat (limited to 'Source/cmCustomCommandGenerator.cxx')
-rw-r--r-- | Source/cmCustomCommandGenerator.cxx | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 5d3a1ce..81c5142 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -39,6 +39,19 @@ unsigned int cmCustomCommandGenerator::GetNumberOfCommands() const } //---------------------------------------------------------------------------- +bool cmCustomCommandGenerator::UseCrossCompilingEmulator(unsigned int c) const +{ + std::string const& argv0 = this->CC.GetCommandLines()[c][0]; + cmGeneratorTarget* target = + this->LG->FindGeneratorTargetToUse(argv0); + if(target && target->GetType() == cmState::EXECUTABLE) + { + return target->GetProperty("CROSSCOMPILING_EMULATOR") != 0; + } + return false; +} + +//---------------------------------------------------------------------------- std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const { std::string const& argv0 = this->CC.GetCommandLines()[c][0]; @@ -50,7 +63,19 @@ std::string cmCustomCommandGenerator::GetCommand(unsigned int c) const { return target->GetLocation(this->Config); } - return this->GE->Parse(argv0)->Evaluate(this->LG, this->Config); + if (target && target->GetType() == cmState::EXECUTABLE) + { + const char* emulator = target->GetProperty("CROSSCOMPILING_EMULATOR"); + if (emulator) + { + return std::string(emulator); + } + } + + cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = this->GE->Parse(argv0); + std::string exe = cge->Evaluate(this->LG, this->Config); + + return exe; } //---------------------------------------------------------------------------- @@ -87,8 +112,13 @@ void cmCustomCommandGenerator ::AppendArguments(unsigned int c, std::string& cmd) const { + unsigned int offset = 1; + if (this->UseCrossCompilingEmulator(c)) + { + offset = 0; + } cmCustomCommandLine const& commandLine = this->CC.GetCommandLines()[c]; - for(unsigned int j=1;j < commandLine.size(); ++j) + for(unsigned int j=offset;j < commandLine.size(); ++j) { std::string arg = this->GE->Parse(commandLine[j])->Evaluate(this->LG, |