1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef CMAKEPROJECTMANAGER_H
34 #define CMAKEPROJECTMANAGER_H
36 #include <projectexplorer/iprojectmanager.h>
37 #include <coreplugin/dialogs/ioptionspage.h>
38 #include <projectexplorer/project.h>
39 #include <projectexplorer/projectnodes.h>
40 #include <coreplugin/icontext.h>
42 #include <utils/environment.h>
43 #include <utils/pathchooser.h>
45 #include <QtCore/QFuture>
46 #include <QtCore/QStringList>
47 #include <QtCore/QDir>
48 #include <QtGui/QAction>
50 QT_FORWARD_DECLARE_CLASS(QProcess)
51 QT_FORWARD_DECLARE_CLASS(QLabel)
57 namespace CMakeProjectManager {
60 class CMakeSettingsPage;
62 class CMakeManager : public ProjectExplorer::IProjectManager
66 CMakeManager(CMakeSettingsPage *cmakeSettingsPage);
68 virtual Core::Context projectContext() const;
69 virtual Core::Context projectLanguage() const;
71 virtual ProjectExplorer::Project *openProject(const QString &fileName);
72 virtual QString mimeType() const;
74 QString cmakeExecutable() const;
75 bool isCMakeExecutableValid() const;
77 void setCMakeExecutable(const QString &executable);
79 void createXmlFile(Utils::QtcProcess *process,
80 const QString &arguments,
81 const QString &sourceDirectory,
82 const QDir &buildDirectory,
83 const Utils::Environment &env,
84 const QString &generator);
85 bool hasCodeBlocksMsvcGenerator() const;
86 static QString findCbpFile(const QDir &);
88 static QString findDumperLibrary(const Utils::Environment &env);
90 void updateContextMenu(ProjectExplorer::Project *project, ProjectExplorer::Node *node);
92 void runCMakeContextMenu();
94 void runCMake(ProjectExplorer::Project *project);
95 static QString qtVersionForQMake(const QString &qmakePath);
96 static QPair<QString, QString> findQtDir(const Utils::Environment &env);
97 Core::Context m_projectContext;
98 Core::Context m_projectLanguage;
99 CMakeSettingsPage *m_settingsPage;
100 QAction *m_runCMakeAction;
101 QAction *m_runCMakeActionContextMenu;
102 ProjectExplorer::Project *m_contextProject;
105 struct CMakeValidator
107 enum STATE { VALID, INVALID, RUNNING };
110 bool hasCodeBlocksMsvcGenerator;
115 class CMakeSettingsPage : public Core::IOptionsPage
120 virtual ~CMakeSettingsPage();
121 virtual QString id() const;
122 virtual QString displayName() const;
123 virtual QString category() const;
124 virtual QString displayCategory() const;
125 virtual QIcon categoryIcon() const;
127 virtual QWidget *createPage(QWidget *parent);
128 virtual void apply();
129 virtual void finish();
131 QString cmakeExecutable() const;
132 void setCMakeExecutable(const QString &executable);
133 bool isCMakeExecutableValid() const;
134 bool hasCodeBlocksMsvcGenerator() const;
136 void userCmakeFinished();
137 void pathCmakeFinished();
139 void cmakeFinished(CMakeValidator *cmakeValidator) const;
140 void saveSettings() const;
141 QString findCmakeExecutable() const;
142 void startProcess(CMakeValidator *cmakeValidator);
143 void updateInfo(CMakeValidator *cmakeValidator);
145 Utils::PathChooser *m_pathchooser;
146 mutable CMakeValidator m_userCmake;
147 mutable CMakeValidator m_pathCmake;
150 } // namespace Internal
151 } // namespace CMakeProjectManager
153 #endif // CMAKEPROJECTMANAGER_H