cmakeprojectmanager.h 4.8 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
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
con's avatar
con committed
9
** No Commercial Usage
10
**
con's avatar
con committed
11 12 13 14
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
15
**
16
** GNU Lesser General Public License Usage
17
**
18 19 20 21 22 23
** Alternatively, 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.
24
**
con's avatar
con committed
25 26 27 28 29 30
** In addition, as a special exception, Nokia gives you certain additional
** rights.  These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
con's avatar
con committed
31
**
32
**************************************************************************/
hjk's avatar
hjk committed
33

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

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

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

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

51
QT_FORWARD_DECLARE_CLASS(QProcess)
52
QT_FORWARD_DECLARE_CLASS(QLabel)
53

54 55 56 57
namespace Utils {
class QtcProcess;
}

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

61 62
class CMakeSettingsPage;

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

dt's avatar
dt committed
69
    virtual Core::Context projectContext() const;
70
    virtual Core::Context projectLanguage() const;
con's avatar
con committed
71 72 73

    virtual ProjectExplorer::Project *openProject(const QString &fileName);
    virtual QString mimeType() const;
74

dt's avatar
dt committed
75
    QString cmakeExecutable() const;
76 77 78
    bool isCMakeExecutableValid() const;

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

80 81
    void createXmlFile(Utils::QtcProcess *process,
                       const QString &arguments,
82 83
                       const QString &sourceDirectory,
                       const QDir &buildDirectory,
84
                       const Utils::Environment &env,
85
                       const QString &generator);
86
    bool hasCodeBlocksMsvcGenerator() const;
87
    static QString findCbpFile(const QDir &);
88

89
    static QString findDumperLibrary(const Utils::Environment &env);
90 91 92 93
private slots:
    void updateContextMenu(ProjectExplorer::Project *project, ProjectExplorer::Node *node);
    void runCMake();
    void runCMakeContextMenu();
con's avatar
con committed
94
private:
95
    void runCMake(ProjectExplorer::Project *project);
96
    static QString qtVersionForQMake(const QString &qmakePath);
97
    static QPair<QString, QString> findQtDir(const Utils::Environment &env);
dt's avatar
dt committed
98
    Core::Context m_projectContext;
99
    Core::Context m_projectLanguage;
100
    CMakeSettingsPage *m_settingsPage;
101 102 103
    QAction *m_runCMakeAction;
    QAction *m_runCMakeActionContextMenu;
    ProjectExplorer::Project *m_contextProject;
104 105
};

dt's avatar
dt committed
106 107 108 109 110 111 112 113 114 115
struct CMakeValidator
{
    enum STATE { VALID, INVALID, RUNNING };
    STATE state;
    QProcess *process;
    bool hasCodeBlocksMsvcGenerator;
    QString version;
    QString executable;
};

116 117 118 119 120 121
class CMakeSettingsPage : public Core::IOptionsPage
{
    Q_OBJECT
public:
    CMakeSettingsPage();
    virtual ~CMakeSettingsPage();
122
    virtual QString id() const;
123
    virtual QString displayName() const;
124
    virtual QString category() const;
125
    virtual QString displayCategory() const;
126
    virtual QIcon categoryIcon() const;
127 128 129 130 131 132

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

    QString cmakeExecutable() const;
133
    void setCMakeExecutable(const QString &executable);
dt's avatar
dt committed
134
    bool isCMakeExecutableValid() const;
135
    bool hasCodeBlocksMsvcGenerator() const;
136
private slots:
dt's avatar
dt committed
137 138
    void userCmakeFinished();
    void pathCmakeFinished();
139
private:
dt's avatar
dt committed
140
    void cmakeFinished(CMakeValidator *cmakeValidator) const;
141 142
    void saveSettings() const;
    QString findCmakeExecutable() const;
dt's avatar
dt committed
143 144
    void startProcess(CMakeValidator *cmakeValidator);
    void updateInfo(CMakeValidator *cmakeValidator);
dt's avatar
dt committed
145

146
    Utils::PathChooser *m_pathchooser;
dt's avatar
dt committed
147 148
    mutable CMakeValidator m_userCmake;
    mutable CMakeValidator m_pathCmake;
con's avatar
con committed
149
};
hjk's avatar
hjk committed
150 151 152 153

} // namespace Internal
} // namespace CMakeProjectManager

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