diff options
author | Alessandro Portale <alessandro.portale@qt.io> | 2023-06-15 18:04:55 +0200 |
---|---|---|
committer | Alessandro Portale <alessandro.portale@qt.io> | 2023-06-16 09:30:52 +0000 |
commit | 850f1ce66cbb36c5aba57aea37740ea6d184ad30 (patch) | |
tree | 31ef5c6cd4875fcb727a64bd3e0c2b1d4757c760 | |
parent | b1e4ed3b7c31f1a19b50974ccf7a76019ac922de (diff) |
Android: Don't pass duplicate ANDROID_PLATFORM to CMake
This makes sure that one unique argument "-DANDROID_PLATFORM:STRING=..."
is passed to CMake. An entry in a kit's CMake configuration has the
precedence over the ANDROID_PLATFORM defined by Qt's build system.
Fixes: QTCREATORBUG-29112
Change-Id: I1c4d80be9ddfc7a00a5a7eff476497f08d87b741
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp index 1ae95c1807..eaefce8a0e 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildconfiguration.cpp @@ -1468,10 +1468,18 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Id id) // Android magic: if (DeviceTypeKitAspect::deviceTypeId(k) == Android::Constants::ANDROID_DEVICE_TYPE) { + auto addUniqueKeyToCmd = [&cmd] (const QString &prefix, const QString &value) -> bool { + const bool isUnique = + !Utils::contains(cmd.splitArguments(), [&prefix] (const QString &arg) { + return arg.startsWith(prefix); }); + if (isUnique) + cmd.addArg(prefix + value); + return isUnique; + }; buildSteps()->appendStep(Android::Constants::ANDROID_BUILD_APK_ID); const auto bs = buildSteps()->steps().constLast(); - cmd.addArg("-DANDROID_PLATFORM:STRING=" - + bs->data(Android::Constants::AndroidNdkPlatform).toString()); + addUniqueKeyToCmd("-DANDROID_PLATFORM:STRING=", + bs->data(Android::Constants::AndroidNdkPlatform).toString()); auto ndkLocation = bs->data(Android::Constants::NdkLocation).value<FilePath>(); cmd.addArg("-DANDROID_NDK:PATH=" + ndkLocation.path()); |