cmakeprojectmanager.h 4.56 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2 3 4
**
** This file is part of Qt Creator
**
con's avatar
con committed
5
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
hjk's avatar
hjk committed
7
** Contact: Nokia Corporation (info@qt.nokia.com)
con's avatar
con committed
8
**
9
**
10
** GNU Lesser General Public License Usage
11
**
hjk's avatar
hjk committed
12 13 14 15 16 17
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this file.
** Please review the following information to ensure the GNU Lesser General
** Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21 22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23 24 25 26 27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
con's avatar
con committed
28
** If you have questions regarding the use of this file, please contact
Tobias Hunger's avatar
Tobias Hunger committed
29
** Nokia at info@qt.nokia.com.
con's avatar
con committed
30
**
31
**************************************************************************/
hjk's avatar
hjk committed
32

con's avatar
con committed
33 34 35 36
#ifndef CMAKEPROJECTMANAGER_H
#define CMAKEPROJECTMANAGER_H

#include <projectexplorer/iprojectmanager.h>
37
#include <coreplugin/dialogs/ioptionspage.h>
38 39
#include <projectexplorer/project.h>
#include <projectexplorer/projectnodes.h>
40 41
#include <coreplugin/icontext.h>

42
#include <utils/environment.h>
43
#include <utils/pathchooser.h>
44

dt's avatar
dt committed
45 46 47
#include <QtCore/QFuture>
#include <QtCore/QStringList>
#include <QtCore/QDir>
48
#include <QtGui/QAction>
con's avatar
con committed
49

50
QT_FORWARD_DECLARE_CLASS(QProcess)
51
QT_FORWARD_DECLARE_CLASS(QLabel)
52

53 54 55 56
namespace Utils {
class QtcProcess;
}

con's avatar
con committed
57 58 59
namespace CMakeProjectManager {
namespace Internal {

60 61
class CMakeSettingsPage;

con's avatar
con committed
62 63 64 65
class CMakeManager : public ProjectExplorer::IProjectManager
{
    Q_OBJECT
public:
66
    CMakeManager(CMakeSettingsPage *cmakeSettingsPage);
con's avatar
con committed
67

68
    virtual ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString);
con's avatar
con committed
69
    virtual QString mimeType() const;
70

dt's avatar
dt committed
71
    QString cmakeExecutable() const;
72 73 74
    bool isCMakeExecutableValid() const;

    void setCMakeExecutable(const QString &executable);
dt's avatar
dt committed
75

76 77
    void createXmlFile(Utils::QtcProcess *process,
                       const QString &arguments,
78 79
                       const QString &sourceDirectory,
                       const QDir &buildDirectory,
80
                       const Utils::Environment &env,
81
                       const QString &generator);
82
    bool hasCodeBlocksMsvcGenerator() const;
83
    static QString findCbpFile(const QDir &);
84

85
    static QString findDumperLibrary(const Utils::Environment &env);
86 87 88 89
private slots:
    void updateContextMenu(ProjectExplorer::Project *project, ProjectExplorer::Node *node);
    void runCMake();
    void runCMakeContextMenu();
con's avatar
con committed
90
private:
91
    void runCMake(ProjectExplorer::Project *project);
92
    static QString qtVersionForQMake(const QString &qmakePath);
93
    static QPair<QString, QString> findQtDir(const Utils::Environment &env);
94
    CMakeSettingsPage *m_settingsPage;
95 96 97
    QAction *m_runCMakeAction;
    QAction *m_runCMakeActionContextMenu;
    ProjectExplorer::Project *m_contextProject;
98 99
};

dt's avatar
dt committed
100 101 102 103 104 105 106 107 108 109
struct CMakeValidator
{
    enum STATE { VALID, INVALID, RUNNING };
    STATE state;
    QProcess *process;
    bool hasCodeBlocksMsvcGenerator;
    QString version;
    QString executable;
};

110 111 112 113 114 115
class CMakeSettingsPage : public Core::IOptionsPage
{
    Q_OBJECT
public:
    CMakeSettingsPage();
    virtual ~CMakeSettingsPage();
116
    virtual QString id() const;
117
    virtual QString displayName() const;
118
    virtual QString category() const;
119
    virtual QString displayCategory() const;
120
    virtual QIcon categoryIcon() const;
121 122 123 124 125 126

    virtual QWidget *createPage(QWidget *parent);
    virtual void apply();
    virtual void finish();

    QString cmakeExecutable() const;
127
    void setCMakeExecutable(const QString &executable);
dt's avatar
dt committed
128
    bool isCMakeExecutableValid() const;
129
    bool hasCodeBlocksMsvcGenerator() const;
130
private slots:
dt's avatar
dt committed
131 132
    void userCmakeFinished();
    void pathCmakeFinished();
133
private:
dt's avatar
dt committed
134
    void cmakeFinished(CMakeValidator *cmakeValidator) const;
135 136
    void saveSettings() const;
    QString findCmakeExecutable() const;
dt's avatar
dt committed
137 138
    void startProcess(CMakeValidator *cmakeValidator);
    void updateInfo(CMakeValidator *cmakeValidator);
dt's avatar
dt committed
139

140
    Utils::PathChooser *m_pathchooser;
dt's avatar
dt committed
141 142
    mutable CMakeValidator m_userCmake;
    mutable CMakeValidator m_pathCmake;
con's avatar
con committed
143
};
hjk's avatar
hjk committed
144 145 146 147

} // namespace Internal
} // namespace CMakeProjectManager

con's avatar
con committed
148
#endif // CMAKEPROJECTMANAGER_H