cmakeprojectmanager.h 4.02 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2 3 4
**
** This file is part of Qt Creator
**
5
** Copyright (c) 2009 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
**
9
** Commercial Usage
10
**
11 12 13 14
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
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
**
25
** If you are unsure which license is appropriate for your use, please
26
** contact the sales department at http://www.qtsoftware.com/contact.
con's avatar
con committed
27
**
28
**************************************************************************/
hjk's avatar
hjk committed
29

con's avatar
con committed
30 31 32
#ifndef CMAKEPROJECTMANAGER_H
#define CMAKEPROJECTMANAGER_H

33
#include <coreplugin/dialogs/ioptionspage.h>
con's avatar
con committed
34
#include <projectexplorer/iprojectmanager.h>
35
#include <projectexplorer/environment.h>
36
#include <utils/pathchooser.h>
dt's avatar
dt committed
37 38 39
#include <QtCore/QFuture>
#include <QtCore/QStringList>
#include <QtCore/QDir>
con's avatar
con committed
40

41 42
QT_FORWARD_DECLARE_CLASS(QProcess)

con's avatar
con committed
43 44 45
namespace CMakeProjectManager {
namespace Internal {

46
class CMakeSettingsPage;
dt's avatar
dt committed
47
class CMakeRunner;
48

con's avatar
con committed
49 50 51 52
class CMakeManager : public ProjectExplorer::IProjectManager
{
    Q_OBJECT
public:
53
    CMakeManager(CMakeSettingsPage *cmakeSettingsPage);
con's avatar
con committed
54 55 56 57 58 59

    virtual int projectContext() const;
    virtual int projectLanguage() const;

    virtual ProjectExplorer::Project *openProject(const QString &fileName);
    virtual QString mimeType() const;
dt's avatar
dt committed
60 61
    QString cmakeExecutable() const;

62 63 64
    QProcess* createXmlFile(const QStringList &arguments,
                            const QString &sourceDirectory,
                            const QDir &buildDirectory,
65 66 67
                            const ProjectExplorer::Environment &env,
                            const QString &generator);
    bool hasCodeBlocksMsvcGenerator() const;
68
    static QString findCbpFile(const QDir &);
69 70

    static QString findDumperLibrary(const ProjectExplorer::Environment &env);
con's avatar
con committed
71
private:
72
    static QString qtVersionForQMake(const QString &qmakePath);
73
    static QPair<QString, QString> findQtDir(const ProjectExplorer::Environment &env);
con's avatar
con committed
74 75
    int m_projectContext;
    int m_projectLanguage;
76 77 78
    CMakeSettingsPage *m_settingsPage;
};

dt's avatar
dt committed
79 80 81 82 83 84 85 86
class CMakeRunner
{
public:
    CMakeRunner();
    void setExecutable(const QString &executable);
    QString executable() const;
    QString version() const;
    bool supportsQtCreator() const;
87
    bool hasCodeBlocksMsvcGenerator() const;
dt's avatar
dt committed
88 89

private:
90 91
    void run(QFutureInterface<void> &fi);
    void waitForUpToDate() const;
dt's avatar
dt committed
92 93 94
    QString m_executable;
    QString m_version;
    bool m_supportsQtCreator;
95
    bool m_hasCodeBlocksMsvcGenerator;
dt's avatar
dt committed
96 97 98 99 100
    bool m_cacheUpToDate;
    mutable QFuture<void> m_future;
    mutable QMutex m_mutex;
};

101 102 103 104 105 106
class CMakeSettingsPage : public Core::IOptionsPage
{
    Q_OBJECT
public:
    CMakeSettingsPage();
    virtual ~CMakeSettingsPage();
107 108
    virtual QString id() const;
    virtual QString trName() const;
109 110 111 112 113 114 115 116 117
    virtual QString category() const;
    virtual QString trCategory() const;

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

    QString cmakeExecutable() const;
    void askUserForCMakeExecutable();
118
    bool hasCodeBlocksMsvcGenerator() const;
119
private:
120
    void updateCachedInformation() const;
121 122
    void saveSettings() const;
    QString findCmakeExecutable() const;
dt's avatar
dt committed
123 124

    mutable CMakeRunner m_cmakeRunner;
125
    Core::Utils::PathChooser *m_pathchooser;
con's avatar
con committed
126
};
hjk's avatar
hjk committed
127 128 129 130

} // namespace Internal
} // namespace CMakeProjectManager

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