|
|
@@ -167,31 +167,33 @@ 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");
|
|
|
|
|
|
- // 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) << " ";
|
|
|
+ auto addLauncher = [this, &config, &ge, &os,
|
|
|
+ target](std::string const& propertyName) {
|
|
|
+ cmValue launcher = target->GetProperty(propertyName);
|
|
|
+ if (!cmNonempty(launcher)) {
|
|
|
+ return;
|
|
|
}
|
|
|
- }
|
|
|
+ cmList launcherWithArgs{ ge.Parse(*launcher)->Evaluate(this->LG,
|
|
|
+ config) };
|
|
|
+ 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.
|
|
|
+ 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.
|