2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-09 14:53:06 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2008-12-09 14:53:06 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-09 14:53:06 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2008-12-09 14:53:06 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2010-12-17 16:01:08 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-09 14:53:06 +01:00
|
|
|
|
|
|
|
|
#include "cmakerunconfiguration.h"
|
2008-12-09 15:25:01 +01:00
|
|
|
|
|
|
|
|
#include "cmakeprojectconstants.h"
|
2008-12-09 14:53:06 +01:00
|
|
|
|
2013-04-09 12:05:15 +02:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2017-11-03 12:40:49 +01:00
|
|
|
#include <qtsupport/qtoutputformatter.h>
|
2018-03-23 09:32:52 +01:00
|
|
|
|
2013-11-01 14:13:41 +01:00
|
|
|
#include <projectexplorer/localenvironmentaspect.h>
|
2018-03-23 09:32:52 +01:00
|
|
|
#include <projectexplorer/project.h>
|
2015-04-30 13:11:25 +02:00
|
|
|
#include <projectexplorer/runconfigurationaspects.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2011-02-28 16:50:14 +01:00
|
|
|
|
2014-05-26 22:13:14 +03:00
|
|
|
using namespace ProjectExplorer;
|
2008-12-09 14:53:06 +01:00
|
|
|
|
2018-03-23 09:32:52 +01:00
|
|
|
namespace CMakeProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2018-04-25 10:26:08 +02:00
|
|
|
CMakeRunConfiguration::CMakeRunConfiguration(Target *target, Core::Id id)
|
|
|
|
|
: RunConfiguration(target, id)
|
2008-12-09 14:53:06 +01:00
|
|
|
{
|
2017-11-23 14:06:48 +01:00
|
|
|
// Workaround for QTCREATORBUG-19354:
|
2018-09-06 10:45:51 +02:00
|
|
|
auto cmakeRunEnvironmentModifier = [target](Utils::Environment &env) {
|
|
|
|
|
if (!Utils::HostOsInfo::isWindowsHost())
|
2017-11-23 14:06:48 +01:00
|
|
|
return;
|
|
|
|
|
|
2018-09-06 10:45:51 +02:00
|
|
|
const Kit *k = target->kit();
|
2019-02-06 12:50:51 +01:00
|
|
|
const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(k);
|
2017-11-23 14:06:48 +01:00
|
|
|
if (qt)
|
|
|
|
|
env.prependOrSetPath(qt->qmakeProperty("QT_INSTALL_BINS"));
|
|
|
|
|
};
|
2018-09-12 10:43:10 +02:00
|
|
|
auto envAspect = addAspect<LocalEnvironmentAspect>(target, cmakeRunEnvironmentModifier);
|
2018-09-10 12:41:51 +02:00
|
|
|
|
2018-09-04 10:36:44 +02:00
|
|
|
addAspect<ExecutableAspect>();
|
|
|
|
|
addAspect<ArgumentsAspect>();
|
2018-09-10 12:41:51 +02:00
|
|
|
addAspect<WorkingDirectoryAspect>(envAspect);
|
2018-09-04 10:36:44 +02:00
|
|
|
addAspect<TerminalAspect>();
|
2018-03-23 09:32:52 +01:00
|
|
|
|
|
|
|
|
connect(target->project(), &Project::parsingFinished,
|
|
|
|
|
this, &CMakeRunConfiguration::updateTargetInformation);
|
2018-04-06 09:21:44 +02:00
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
if (QtSupport::QtKitAspect::qtVersion(target->kit()))
|
2018-04-06 09:21:44 +02:00
|
|
|
setOutputFormatter<QtSupport::QtOutputFormatter>();
|
2010-01-19 13:41:02 +01:00
|
|
|
}
|
2009-11-26 14:43:27 +01:00
|
|
|
|
2018-03-12 16:33:28 +01:00
|
|
|
void CMakeRunConfiguration::doAdditionalSetup(const RunConfigurationCreationInfo &info)
|
|
|
|
|
{
|
2018-04-24 16:52:29 +02:00
|
|
|
Q_UNUSED(info);
|
2018-03-23 09:32:52 +01:00
|
|
|
updateTargetInformation();
|
2010-08-19 12:26:21 +02:00
|
|
|
}
|
|
|
|
|
|
2018-03-23 09:32:52 +01:00
|
|
|
void CMakeRunConfiguration::updateTargetInformation()
|
2017-07-12 12:52:06 +02:00
|
|
|
{
|
2019-02-18 18:24:10 +01:00
|
|
|
BuildTargetInfo bti = buildTargetInfo();
|
2018-09-07 13:29:45 +02:00
|
|
|
aspect<ExecutableAspect>()->setExecutable(bti.targetFilePath);
|
|
|
|
|
aspect<WorkingDirectoryAspect>()->setDefaultWorkingDirectory(bti.workingDirectory);
|
|
|
|
|
aspect<LocalEnvironmentAspect>()->buildEnvironmentHasChanged();
|
2018-03-23 09:32:52 +01:00
|
|
|
|
2018-09-07 13:29:45 +02:00
|
|
|
auto terminalAspect = aspect<TerminalAspect>();
|
2018-03-23 09:32:52 +01:00
|
|
|
if (!terminalAspect->isUserSet())
|
|
|
|
|
terminalAspect->setUseTerminal(bti.usesTerminal);
|
2013-01-29 18:00:30 +01:00
|
|
|
}
|
2009-09-17 13:59:10 +02:00
|
|
|
|
2008-12-09 14:53:06 +01:00
|
|
|
// Factory
|
2018-03-06 17:14:43 +01:00
|
|
|
CMakeRunConfigurationFactory::CMakeRunConfigurationFactory()
|
2017-11-10 15:43:23 +01:00
|
|
|
{
|
2018-04-25 10:26:08 +02:00
|
|
|
registerRunConfiguration<CMakeRunConfiguration>("CMakeProjectManager.CMakeRunConfiguration.");
|
2017-12-08 14:50:57 +01:00
|
|
|
addSupportedProjectType(CMakeProjectManager::Constants::CMAKEPROJECT_ID);
|
2018-03-14 08:38:34 +01:00
|
|
|
addSupportedTargetDeviceType(ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
|
2018-05-29 12:51:40 +02:00
|
|
|
|
|
|
|
|
addRunWorkerFactory<SimpleTargetRunner>(ProjectExplorer::Constants::NORMAL_RUN_MODE);
|
2017-11-10 15:43:23 +01:00
|
|
|
}
|
2018-03-23 09:32:52 +01:00
|
|
|
|
|
|
|
|
} // Internal
|
|
|
|
|
} // CMakeProjectManager
|