cmTestGenerator: De-duplicate TEST_LAUNCHER and CROSSCOMPILING_EMULATOR impl
This commit is contained in:
parent
f434d650ee
commit
b9ad73fcb2
@ -167,31 +167,31 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
|
||||
if (target && target->GetType() == cmStateEnums::EXECUTABLE) {
|
||||
// Use the target file on disk.
|
||||
exe = target->GetFullPath(config);
|
||||
auto useEmulator = !this->GetTest()->GetCMP0158IsNew() ||
|
||||
this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING");
|
||||
|
||||
auto addLauncher = [&os, target](std::string const& propertyName) {
|
||||
cmValue launcher = target->GetProperty(propertyName);
|
||||
if (!cmNonempty(launcher)) {
|
||||
return;
|
||||
}
|
||||
cmList launcherWithArgs{ *launcher };
|
||||
if (!launcherWithArgs.empty() && !launcherWithArgs[0].empty()) {
|
||||
std::string launcherExe(launcherWithArgs[0]);
|
||||
cmSystemTools::ConvertToUnixSlashes(launcherExe);
|
||||
os << cmOutputConverter::EscapeForCMake(launcherExe) << " ";
|
||||
for (std::string const& arg :
|
||||
cmMakeRange(launcherWithArgs).advance(1)) {
|
||||
os << cmOutputConverter::EscapeForCMake(arg) << " ";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Prepend with the test launcher if specified.
|
||||
cmValue launcher = target->GetProperty("TEST_LAUNCHER");
|
||||
if (cmNonempty(launcher)) {
|
||||
cmList launcherWithArgs{ *launcher };
|
||||
std::string launcherExe(launcherWithArgs[0]);
|
||||
cmSystemTools::ConvertToUnixSlashes(launcherExe);
|
||||
os << cmOutputConverter::EscapeForCMake(launcherExe) << " ";
|
||||
for (std::string const& arg : cmMakeRange(launcherWithArgs).advance(1)) {
|
||||
os << cmOutputConverter::EscapeForCMake(arg) << " ";
|
||||
}
|
||||
}
|
||||
addLauncher("TEST_LAUNCHER");
|
||||
|
||||
// Prepend with the emulator when cross compiling if required.
|
||||
cmValue emulator = target->GetProperty("CROSSCOMPILING_EMULATOR");
|
||||
if (cmNonempty(emulator) && useEmulator) {
|
||||
cmList emulatorWithArgs{ *emulator };
|
||||
std::string emulatorExe(emulatorWithArgs[0]);
|
||||
cmSystemTools::ConvertToUnixSlashes(emulatorExe);
|
||||
os << cmOutputConverter::EscapeForCMake(emulatorExe) << " ";
|
||||
for (std::string const& arg : cmMakeRange(emulatorWithArgs).advance(1)) {
|
||||
os << cmOutputConverter::EscapeForCMake(arg) << " ";
|
||||
}
|
||||
if (!this->GetTest()->GetCMP0158IsNew() ||
|
||||
this->LG->GetMakefile()->IsOn("CMAKE_CROSSCOMPILING")) {
|
||||
addLauncher("CROSSCOMPILING_EMULATOR");
|
||||
}
|
||||
} else {
|
||||
// Use the command name given.
|
||||
|
Loading…
Reference in New Issue
Block a user