cmakeprojectmanager.h 4.4 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** 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
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22 23 24 25
** 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
hjk's avatar
hjk committed
29

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

#include <projectexplorer/iprojectmanager.h>
34
#include <coreplugin/dialogs/ioptionspage.h>
35 36
#include <projectexplorer/project.h>
#include <projectexplorer/projectnodes.h>
37
#include <coreplugin/icontext.h>
38
#include <texteditor/codeassist/keywordscompletionassist.h>
39

40
#include <utils/environment.h>
41
#include <utils/pathchooser.h>
42

43
#include <QAction>
44
#include <QCheckBox>
45
#include <QDir>
46 47 48
#include <QFuture>
#include <QPointer>
#include <QStringList>
49
#include <QVector>
con's avatar
con committed
50

51 52
#include "cmakevalidator.h"

53
QT_FORWARD_DECLARE_CLASS(QLabel)
54

55
namespace Utils { class QtcProcess; }
56

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;
Peter Kümmel's avatar
Peter Kümmel committed
83
    bool hasCodeBlocksNinjaGenerator() const;
84
    bool preferNinja() const;
85
    static QString findCbpFile(const QDir &);
86

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

class CMakeSettingsPage : public Core::IOptionsPage
{
    Q_OBJECT
105

106 107
public:
    CMakeSettingsPage();
108
    ~CMakeSettingsPage();
109

110
    QWidget *widget();
111 112
    void apply();
    void finish();
113 114

    QString cmakeExecutable() const;
115
    void setCMakeExecutable(const QString &executable);
dt's avatar
dt committed
116
    bool isCMakeExecutableValid() const;
117
    bool hasCodeBlocksMsvcGenerator() const;
Peter Kümmel's avatar
Peter Kümmel committed
118
    bool hasCodeBlocksNinjaGenerator() const;
119
    bool preferNinja() const;
120

121
    TextEditor::Keywords keywords();
122

123 124 125
private:
    void saveSettings() const;
    QString findCmakeExecutable() const;
dt's avatar
dt committed
126

127
    QPointer<QWidget> m_widget;
128
    Utils::PathChooser *m_pathchooser;
129
    QCheckBox *m_preferNinja;
130 131
    CMakeValidator m_cmakeValidatorForUser;
    CMakeValidator m_cmakeValidatorForSystem;
con's avatar
con committed
132
};
hjk's avatar
hjk committed
133 134 135 136

} // namespace Internal
} // namespace CMakeProjectManager

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