diff options
author | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2020-09-24 13:03:25 +0300 |
---|---|---|
committer | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2020-09-28 07:31:48 +0000 |
commit | 9dcbb8ca01e0981b6a3c7ea8dd278014343f48e3 (patch) | |
tree | d06048db11cbcfa8b23f909f68f0546053175234 /src/plugins/cmakeprojectmanager | |
parent | e685bb3b11da384ae6f230438a98c260a7a8eeca (diff) |
Android: add prepare_apk_dir CMake target by default
Qt 6 CMake build doesn't execute prepare_apk_dir by default (this is
the equivalent of install step in qmake). Since we have the target
for installing the build artifacts to android-build already present
in the CMake targets list, it's better to just use it, instead of
using another custom step just for that.
Task-number: QTCREATORBUG-24679
Change-Id: I369d6ce513f9aaf917c5fcbb3f6aa44e36b97af8
Reviewed-by: hjk <hjk@qt.io>
Diffstat (limited to 'src/plugins/cmakeprojectmanager')
-rw-r--r-- | src/plugins/cmakeprojectmanager/cmakebuildstep.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp index d120623e65e..65e51a41704 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildstep.cpp @@ -32,15 +32,18 @@ #include "cmakeprojectconstants.h" #include "cmaketool.h" +#include <android/androidconstants.h> #include <coreplugin/find/itemviewfind.h> #include <projectexplorer/buildsteplist.h> #include <projectexplorer/gnumakeparser.h> +#include <projectexplorer/kitinformation.h> #include <projectexplorer/processparameters.h> #include <projectexplorer/project.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/runconfiguration.h> #include <projectexplorer/target.h> - +#include <qtsupport/baseqtversion.h> +#include <qtsupport/qtkitinformation.h> #include <utils/algorithm.h> #include <utils/layoutbuilder.h> @@ -473,6 +476,30 @@ BuildStepConfigWidget *CMakeBuildStep::createConfigWidget() connect(this, &CMakeBuildStep::buildTargetsChanged, widget, updateDetails); + // For Qt 6 for Android: Make sure to add "<target>_prepare_apk_dir" if only + // "all" target is selected. This copies the build shared libs to android-build + // folder, partially the same as done in AndroidPackageInstallationStep for + // qmake install step. + const Kit *k = target()->kit(); + if (DeviceTypeKitAspect::deviceTypeId(k) == Android::Constants::ANDROID_DEVICE_TYPE) { + const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(k); + if (qt && qt->qtVersion() >= QtSupport::QtVersionNumber{6, 0, 0}) { + QMetaObject::Connection *const connection = new QMetaObject::Connection; + *connection = connect(this, &CMakeBuildStep::buildTargetsChanged, widget, [this, connection]() { + const QString mainTarget = activeRunConfigTarget(); + if (!mainTarget.isEmpty()) { + QStringList targets{buildTargets()}; + if (targets == QStringList{allTarget()}) { + targets.append(QString("%1_prepare_apk_dir").arg(mainTarget)); + setBuildTargets({targets}); + QObject::disconnect(*connection); + delete connection; + } + } + }); + } + } + return widget; } |