summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2024-01-26 19:11:31 (GMT)
committerBrad King <brad.king@kitware.com>2024-01-29 15:29:45 (GMT)
commitb9ad73fcb2ddbdd53eff6c3ba635b96f5ed0c87b (patch)
tree0db240014f48033b5b49aff8afe9687af02ff7d5
parentf434d650ee1b909ce11ff984aad20ffab6843221 (diff)
downloadCMake-b9ad73fcb2ddbdd53eff6c3ba635b96f5ed0c87b.zip
CMake-b9ad73fcb2ddbdd53eff6c3ba635b96f5ed0c87b.tar.gz
CMake-b9ad73fcb2ddbdd53eff6c3ba635b96f5ed0c87b.tar.bz2
cmTestGenerator: De-duplicate TEST_LAUNCHER and CROSSCOMPILING_EMULATOR impl
-rw-r--r--Source/cmTestGenerator.cxx40
1 files changed, 20 insertions, 20 deletions
diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx
index 3194d8f..f7403cf 100644
--- a/Source/cmTestGenerator.cxx
+++ b/Source/cmTestGenerator.cxx
@@ -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");
- // Prepend with the test launcher if specified.
- cmValue launcher = target->GetProperty("TEST_LAUNCHER");
- if (cmNonempty(launcher)) {
+ auto addLauncher = [&os, target](std::string const& propertyName) {
+ cmValue launcher = target->GetProperty(propertyName);
+ if (!cmNonempty(launcher)) {
+ return;
+ }
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) << " ";
+ 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.