CMakeProjectManager: Deselect "Stage for installation" for Android/iOS

The "Stage for installation" option in the CMake build step, which is
introduced with Qt Creator 11, relies on the presence of an "install"
CMake target.

The build systems of Qt for Android and Qt for iOS do not create an
"install" CMake target. Therefore, a pre-selected "Stage for
installation" option in the CMake build step would cause a build
failure.

This change deselects the option if the kit's run device is of type
Android or iOS.

Fixes: QTCREATORBUG-29293
Change-Id: I9755dea1564fbc2696f8bdd416f637c5b28e3761
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Alessandro Portale
2023-06-16 21:47:39 +02:00
parent 5010f041cb
commit 2387e9e37a

View File

@@ -12,6 +12,10 @@
#include "cmakeprojectmanagertr.h"
#include "cmaketool.h"
#include <android/androidconstants.h>
#include <ios/iosconstants.h>
#include <coreplugin/find/itemviewfind.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/devicesupport/idevice.h>
@@ -173,13 +177,15 @@ static QString initialStagingDir(Kit *kit)
return QString::fromUtf8("/tmp/Qt-Creator-staging-" + ba);
}
static bool buildAndRunOnSameDevice(Kit *kit)
static bool supportsStageForInstallation(const Kit *kit)
{
IDeviceConstPtr runDevice = DeviceKitAspect::device(kit);
IDeviceConstPtr buildDevice = BuildDeviceKitAspect::device(kit);
QTC_ASSERT(runDevice, return false);
QTC_ASSERT(buildDevice, return false);
return runDevice->id() == buildDevice->id();
return runDevice->id() != buildDevice->id()
&& runDevice->type() != Android::Constants::ANDROID_DEVICE_TYPE
&& runDevice->type() != Ios::Constants::IOS_DEVICE_TYPE;
}
CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl, Id id) :
@@ -198,7 +204,7 @@ CMakeBuildStep::CMakeBuildStep(BuildStepList *bsl, Id id) :
m_useStaging = addAspect<BoolAspect>();
m_useStaging->setSettingsKey(USE_STAGING_KEY);
m_useStaging->setLabel(Tr::tr("Stage for installation"), BoolAspect::LabelPlacement::AtCheckBox);
m_useStaging->setDefaultValue(!buildAndRunOnSameDevice(kit()));
m_useStaging->setDefaultValue(supportsStageForInstallation(kit()));
m_stagingDir = addAspect<FilePathAspect>();
m_stagingDir->setSettingsKey(STAGING_DIR_KEY);