mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-08 15:19:51 -05:00
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.
This commit is contained in:
committed by
Brad King
parent
eccfc0d185
commit
8c2cedc624
@@ -38,6 +38,19 @@ unsigned int cmCustomCommandGenerator::GetNumberOfCommands() const
|
||||
return static_cast<unsigned int>(this->CC.GetCommandLines().size());
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
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
|
||||
{
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user