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
|
|
|
|
2016-01-27 10:14:00 +01:00
|
|
|
#pragma once
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-03-10 14:24:14 +01:00
|
|
|
#include "cmake_global.h"
|
2008-12-02 14:09:21 +01:00
|
|
|
#include "cmakeprojectnodes.h"
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <projectexplorer/project.h>
|
2009-09-24 16:02:02 +02:00
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2012-11-08 18:02:50 +01:00
|
|
|
#include <projectexplorer/namedwidget.h>
|
2012-02-14 16:43:51 +01:00
|
|
|
#include <coreplugin/idocument.h>
|
2011-03-31 17:43:48 +02:00
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
2010-09-24 13:17:43 +02:00
|
|
|
#include <coreplugin/editormanager/ieditor.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-02-02 00:37:38 +02:00
|
|
|
#include <utils/fileutils.h>
|
|
|
|
|
|
2014-09-12 13:02:40 +04:00
|
|
|
#include <QFuture>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QXmlStreamReader>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QLineEdit>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-03-26 17:31:04 +04:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QFileSystemWatcher;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
namespace CMakeProjectManager {
|
|
|
|
|
|
2015-03-10 10:22:38 +01:00
|
|
|
namespace Internal {
|
2008-12-02 12:01:29 +01:00
|
|
|
class CMakeFile;
|
2009-09-24 16:02:02 +02:00
|
|
|
class CMakeBuildSettingsWidget;
|
2015-03-10 14:24:14 +01:00
|
|
|
class CMakeBuildConfiguration;
|
|
|
|
|
class CMakeProjectNode;
|
|
|
|
|
class CMakeManager;
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2014-11-06 11:27:24 +01:00
|
|
|
enum TargetType {
|
|
|
|
|
ExecutableType = 0,
|
|
|
|
|
StaticLibraryType = 2,
|
2016-01-07 11:47:56 +01:00
|
|
|
DynamicLibraryType = 3,
|
|
|
|
|
UtilityType = 64
|
2014-11-06 11:27:24 +01:00
|
|
|
};
|
|
|
|
|
|
2016-01-07 15:22:53 +01:00
|
|
|
class CMAKE_EXPORT CMakeBuildTarget
|
2008-12-09 14:13:29 +01:00
|
|
|
{
|
2016-01-07 15:22:53 +01:00
|
|
|
public:
|
2008-12-09 14:13:29 +01:00
|
|
|
QString title;
|
2010-04-23 16:24:55 +02:00
|
|
|
QString executable; // TODO: rename to output?
|
2014-11-06 11:27:24 +01:00
|
|
|
TargetType targetType;
|
2008-12-09 14:13:29 +01:00
|
|
|
QString workingDirectory;
|
2014-07-17 19:02:54 +02:00
|
|
|
QString sourceDirectory;
|
2008-12-09 14:13:29 +01:00
|
|
|
QString makeCommand;
|
|
|
|
|
QString makeCleanCommand;
|
2014-07-17 19:02:54 +02:00
|
|
|
|
|
|
|
|
// code model
|
|
|
|
|
QStringList includeFiles;
|
|
|
|
|
QStringList compilerOptions;
|
|
|
|
|
QByteArray defines;
|
|
|
|
|
QStringList files;
|
|
|
|
|
|
2008-12-09 14:13:29 +01:00
|
|
|
void clear();
|
|
|
|
|
};
|
|
|
|
|
|
2015-03-10 14:24:14 +01:00
|
|
|
class CMAKE_EXPORT CMakeProject : public ProjectExplorer::Project
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2009-04-20 14:35:25 +02:00
|
|
|
// for changeBuildDirectory
|
2015-03-10 14:24:14 +01:00
|
|
|
friend class Internal::CMakeBuildSettingsWidget;
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2015-03-10 14:24:14 +01:00
|
|
|
CMakeProject(Internal::CMakeManager *manager, const Utils::FileName &filename);
|
2016-01-06 15:49:21 +01:00
|
|
|
~CMakeProject() override;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2016-01-06 15:49:21 +01:00
|
|
|
QString displayName() const override;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2016-01-06 15:49:21 +01:00
|
|
|
QStringList files(FilesMode fileMode) const override;
|
2013-02-16 14:18:39 +01:00
|
|
|
QStringList buildTargetTitles(bool runnable = false) const;
|
2010-02-02 12:01:11 +01:00
|
|
|
QList<CMakeBuildTarget> buildTargets() const;
|
|
|
|
|
bool hasBuildTarget(const QString &title) const;
|
2009-11-25 18:50:20 +01:00
|
|
|
|
2010-02-02 12:01:11 +01:00
|
|
|
CMakeBuildTarget buildTargetForTitle(const QString &title);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-02-02 00:37:38 +02:00
|
|
|
bool isProjectFile(const Utils::FileName &fileName);
|
2011-03-31 17:43:48 +02:00
|
|
|
|
2012-07-17 15:56:43 +02:00
|
|
|
bool parseCMakeLists();
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2016-01-06 15:49:21 +01:00
|
|
|
bool needsConfiguration() const override;
|
2015-09-10 16:17:38 +02:00
|
|
|
|
2016-01-06 15:49:21 +01:00
|
|
|
bool requiresTargetPanel() const override;
|
2015-09-10 16:17:38 +02:00
|
|
|
|
2016-01-06 15:51:44 +01:00
|
|
|
bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage = 0) const override;
|
|
|
|
|
|
2009-12-03 19:45:09 +01:00
|
|
|
signals:
|
|
|
|
|
/// emitted after parsing
|
2010-02-02 12:01:11 +01:00
|
|
|
void buildTargetsChanged();
|
2009-12-03 19:45:09 +01:00
|
|
|
|
2009-03-26 17:36:58 +01:00
|
|
|
protected:
|
2016-01-06 15:49:21 +01:00
|
|
|
RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) override;
|
|
|
|
|
bool setupTarget(ProjectExplorer::Target *t) override;
|
2009-03-26 17:36:58 +01:00
|
|
|
|
2009-04-20 14:35:25 +02:00
|
|
|
// called by CMakeBuildSettingsWidget
|
2015-03-10 14:24:14 +01:00
|
|
|
void changeBuildDirectory(Internal::CMakeBuildConfiguration *bc, const QString &newBuildDirectory);
|
2009-04-20 14:35:25 +02:00
|
|
|
|
2016-01-07 15:22:53 +01:00
|
|
|
private:
|
2009-03-26 17:36:58 +01:00
|
|
|
void fileChanged(const QString &fileName);
|
2012-10-16 17:19:59 +02:00
|
|
|
void activeTargetWasChanged(ProjectExplorer::Target *target);
|
2010-02-08 15:50:06 +01:00
|
|
|
void changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*);
|
2009-03-26 17:36:58 +01:00
|
|
|
|
2012-07-17 15:56:43 +02:00
|
|
|
void updateRunConfigurations();
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2015-03-10 14:24:14 +01:00
|
|
|
void buildTree(Internal::CMakeProjectNode *rootNode, QList<ProjectExplorer::FileNode *> list);
|
2009-03-26 17:36:58 +01:00
|
|
|
void gatherFileNodes(ProjectExplorer::FolderNode *parent, QList<ProjectExplorer::FileNode *> &list);
|
2015-03-10 14:24:14 +01:00
|
|
|
ProjectExplorer::FolderNode *findOrCreateFolder(Internal::CMakeProjectNode *rootNode, QString directory);
|
2010-09-24 13:17:43 +02:00
|
|
|
void createUiCodeModelSupport();
|
|
|
|
|
QString uiHeaderFile(const QString &uiFile);
|
2016-01-08 14:29:36 +01:00
|
|
|
void updateTargetRunConfigurations(ProjectExplorer::Target *t);
|
2013-07-07 23:49:13 +02:00
|
|
|
void updateApplicationAndDeploymentTargets();
|
2015-07-20 12:32:54 +02:00
|
|
|
QStringList getCXXFlagsFor(const CMakeBuildTarget &buildTarget, QByteArray *cachedBuildNinja);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2016-01-08 11:31:06 +01:00
|
|
|
ProjectExplorer::Target *m_activeTarget = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// TODO probably need a CMake specific node structure
|
|
|
|
|
QStringList m_files;
|
2010-02-02 12:01:11 +01:00
|
|
|
QList<CMakeBuildTarget> m_buildTargets;
|
2011-03-31 17:43:48 +02:00
|
|
|
QFileSystemWatcher *m_watcher;
|
2015-02-02 00:37:38 +02:00
|
|
|
QSet<Utils::FileName> m_watchedFiles;
|
2010-04-22 18:57:43 +02:00
|
|
|
QFuture<void> m_codeModelFuture;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2008-12-02 14:09:21 +01:00
|
|
|
} // namespace CMakeProjectManager
|