cmakeprojectmanager.h 3.79 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 8
**
** Contact:  Qt Software Information (qt-info@nokia.com)
**
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 26
** If you are unsure which license is appropriate for your use, please
** contact the sales department at qt-sales@nokia.com.
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 65
    QProcess* createXmlFile(const QStringList &arguments,
                            const QString &sourceDirectory,
                            const QDir &buildDirectory,
                            const ProjectExplorer::Environment &env);
66
    static QString findCbpFile(const QDir &);
67 68

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

dt's avatar
dt committed
77 78 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;

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

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

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

    QString cmakeExecutable() const;
    void askUserForCMakeExecutable();
private:
115
    void updateCachedInformation() const;
116 117
    void saveSettings() const;
    QString findCmakeExecutable() const;
dt's avatar
dt committed
118 119

    mutable CMakeRunner m_cmakeRunner;
120
    Core::Utils::PathChooser *m_pathchooser;
con's avatar
con committed
121
};
hjk's avatar
hjk committed
122 123 124 125

} // namespace Internal
} // namespace CMakeProjectManager

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