2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +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-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +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-02 14:17:16 +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-02 14:09:21 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "cmakeproject.h"
|
2012-04-24 15:49:09 +02:00
|
|
|
|
|
|
|
|
#include "cmakebuildconfiguration.h"
|
2019-04-12 14:49:59 +02:00
|
|
|
#include "cmakebuildstep.h"
|
2016-01-06 15:51:44 +01:00
|
|
|
#include "cmakekitinformation.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "cmakeprojectconstants.h"
|
|
|
|
|
#include "cmakeprojectnodes.h"
|
2015-03-10 10:22:38 +01:00
|
|
|
#include "cmakeprojectmanager.h"
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2016-12-04 03:36:12 +10:00
|
|
|
#include <coreplugin/progressmanager/progressmanager.h>
|
2017-02-06 16:59:53 +01:00
|
|
|
#include <cpptools/cppprojectupdater.h>
|
2019-08-28 18:22:45 +02:00
|
|
|
#include <cpptools/cpptoolsconstants.h>
|
2016-10-06 11:31:23 +02:00
|
|
|
#include <cpptools/generatedcodemodelsupport.h>
|
2016-01-20 12:19:16 +01:00
|
|
|
#include <cpptools/projectinfo.h>
|
2019-04-12 14:49:59 +02:00
|
|
|
#include <projectexplorer/buildsteplist.h>
|
2013-07-07 23:49:13 +02:00
|
|
|
#include <projectexplorer/buildtargetinfo.h>
|
2016-01-20 12:19:16 +01:00
|
|
|
#include <projectexplorer/deploymentdata.h>
|
|
|
|
|
#include <projectexplorer/headerpath.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <projectexplorer/kitinformation.h>
|
2017-09-28 11:32:39 +02:00
|
|
|
#include <projectexplorer/kitmanager.h>
|
2016-01-20 12:19:16 +01:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
2010-11-01 14:14:17 +01:00
|
|
|
#include <projectexplorer/toolchain.h>
|
2019-08-28 18:22:45 +02:00
|
|
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
2013-01-17 15:12:46 +01:00
|
|
|
#include <qtsupport/baseqtversion.h>
|
2019-01-04 12:35:28 +01:00
|
|
|
#include <qtsupport/qtcppkitinfo.h>
|
2013-01-17 15:12:46 +01:00
|
|
|
#include <qtsupport/qtkitinformation.h>
|
2016-10-06 11:31:23 +02:00
|
|
|
|
2014-06-16 18:25:52 +04:00
|
|
|
#include <utils/algorithm.h>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2019-05-29 18:54:45 +02:00
|
|
|
#include <utils/qtcprocess.h>
|
2012-11-19 14:18:14 +01:00
|
|
|
#include <utils/stringutils.h>
|
2013-01-01 18:18:03 +01:00
|
|
|
#include <utils/hostosinfo.h>
|
2008-12-02 14:09:21 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDir>
|
2019-06-20 15:49:05 +02:00
|
|
|
#include <QElapsedTimer>
|
2016-06-14 17:43:11 +02:00
|
|
|
#include <QSet>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-09-24 16:02:02 +02:00
|
|
|
using namespace ProjectExplorer;
|
2015-02-01 18:44:47 +02:00
|
|
|
using namespace Utils;
|
2008-12-12 17:22:02 +01:00
|
|
|
|
2016-02-24 18:00:24 +01:00
|
|
|
namespace CMakeProjectManager {
|
|
|
|
|
|
|
|
|
|
using namespace Internal;
|
|
|
|
|
|
2008-12-12 17:22:02 +01:00
|
|
|
// QtCreator CMake Generator wishlist:
|
|
|
|
|
// Which make targets we need to build to get all executables
|
|
|
|
|
// What is the actual compiler executable
|
|
|
|
|
// DEFINES
|
|
|
|
|
|
2009-09-24 16:02:02 +02:00
|
|
|
/*!
|
|
|
|
|
\class CMakeProject
|
|
|
|
|
*/
|
2019-08-05 15:56:03 +02:00
|
|
|
CMakeProject::CMakeProject(const FilePath &fileName)
|
|
|
|
|
: Project(Constants::CMAKEMIMETYPE, fileName)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2016-10-06 11:31:23 +02:00
|
|
|
setId(CMakeProjectManager::Constants::CMAKEPROJECT_ID);
|
2017-01-30 14:59:10 +01:00
|
|
|
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
|
2017-04-07 14:35:49 +02:00
|
|
|
setDisplayName(projectDirectory().fileName());
|
2019-06-03 17:36:02 +02:00
|
|
|
setCanBuildProducts();
|
2019-08-08 17:28:11 +02:00
|
|
|
setKnowsAllBuildExecutables(false);
|
2019-08-13 12:11:07 +02:00
|
|
|
setHasMakeInstallEquivalent(true);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2019-08-06 12:41:46 +02:00
|
|
|
CMakeProject::~CMakeProject() = default;
|
2016-04-18 13:06:41 +02:00
|
|
|
|
2019-05-27 16:09:44 +02:00
|
|
|
Tasks CMakeProject::projectIssues(const Kit *k) const
|
2016-01-06 15:51:44 +01:00
|
|
|
{
|
2019-05-27 16:09:44 +02:00
|
|
|
Tasks result = Project::projectIssues(k);
|
2018-04-18 13:39:05 +02:00
|
|
|
|
2019-02-06 12:50:51 +01:00
|
|
|
if (!CMakeKitAspect::cmakeTool(k))
|
2018-04-18 13:39:05 +02:00
|
|
|
result.append(createProjectTask(Task::TaskType::Error, tr("No cmake tool set.")));
|
2019-02-06 12:50:51 +01:00
|
|
|
if (ToolChainKitAspect::toolChains(k).isEmpty())
|
2018-04-18 13:39:05 +02:00
|
|
|
result.append(createProjectTask(Task::TaskType::Warning, tr("No compilers set in kit.")));
|
|
|
|
|
|
|
|
|
|
return result;
|
2016-01-06 15:51:44 +01:00
|
|
|
}
|
|
|
|
|
|
2016-11-14 15:18:25 +01:00
|
|
|
|
2016-08-25 14:33:44 +02:00
|
|
|
ProjectImporter *CMakeProject::projectImporter() const
|
|
|
|
|
{
|
|
|
|
|
if (!m_projectImporter)
|
|
|
|
|
m_projectImporter = std::make_unique<CMakeProjectImporter>(projectFilePath());
|
|
|
|
|
return m_projectImporter.get();
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-02 17:46:19 +02:00
|
|
|
bool CMakeProject::setupTarget(Target *t)
|
|
|
|
|
{
|
2013-07-07 23:49:13 +02:00
|
|
|
t->updateDefaultBuildConfigurations();
|
2014-07-31 16:36:46 +02:00
|
|
|
if (t->buildConfigurations().isEmpty())
|
|
|
|
|
return false;
|
2013-07-07 23:49:13 +02:00
|
|
|
t->updateDefaultDeployConfigurations();
|
2012-10-02 17:46:19 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-12 14:49:59 +02:00
|
|
|
ProjectExplorer::DeploymentKnowledge CMakeProject::deploymentKnowledge() const
|
|
|
|
|
{
|
2019-06-18 16:21:56 +02:00
|
|
|
return !files([](const ProjectExplorer::Node *n) {
|
|
|
|
|
return n->filePath().fileName() == "QtCreatorDeployment.txt";
|
|
|
|
|
})
|
|
|
|
|
.isEmpty()
|
|
|
|
|
? DeploymentKnowledge::Approximative
|
|
|
|
|
: DeploymentKnowledge::Bad;
|
2019-04-12 14:49:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MakeInstallCommand CMakeProject::makeInstallCommand(const Target *target,
|
|
|
|
|
const QString &installRoot)
|
|
|
|
|
{
|
|
|
|
|
MakeInstallCommand cmd;
|
|
|
|
|
if (const BuildConfiguration * const bc = target->activeBuildConfiguration()) {
|
2019-12-05 16:19:42 +01:00
|
|
|
if (const auto cmakeStep = bc->buildSteps()->firstOfType<CMakeBuildStep>()) {
|
2019-05-29 18:54:45 +02:00
|
|
|
if (CMakeTool *tool = CMakeKitAspect::cmakeTool(target->kit()))
|
|
|
|
|
cmd.command = tool->cmakeExecutable();
|
2019-04-12 14:49:59 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
cmd.arguments << "--build" << "." << "--target" << "install";
|
|
|
|
|
cmd.environment.set("DESTDIR", QDir::toNativeSeparators(installRoot));
|
|
|
|
|
return cmd;
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-24 18:00:24 +01:00
|
|
|
} // namespace CMakeProjectManager
|