From d47a72e26c1dab55289b50ca4d12cea4ad6260e0 Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 18 Oct 2022 15:09:40 +0200 Subject: [PATCH] CMake: Use the OS of the source directory as ${hostSystemName} In case of building on a remote system CMake considers this remote system as host. Change-Id: Ifb9d0b2a2c4c49ba4ee009795f5b432c7b951e0d Reviewed-by: Cristian Adam --- .../cmakeprojectmanager/presetsmacros.cpp | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/presetsmacros.cpp b/src/plugins/cmakeprojectmanager/presetsmacros.cpp index 2623a0cfed1..37896bfb700 100644 --- a/src/plugins/cmakeprojectmanager/presetsmacros.cpp +++ b/src/plugins/cmakeprojectmanager/presetsmacros.cpp @@ -10,10 +10,8 @@ namespace CMakeProjectManager::Internal::CMakePresets::Macros { -QString getHostSystemName() +static QString getHostSystemName(Utils::OsType osType) { - Utils::OsType osType = Utils::HostOsInfo::hostOs(); - switch (osType) { case Utils::OsTypeWindows: return "Windows"; @@ -29,9 +27,9 @@ QString getHostSystemName() return "Other"; } -void expandAllButEnv(const PresetsDetails::ConfigurePreset &preset, - const Utils::FilePath &sourceDirectory, - QString &value) +static void expandAllButEnv(const PresetsDetails::ConfigurePreset &preset, + const Utils::FilePath &sourceDirectory, + QString &value) { value.replace("${dollar}", "$"); @@ -43,12 +41,12 @@ void expandAllButEnv(const PresetsDetails::ConfigurePreset &preset, if (preset.generator) value.replace("${generator}", preset.generator.value()); - value.replace("${hostSystemName}", getHostSystemName()); + value.replace("${hostSystemName}", getHostSystemName(sourceDirectory.osType())); } -void expandAllButEnv(const PresetsDetails::BuildPreset &preset, - const Utils::FilePath &sourceDirectory, - QString &value) +static void expandAllButEnv(const PresetsDetails::BuildPreset &preset, + const Utils::FilePath &sourceDirectory, + QString &value) { value.replace("${dollar}", "$"); @@ -59,9 +57,9 @@ void expandAllButEnv(const PresetsDetails::BuildPreset &preset, value.replace("${presetName}", preset.name); } -QString expandMacroEnv(const QString ¯oPrefix, - const QString &value, - const std::function &op) +static QString expandMacroEnv(const QString ¯oPrefix, + const QString &value, + const std::function &op) { const QString startToken = QString("$%1{").arg(macroPrefix); const QString endToken = QString("}");