| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | /****************************************************************************
 | 
					
						
							| 
									
										
										
										
											2009-03-20 14:57:12 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2014-01-07 13:27:11 +01:00
										 |  |  | ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** Contact: http://www.qt-project.org/legal
 | 
					
						
							| 
									
										
										
										
											2009-03-20 14:57:12 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** This file is part of Qt Creator. | 
					
						
							| 
									
										
										
										
											2009-03-20 14:57:12 +01:00
										 |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** 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.
 | 
					
						
							| 
									
										
										
										
											2009-03-20 14:57:12 +01:00
										 |  |  | ** | 
					
						
							|  |  |  | ** GNU Lesser General Public License Usage | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ** 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 | 
					
						
							| 
									
										
										
										
											2010-12-17 16:01:08 +01:00
										 |  |  | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | 
					
						
							|  |  |  | ** | 
					
						
							| 
									
										
										
										
											2012-10-02 09:12:39 +02:00
										 |  |  | ****************************************************************************/ | 
					
						
							| 
									
										
										
										
											2009-03-20 14:57:12 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | #include "cmakeopenprojectwizard.h"
 | 
					
						
							|  |  |  | #include "cmakeprojectmanager.h"
 | 
					
						
							| 
									
										
										
										
											2012-09-12 20:21:01 +02:00
										 |  |  | #include "cmakebuildconfiguration.h"
 | 
					
						
							| 
									
										
										
										
											2013-07-22 15:53:57 +02:00
										 |  |  | #include "cmakebuildinfo.h"
 | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-08-21 19:35:41 +02:00
										 |  |  | #include <coreplugin/icore.h>
 | 
					
						
							| 
									
										
										
										
											2012-09-19 11:15:13 +02:00
										 |  |  | #include <utils/hostosinfo.h>
 | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | #include <utils/pathchooser.h>
 | 
					
						
							| 
									
										
										
										
											2012-08-23 14:26:24 +02:00
										 |  |  | #include <utils/fancylineedit.h>
 | 
					
						
							| 
									
										
										
										
											2013-02-15 13:50:03 +08:00
										 |  |  | #include <utils/historycompleter.h>
 | 
					
						
							| 
									
										
										
										
											2012-09-03 18:31:44 +02:00
										 |  |  | #include <projectexplorer/kitinformation.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/kitmanager.h>
 | 
					
						
							| 
									
										
										
										
											2011-08-18 13:46:52 +02:00
										 |  |  | #include <projectexplorer/toolchain.h>
 | 
					
						
							|  |  |  | #include <projectexplorer/abi.h>
 | 
					
						
							| 
									
										
										
										
											2013-02-13 13:38:28 +01:00
										 |  |  | #include <projectexplorer/projectexplorerconstants.h>
 | 
					
						
							| 
									
										
										
										
											2011-04-27 15:51:35 +02:00
										 |  |  | #include <texteditor/fontsettings.h>
 | 
					
						
							| 
									
										
										
										
											2013-07-07 23:49:13 +02:00
										 |  |  | #include <remotelinux/remotelinux_constants.h>
 | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-15 10:42:41 +01:00
										 |  |  | #include <QVBoxLayout>
 | 
					
						
							|  |  |  | #include <QFormLayout>
 | 
					
						
							|  |  |  | #include <QLabel>
 | 
					
						
							|  |  |  | #include <QPushButton>
 | 
					
						
							|  |  |  | #include <QPlainTextEdit>
 | 
					
						
							|  |  |  | #include <QDateTime>
 | 
					
						
							| 
									
										
										
										
											2012-08-21 19:35:41 +02:00
										 |  |  | #include <QSettings>
 | 
					
						
							| 
									
										
										
										
											2012-02-15 10:42:41 +01:00
										 |  |  | #include <QStringList>
 | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | #include <QApplication>
 | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | using namespace CMakeProjectManager; | 
					
						
							|  |  |  | using namespace CMakeProjectManager::Internal; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ///////
 | 
					
						
							|  |  |  | //  Page Flow:
 | 
					
						
							|  |  |  | //   Start (No .user file)
 | 
					
						
							|  |  |  | //    |
 | 
					
						
							|  |  |  | //    |---> In Source Build --> Page: Tell the user about that
 | 
					
						
							|  |  |  | //                               |--> Already existing cbp file (and new enough) --> Page: Ready to load the project
 | 
					
						
							|  |  |  | //                               |--> Page: Ask for cmd options, run generator
 | 
					
						
							|  |  |  | //    |---> No in source Build --> Page: Ask the user for the build directory
 | 
					
						
							|  |  |  | //                                   |--> Already existing cbp file (and new enough) --> Page: Ready to load the project
 | 
					
						
							|  |  |  | //                                   |--> Page: Ask for cmd options, run generator
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-09-12 20:21:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | namespace CMakeProjectManager { | 
					
						
							|  |  |  | namespace Internal { | 
					
						
							|  |  |  |     class GeneratorInfo | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2013-01-28 17:29:33 +01:00
										 |  |  |         Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::Internal::GeneratorInfo) | 
					
						
							| 
									
										
										
										
											2012-09-12 20:21:01 +02:00
										 |  |  |     public: | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |         enum Ninja { NoNinja, OfferNinja, ForceNinja }; | 
					
						
							| 
									
										
										
										
											2013-02-16 14:54:13 +08:00
										 |  |  |         static QList<GeneratorInfo> generatorInfosFor(ProjectExplorer::Kit *k, Ninja n, bool preferNinja, bool hasCodeBlocks); | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         GeneratorInfo(); | 
					
						
							|  |  |  |         explicit GeneratorInfo(ProjectExplorer::Kit *kit, bool ninja = false); | 
					
						
							| 
									
										
										
										
											2012-09-12 20:21:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |         ProjectExplorer::Kit *kit() const; | 
					
						
							|  |  |  |         bool isNinja() const; | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |         QString displayName() const; | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  |         QByteArray generatorArgument() const; | 
					
						
							|  |  |  |         QByteArray generator() const; | 
					
						
							| 
									
										
										
										
											2012-09-12 20:21:01 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     private: | 
					
						
							|  |  |  |         ProjectExplorer::Kit *m_kit; | 
					
						
							|  |  |  |         bool m_isNinja; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Q_DECLARE_METATYPE(CMakeProjectManager::Internal::GeneratorInfo); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | GeneratorInfo::GeneratorInfo() | 
					
						
							|  |  |  |     : m_kit(0), m_isNinja(false) | 
					
						
							|  |  |  | {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | GeneratorInfo::GeneratorInfo(ProjectExplorer::Kit *kit, bool ninja) | 
					
						
							|  |  |  |     : m_kit(kit), m_isNinja(ninja) | 
					
						
							|  |  |  | {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ProjectExplorer::Kit *GeneratorInfo::kit() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_kit; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool GeneratorInfo::isNinja() const { | 
					
						
							|  |  |  |     return m_isNinja; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  | QByteArray GeneratorInfo::generator() const | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     if (!m_kit) | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  |         return QByteArray(); | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(m_kit); | 
					
						
							|  |  |  |     ProjectExplorer::Abi targetAbi = tc->targetAbi(); | 
					
						
							|  |  |  |     if (m_isNinja) { | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  |         return "Ninja"; | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     } else if (targetAbi.os() == ProjectExplorer::Abi::WindowsOS) { | 
					
						
							|  |  |  |         if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2005Flavor | 
					
						
							|  |  |  |                 || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2008Flavor | 
					
						
							|  |  |  |                 || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2010Flavor | 
					
						
							|  |  |  |                 || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2012Flavor) { | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  |             return "NMake Makefiles"; | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |         } else if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor) { | 
					
						
							| 
									
										
										
										
											2012-10-05 20:51:31 +02:00
										 |  |  |             if (Utils::HostOsInfo::isWindowsHost()) | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  |                 return "MinGW Makefiles"; | 
					
						
							| 
									
										
										
										
											2012-10-05 20:51:31 +02:00
										 |  |  |             else | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  |                 return "Unix Makefiles"; | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  |     return "Unix Makefiles"; | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:12 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  | QByteArray GeneratorInfo::generatorArgument() const | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  |     QByteArray tmp = generator(); | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     if (tmp.isEmpty()) | 
					
						
							|  |  |  |         return tmp; | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  |     return QByteArray("-GCodeBlocks - ") + tmp; | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString GeneratorInfo::displayName() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (!m_kit) | 
					
						
							|  |  |  |         return QString(); | 
					
						
							|  |  |  |     if (m_isNinja) | 
					
						
							| 
									
										
										
										
											2013-01-28 17:29:33 +01:00
										 |  |  |         return tr("Ninja (%1)").arg(m_kit->displayName()); | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(m_kit); | 
					
						
							|  |  |  |     ProjectExplorer::Abi targetAbi = tc->targetAbi(); | 
					
						
							|  |  |  |     if (targetAbi.os() == ProjectExplorer::Abi::WindowsOS) { | 
					
						
							|  |  |  |         if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2005Flavor | 
					
						
							|  |  |  |                 || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2008Flavor | 
					
						
							|  |  |  |                 || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2010Flavor | 
					
						
							|  |  |  |                 || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2012Flavor) { | 
					
						
							| 
									
										
										
										
											2013-01-28 17:29:33 +01:00
										 |  |  |             return tr("NMake Generator (%1)").arg(m_kit->displayName()); | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |         } else if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor) { | 
					
						
							| 
									
										
										
										
											2012-10-05 20:51:31 +02:00
										 |  |  |             if (Utils::HostOsInfo::isWindowsHost()) | 
					
						
							| 
									
										
										
										
											2013-01-28 17:29:33 +01:00
										 |  |  |                 return tr("MinGW Generator (%1)").arg(m_kit->displayName()); | 
					
						
							| 
									
										
										
										
											2012-10-05 20:51:31 +02:00
										 |  |  |             else | 
					
						
							| 
									
										
										
										
											2013-01-28 17:29:33 +01:00
										 |  |  |                 return tr("Unix Generator (%1)").arg(m_kit->displayName()); | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         // Non windows
 | 
					
						
							| 
									
										
										
										
											2013-01-28 17:29:33 +01:00
										 |  |  |         return tr("Unix Generator (%1)").arg(m_kit->displayName()); | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     } | 
					
						
							|  |  |  |     return QString(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-16 14:54:13 +08:00
										 |  |  | QList<GeneratorInfo> GeneratorInfo::generatorInfosFor(ProjectExplorer::Kit *k, Ninja n, bool preferNinja, bool hasCodeBlocks) | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     QList<GeneratorInfo> results; | 
					
						
							|  |  |  |     ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k); | 
					
						
							| 
									
										
										
										
											2012-11-05 12:37:34 +01:00
										 |  |  |     if (!tc) | 
					
						
							|  |  |  |         return results; | 
					
						
							| 
									
										
										
										
											2013-05-23 15:30:01 +02:00
										 |  |  |     Core::Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(k); | 
					
						
							| 
									
										
										
										
											2013-07-07 23:49:13 +02:00
										 |  |  |     if (deviceType !=  ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE | 
					
						
							|  |  |  |             && deviceType != RemoteLinux::Constants::GenericLinuxOsType) | 
					
						
							| 
									
										
										
										
											2013-05-23 15:30:01 +02:00
										 |  |  |         return results; | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     ProjectExplorer::Abi targetAbi = tc->targetAbi(); | 
					
						
							|  |  |  |     if (n != ForceNinja) { | 
					
						
							|  |  |  |         if (targetAbi.os() == ProjectExplorer::Abi::WindowsOS) { | 
					
						
							|  |  |  |             if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2005Flavor | 
					
						
							|  |  |  |                     || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2008Flavor | 
					
						
							|  |  |  |                     || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2010Flavor | 
					
						
							|  |  |  |                     || targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMsvc2012Flavor) { | 
					
						
							|  |  |  |                 if (hasCodeBlocks) | 
					
						
							|  |  |  |                     results << GeneratorInfo(k); | 
					
						
							|  |  |  |             } else if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor) { | 
					
						
							|  |  |  |                 results << GeneratorInfo(k); | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             // Non windows
 | 
					
						
							|  |  |  |             results << GeneratorInfo(k); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2013-02-16 14:54:13 +08:00
										 |  |  |     if (n != NoNinja) { | 
					
						
							|  |  |  |         if (preferNinja) | 
					
						
							|  |  |  |             results.prepend(GeneratorInfo(k, true)); | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |             results.append(GeneratorInfo(k, true)); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     return results; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //////////////
 | 
					
						
							|  |  |  | /// CMakeOpenProjectWizard
 | 
					
						
							|  |  |  | //////////////
 | 
					
						
							| 
									
										
										
										
											2012-09-12 20:21:01 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, Utils::Environment env) | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  |     : m_cmakeManager(cmakeManager), | 
					
						
							| 
									
										
										
										
											2009-03-16 17:33:05 +01:00
										 |  |  |       m_sourceDirectory(sourceDirectory), | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |       m_environment(env), | 
					
						
							|  |  |  |       m_useNinja(false), | 
					
						
							|  |  |  |       m_kit(0) | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-02-13 13:38:28 +01:00
										 |  |  |     if (!compatibleKitExist()) | 
					
						
							|  |  |  |         addPage(new NoKitPage(this)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  |     if (hasInSourceBuild()) { | 
					
						
							|  |  |  |         m_buildDirectory = m_sourceDirectory; | 
					
						
							| 
									
										
										
										
											2012-10-12 16:26:35 +02:00
										 |  |  |         addPage(new InSourceBuildPage(this)); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2012-01-04 21:02:34 +08:00
										 |  |  |         m_buildDirectory = m_sourceDirectory + QLatin1String("-build"); | 
					
						
							| 
									
										
										
										
											2012-10-12 16:26:35 +02:00
										 |  |  |         addPage(new ShadowBuildPage(this)); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-12 16:53:57 +02:00
										 |  |  |     if (!m_cmakeManager->isCMakeExecutableValid()) | 
					
						
							|  |  |  |         addPage(new ChooseCMakePage(this)); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-12 16:26:35 +02:00
										 |  |  |     addPage(new CMakeRunPage(this)); | 
					
						
							| 
									
										
										
										
											2010-03-31 14:48:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-10 16:03:16 +02:00
										 |  |  |     init(); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, CMakeOpenProjectWizard::Mode mode, | 
					
						
							| 
									
										
										
										
											2013-07-22 15:53:57 +02:00
										 |  |  |                                                const CMakeBuildInfo *info) | 
					
						
							| 
									
										
										
										
											2009-03-16 17:33:05 +01:00
										 |  |  |     : m_cmakeManager(cmakeManager), | 
					
						
							| 
									
										
										
										
											2013-07-22 15:53:57 +02:00
										 |  |  |       m_sourceDirectory(info->sourceDirectory), | 
					
						
							|  |  |  |       m_environment(info->environment), | 
					
						
							|  |  |  |       m_useNinja(info->useNinja), | 
					
						
							|  |  |  |       m_kit(0) | 
					
						
							| 
									
										
										
										
											2009-03-16 17:33:05 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2013-07-22 15:53:57 +02:00
										 |  |  |     m_kit = ProjectExplorer::KitManager::find(info->kitId); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-02 13:57:14 +02:00
										 |  |  |     CMakeRunPage::Mode rmode; | 
					
						
							| 
									
										
										
										
											2009-05-26 15:50:27 +02:00
										 |  |  |     if (mode == CMakeOpenProjectWizard::NeedToCreate) | 
					
						
							| 
									
										
										
										
											2010-09-02 13:57:14 +02:00
										 |  |  |         rmode = CMakeRunPage::Recreate; | 
					
						
							|  |  |  |     else if (mode == CMakeOpenProjectWizard::WantToUpdate) | 
					
						
							|  |  |  |         rmode = CMakeRunPage::WantToUpdate; | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     else if (mode == CMakeOpenProjectWizard::NeedToUpdate) | 
					
						
							| 
									
										
										
										
											2010-09-02 13:57:14 +02:00
										 |  |  |         rmode = CMakeRunPage::NeedToUpdate; | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     else | 
					
						
							|  |  |  |         rmode = CMakeRunPage::ChangeDirectory; | 
					
						
							| 
									
										
										
										
											2009-03-16 17:33:05 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     if (mode == CMakeOpenProjectWizard::ChangeDirectory) { | 
					
						
							| 
									
										
										
										
											2013-07-22 15:53:57 +02:00
										 |  |  |         m_buildDirectory = info->buildDirectory.toString(); | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |         addPage(new ShadowBuildPage(this, true)); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-10-12 16:53:57 +02:00
										 |  |  |     if (!m_cmakeManager->isCMakeExecutableValid()) | 
					
						
							|  |  |  |         addPage(new ChooseCMakePage(this)); | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-22 15:53:57 +02:00
										 |  |  |     addPage(new CMakeRunPage(this, rmode, info->buildDirectory.toString())); | 
					
						
							| 
									
										
										
										
											2009-06-10 16:03:16 +02:00
										 |  |  |     init(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void CMakeOpenProjectWizard::init() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     setWindowTitle(tr("CMake Wizard")); | 
					
						
							| 
									
										
										
										
											2009-04-20 14:35:25 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | CMakeManager *CMakeOpenProjectWizard::cmakeManager() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_cmakeManager; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool CMakeOpenProjectWizard::hasInSourceBuild() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  |     QFileInfo fi(m_sourceDirectory + QLatin1String("/CMakeCache.txt")); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  |     if (fi.exists()) | 
					
						
							|  |  |  |         return true; | 
					
						
							|  |  |  |     return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-13 13:38:28 +01:00
										 |  |  | bool CMakeOpenProjectWizard::compatibleKitExist() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     bool hasCodeBlocksGenerator = m_cmakeManager->hasCodeBlocksMsvcGenerator(); | 
					
						
							|  |  |  |     bool hasNinjaGenerator = m_cmakeManager->hasCodeBlocksNinjaGenerator(); | 
					
						
							| 
									
										
										
										
											2013-02-16 14:54:13 +08:00
										 |  |  |     bool preferNinja = m_cmakeManager->preferNinja(); | 
					
						
							| 
									
										
										
										
											2013-02-13 13:38:28 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-21 12:48:46 +02:00
										 |  |  |     QList<ProjectExplorer::Kit *> kitList = ProjectExplorer::KitManager::kits(); | 
					
						
							| 
									
										
										
										
											2013-02-13 13:38:28 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     foreach (ProjectExplorer::Kit *k, kitList) { | 
					
						
							|  |  |  |         // OfferNinja and ForceNinja differ in what they return
 | 
					
						
							|  |  |  |         // but not whether the list is empty or not, which is what we
 | 
					
						
							|  |  |  |         // are interested in here
 | 
					
						
							|  |  |  |         QList<GeneratorInfo> infos = GeneratorInfo::generatorInfosFor(k, | 
					
						
							|  |  |  |                                                                       hasNinjaGenerator ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja, | 
					
						
							| 
									
										
										
										
											2013-02-16 14:54:13 +08:00
										 |  |  |                                                                       preferNinja, | 
					
						
							| 
									
										
										
										
											2013-02-13 13:38:28 +01:00
										 |  |  |                                                                       hasCodeBlocksGenerator); | 
					
						
							|  |  |  |         if (!infos.isEmpty()) | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | bool CMakeOpenProjectWizard::existsUpToDateXmlFile() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QString cbpFile = CMakeManager::findCbpFile(QDir(buildDirectory())); | 
					
						
							|  |  |  |     if (!cbpFile.isEmpty()) { | 
					
						
							|  |  |  |         // We already have a cbp file
 | 
					
						
							|  |  |  |         QFileInfo cbpFileInfo(cbpFile); | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  |         QFileInfo cmakeListsFileInfo(sourceDirectory() + QLatin1String("/CMakeLists.txt")); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (cbpFileInfo.lastModified() > cmakeListsFileInfo.lastModified()) | 
					
						
							|  |  |  |             return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return false; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString CMakeOpenProjectWizard::buildDirectory() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_buildDirectory; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString CMakeOpenProjectWizard::sourceDirectory() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_sourceDirectory; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void CMakeOpenProjectWizard::setBuildDirectory(const QString &directory) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_buildDirectory = directory; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | bool CMakeOpenProjectWizard::useNinja() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_useNinja; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void CMakeOpenProjectWizard::setUseNinja(bool b) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_useNinja = b; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-01 18:36:00 +01:00
										 |  |  | QString CMakeOpenProjectWizard::arguments() const | 
					
						
							| 
									
										
										
										
											2009-07-02 16:44:51 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-02-01 18:36:00 +01:00
										 |  |  |     return m_arguments; | 
					
						
							| 
									
										
										
										
											2009-07-02 16:44:51 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-02-01 18:36:00 +01:00
										 |  |  | void CMakeOpenProjectWizard::setArguments(const QString &args) | 
					
						
							| 
									
										
										
										
											2009-07-02 16:44:51 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2011-02-01 18:36:00 +01:00
										 |  |  |     m_arguments = args; | 
					
						
							| 
									
										
										
										
											2009-07-02 16:44:51 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-23 10:35:23 +02:00
										 |  |  | Utils::Environment CMakeOpenProjectWizard::environment() const | 
					
						
							| 
									
										
										
										
											2009-05-26 16:10:13 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     return m_environment; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ProjectExplorer::Kit *CMakeOpenProjectWizard::kit() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_kit; | 
					
						
							| 
									
										
										
										
											2009-05-26 16:10:13 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | void CMakeOpenProjectWizard::setKit(ProjectExplorer::Kit *kit) | 
					
						
							| 
									
										
										
										
											2012-09-12 20:21:01 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     m_kit = kit; | 
					
						
							| 
									
										
										
										
											2012-09-12 20:21:01 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-13 13:38:28 +01:00
										 |  |  | //////
 | 
					
						
							|  |  |  | // NoKitPage
 | 
					
						
							|  |  |  | /////
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | NoKitPage::NoKitPage(CMakeOpenProjectWizard *cmakeWizard) | 
					
						
							|  |  |  |     : QWizardPage(cmakeWizard), m_cmakeWizard(cmakeWizard) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QVBoxLayout *layout = new QVBoxLayout; | 
					
						
							|  |  |  |     setLayout(layout); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_descriptionLabel = new QLabel(this); | 
					
						
							|  |  |  |     m_descriptionLabel->setWordWrap(true); | 
					
						
							|  |  |  |     layout->addWidget(m_descriptionLabel); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_optionsButton = new QPushButton; | 
					
						
							| 
									
										
										
										
											2014-02-20 14:52:10 +01:00
										 |  |  |     m_optionsButton->setText(Core::ICore::msgShowOptionsDialog()); | 
					
						
							| 
									
										
										
										
											2013-02-13 13:38:28 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     connect(m_optionsButton, SIGNAL(clicked()), | 
					
						
							|  |  |  |             this, SLOT(showOptions())); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QHBoxLayout *hbox = new QHBoxLayout; | 
					
						
							|  |  |  |     hbox->addWidget(m_optionsButton); | 
					
						
							|  |  |  |     hbox->addStretch(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     layout->addLayout(hbox); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     setTitle(tr("Check Kits")); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     connect(ProjectExplorer::KitManager::instance(), SIGNAL(kitsChanged()), | 
					
						
							|  |  |  |             this, SLOT(kitsChanged())); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     kitsChanged(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NoKitPage::kitsChanged() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (isComplete()) { | 
					
						
							|  |  |  |         m_descriptionLabel->setText(tr("There are compatible kits.")); | 
					
						
							|  |  |  |         m_optionsButton->setVisible(false); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |         m_descriptionLabel->setText(tr("Qt Creator has no kits that are suitable for CMake projects. Please configure a kit.")); | 
					
						
							|  |  |  |         m_optionsButton->setVisible(true); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     emit completeChanged(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool NoKitPage::isComplete() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_cmakeWizard->compatibleKitExist(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void NoKitPage::showOptions() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Core::ICore::showOptionsDialog(Core::Id(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY), | 
					
						
							|  |  |  |                                    Core::Id(ProjectExplorer::Constants::KITS_SETTINGS_PAGE_ID), this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | InSourceBuildPage::InSourceBuildPage(CMakeOpenProjectWizard *cmakeWizard) | 
					
						
							|  |  |  |     : QWizardPage(cmakeWizard), m_cmakeWizard(cmakeWizard) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     setLayout(new QVBoxLayout); | 
					
						
							|  |  |  |     QLabel *label = new QLabel(this); | 
					
						
							|  |  |  |     label->setWordWrap(true); | 
					
						
							| 
									
										
										
										
											2009-08-13 17:36:56 +02:00
										 |  |  |     label->setText(tr("Qt Creator has detected an <b>in-source-build in %1</b> " | 
					
						
							| 
									
										
										
										
											2009-05-07 15:34:52 +02:00
										 |  |  |                    "which prevents shadow builds. Qt Creator will not allow you to change the build directory. " | 
					
						
							| 
									
										
										
										
											2009-12-03 19:45:09 +01:00
										 |  |  |                    "If you want a shadow build, clean your source directory and re-open the project.") | 
					
						
							|  |  |  |                    .arg(m_cmakeWizard->buildDirectory())); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  |     layout()->addWidget(label); | 
					
						
							| 
									
										
										
										
											2010-03-31 14:48:08 +02:00
										 |  |  |     setTitle(tr("Build Location")); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-20 14:35:25 +02:00
										 |  |  | ShadowBuildPage::ShadowBuildPage(CMakeOpenProjectWizard *cmakeWizard, bool change) | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  |     : QWizardPage(cmakeWizard), m_cmakeWizard(cmakeWizard) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QFormLayout *fl = new QFormLayout; | 
					
						
							|  |  |  |     this->setLayout(fl); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QLabel *label = new QLabel(this); | 
					
						
							|  |  |  |     label->setWordWrap(true); | 
					
						
							| 
									
										
										
										
											2009-04-20 14:35:25 +02:00
										 |  |  |     if (change) | 
					
						
							| 
									
										
										
										
											2013-10-17 14:52:10 +02:00
										 |  |  |         label->setText(tr("Please enter the directory in which you want to build your project.") + QLatin1Char(' ')); | 
					
						
							| 
									
										
										
										
											2009-04-20 14:35:25 +02:00
										 |  |  |     else | 
					
						
							|  |  |  |         label->setText(tr("Please enter the directory in which you want to build your project. " | 
					
						
							|  |  |  |                           "Qt Creator recommends to not use the source directory for building. " | 
					
						
							|  |  |  |                           "This ensures that the source directory remains clean and enables multiple builds " | 
					
						
							|  |  |  |                           "with different settings.")); | 
					
						
							| 
									
										
										
										
											2011-07-07 09:26:00 +02:00
										 |  |  |     fl->addRow(label); | 
					
						
							| 
									
										
										
										
											2009-10-05 11:06:05 +02:00
										 |  |  |     m_pc = new Utils::PathChooser(this); | 
					
						
							| 
									
										
										
										
											2010-09-17 14:58:07 +02:00
										 |  |  |     m_pc->setBaseDirectory(m_cmakeWizard->sourceDirectory()); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  |     m_pc->setPath(m_cmakeWizard->buildDirectory()); | 
					
						
							| 
									
										
										
										
											2011-11-04 12:36:00 +01:00
										 |  |  |     m_pc->setExpectedKind(Utils::PathChooser::Directory); | 
					
						
							| 
									
										
										
										
											2013-11-25 14:32:41 +01:00
										 |  |  |     m_pc->setHistoryCompleter(QLatin1String("Cmake.BuildDir.History")); | 
					
						
							| 
									
										
										
										
											2009-06-19 17:55:47 +02:00
										 |  |  |     connect(m_pc, SIGNAL(changed(QString)), this, SLOT(buildDirectoryChanged())); | 
					
						
							| 
									
										
										
										
											2009-04-17 21:11:52 +02:00
										 |  |  |     fl->addRow(tr("Build directory:"), m_pc); | 
					
						
							| 
									
										
										
										
											2010-03-31 14:48:08 +02:00
										 |  |  |     setTitle(tr("Build Location")); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ShadowBuildPage::buildDirectoryChanged() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_cmakeWizard->setBuildDirectory(m_pc->path()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-12 16:53:57 +02:00
										 |  |  | ChooseCMakePage::ChooseCMakePage(CMakeOpenProjectWizard *cmakeWizard) | 
					
						
							|  |  |  |     : QWizardPage(cmakeWizard), m_cmakeWizard(cmakeWizard) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QFormLayout *fl = new QFormLayout; | 
					
						
							|  |  |  |     fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); | 
					
						
							|  |  |  |     setLayout(fl); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     m_cmakeLabel = new QLabel; | 
					
						
							|  |  |  |     m_cmakeLabel->setWordWrap(true); | 
					
						
							|  |  |  |     fl->addRow(m_cmakeLabel); | 
					
						
							|  |  |  |     // Show a field for the user to enter
 | 
					
						
							|  |  |  |     m_cmakeExecutable = new Utils::PathChooser(this); | 
					
						
							|  |  |  |     m_cmakeExecutable->setExpectedKind(Utils::PathChooser::ExistingCommand); | 
					
						
							| 
									
										
										
										
											2013-11-25 14:32:41 +01:00
										 |  |  |     m_cmakeExecutable->setHistoryCompleter(QLatin1String("Cmake.Command.History")); | 
					
						
							| 
									
										
										
										
											2013-02-12 15:35:09 +01:00
										 |  |  |     fl->addRow(tr("CMake Executable:"), m_cmakeExecutable); | 
					
						
							| 
									
										
										
										
											2012-10-12 16:53:57 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     connect(m_cmakeExecutable, SIGNAL(editingFinished()), | 
					
						
							|  |  |  |             this, SLOT(cmakeExecutableChanged())); | 
					
						
							|  |  |  |     connect(m_cmakeExecutable, SIGNAL(browsingFinished()), | 
					
						
							|  |  |  |             this, SLOT(cmakeExecutableChanged())); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-02-12 15:35:09 +01:00
										 |  |  |     setTitle(tr("Choose CMake Executable")); | 
					
						
							| 
									
										
										
										
											2012-10-12 16:53:57 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ChooseCMakePage::updateErrorText() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QString cmakeExecutable = m_cmakeWizard->cmakeManager()->cmakeExecutable(); | 
					
						
							|  |  |  |     if (m_cmakeWizard->cmakeManager()->isCMakeExecutableValid()) { | 
					
						
							| 
									
										
										
										
											2013-02-12 15:35:09 +01:00
										 |  |  |         m_cmakeLabel->setText(tr("The CMake executable is valid.")); | 
					
						
							| 
									
										
										
										
											2012-10-12 16:53:57 +02:00
										 |  |  |     } else { | 
					
						
							| 
									
										
										
										
											2013-02-12 15:35:09 +01:00
										 |  |  |         QString text = tr("Specify the path to the CMake executable. No CMake executable was found in the path."); | 
					
						
							| 
									
										
										
										
											2012-10-12 16:53:57 +02:00
										 |  |  |         if (!cmakeExecutable.isEmpty()) { | 
					
						
							| 
									
										
										
										
											2013-10-17 14:52:10 +02:00
										 |  |  |             text += QLatin1Char(' '); | 
					
						
							| 
									
										
										
										
											2012-10-12 16:53:57 +02:00
										 |  |  |             QFileInfo fi(cmakeExecutable); | 
					
						
							|  |  |  |             if (!fi.exists()) | 
					
						
							| 
									
										
										
										
											2013-10-17 14:52:10 +02:00
										 |  |  |                 text += tr("The CMake executable (%1) does not exist.").arg(cmakeExecutable); | 
					
						
							| 
									
										
										
										
											2012-10-12 16:53:57 +02:00
										 |  |  |             else if (!fi.isExecutable()) | 
					
						
							| 
									
										
										
										
											2013-10-17 14:52:10 +02:00
										 |  |  |                 text += tr("The path %1 is not an executable.").arg(cmakeExecutable); | 
					
						
							| 
									
										
										
										
											2012-10-12 16:53:57 +02:00
										 |  |  |             else | 
					
						
							| 
									
										
										
										
											2013-10-17 14:52:10 +02:00
										 |  |  |                 text += tr("The path %1 is not a valid CMake executable.").arg(cmakeExecutable); | 
					
						
							| 
									
										
										
										
											2012-10-12 16:53:57 +02:00
										 |  |  |         } | 
					
						
							|  |  |  |         m_cmakeLabel->setText(text); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void ChooseCMakePage::cmakeExecutableChanged() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_cmakeWizard->cmakeManager()->setCMakeExecutable(m_cmakeExecutable->path()); | 
					
						
							|  |  |  |     updateErrorText(); | 
					
						
							|  |  |  |     emit completeChanged(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool ChooseCMakePage::isComplete() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return m_cmakeWizard->cmakeManager()->isCMakeExecutableValid(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-04-20 14:35:25 +02:00
										 |  |  | CMakeRunPage::CMakeRunPage(CMakeOpenProjectWizard *cmakeWizard, Mode mode, const QString &buildDirectory) | 
					
						
							| 
									
										
										
										
											2009-03-16 17:33:05 +01:00
										 |  |  |     : QWizardPage(cmakeWizard), | 
					
						
							|  |  |  |       m_cmakeWizard(cmakeWizard), | 
					
						
							| 
									
										
										
										
											2013-02-13 12:16:02 +01:00
										 |  |  |       m_haveCbpFile(false), | 
					
						
							| 
									
										
										
										
											2009-04-20 14:35:25 +02:00
										 |  |  |       m_mode(mode), | 
					
						
							|  |  |  |       m_buildDirectory(buildDirectory) | 
					
						
							| 
									
										
										
										
											2009-03-16 17:33:05 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     initWidgets(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void CMakeRunPage::initWidgets() | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     QFormLayout *fl = new QFormLayout; | 
					
						
							| 
									
										
										
										
											2011-07-07 09:26:00 +02:00
										 |  |  |     fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  |     setLayout(fl); | 
					
						
							| 
									
										
										
										
											2009-09-23 14:33:05 +02:00
										 |  |  |     // Description Label
 | 
					
						
							| 
									
										
										
										
											2009-03-16 17:33:05 +01:00
										 |  |  |     m_descriptionLabel = new QLabel(this); | 
					
						
							|  |  |  |     m_descriptionLabel->setWordWrap(true); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     fl->addRow(m_descriptionLabel); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-23 14:33:05 +02:00
										 |  |  |     // Run CMake Line (with arguments)
 | 
					
						
							| 
									
										
										
										
											2012-08-23 14:26:24 +02:00
										 |  |  |     m_argumentsLineEdit = new Utils::FancyLineEdit(this); | 
					
						
							| 
									
										
										
										
											2012-08-24 13:05:09 +02:00
										 |  |  |     m_argumentsLineEdit->setHistoryCompleter(QLatin1String("CMakeArgumentsLineEdit")); | 
					
						
							| 
									
										
										
										
											2012-10-19 22:51:57 +08:00
										 |  |  |     m_argumentsLineEdit->selectAll(); | 
					
						
							| 
									
										
										
										
											2012-08-21 19:35:41 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-09 15:45:20 +02:00
										 |  |  |     connect(m_argumentsLineEdit,SIGNAL(returnPressed()), this, SLOT(runCMake())); | 
					
						
							| 
									
										
										
										
											2011-07-07 09:26:00 +02:00
										 |  |  |     fl->addRow(tr("Arguments:"), m_argumentsLineEdit); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-02 11:30:29 +02:00
										 |  |  |     m_generatorComboBox = new QComboBox(this); | 
					
						
							| 
									
										
										
										
											2011-07-07 09:26:00 +02:00
										 |  |  |     fl->addRow(tr("Generator:"), m_generatorComboBox); | 
					
						
							| 
									
										
										
										
											2009-07-02 16:44:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  |     m_runCMake = new QPushButton(this); | 
					
						
							| 
									
										
										
										
											2009-04-06 17:07:51 +02:00
										 |  |  |     m_runCMake->setText(tr("Run CMake")); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  |     connect(m_runCMake, SIGNAL(clicked()), this, SLOT(runCMake())); | 
					
						
							| 
									
										
										
										
											2009-04-06 17:07:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-07-07 09:26:00 +02:00
										 |  |  |     QHBoxLayout *hbox2 = new QHBoxLayout; | 
					
						
							|  |  |  |     hbox2->addStretch(10); | 
					
						
							|  |  |  |     hbox2->addWidget(m_runCMake); | 
					
						
							|  |  |  |     fl->addRow(hbox2); | 
					
						
							| 
									
										
										
										
											2009-04-06 17:07:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-23 14:33:05 +02:00
										 |  |  |     // Bottom output window
 | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  |     m_output = new QPlainTextEdit(this); | 
					
						
							| 
									
										
										
										
											2009-03-31 15:02:09 +02:00
										 |  |  |     m_output->setReadOnly(true); | 
					
						
							| 
									
										
										
										
											2011-07-07 09:26:00 +02:00
										 |  |  |     // set smaller minimum size to avoid vanishing descriptions if all of the
 | 
					
						
							|  |  |  |     // above is shown and the dialog not vertically resizing to fit stuff in (Mac)
 | 
					
						
							|  |  |  |     m_output->setMinimumHeight(15); | 
					
						
							| 
									
										
										
										
											2011-04-27 15:51:35 +02:00
										 |  |  |     QFont f(TextEditor::FontSettings::defaultFixedFontFamily()); | 
					
						
							| 
									
										
										
										
											2011-04-27 14:40:14 +02:00
										 |  |  |     f.setStyleHint(QFont::TypeWriter); | 
					
						
							|  |  |  |     m_output->setFont(f); | 
					
						
							| 
									
										
										
										
											2009-04-15 16:22:55 +02:00
										 |  |  |     QSizePolicy pl = m_output->sizePolicy(); | 
					
						
							|  |  |  |     pl.setVerticalStretch(1); | 
					
						
							|  |  |  |     m_output->setSizePolicy(pl); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  |     fl->addRow(m_output); | 
					
						
							| 
									
										
										
										
											2010-10-04 17:52:55 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     m_exitCodeLabel = new QLabel(this); | 
					
						
							|  |  |  |     m_exitCodeLabel->setVisible(false); | 
					
						
							|  |  |  |     fl->addRow(m_exitCodeLabel); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-03-31 14:48:08 +02:00
										 |  |  |     setTitle(tr("Run CMake")); | 
					
						
							| 
									
										
										
										
											2011-11-22 16:56:07 +01:00
										 |  |  |     setMinimumSize(600, 400); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  | QByteArray CMakeRunPage::cachedGeneratorFromFile(const QString &cache) | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     QFile fi(cache); | 
					
						
							|  |  |  |     if (fi.exists()) { | 
					
						
							|  |  |  |         // Cache exists, then read it...
 | 
					
						
							|  |  |  |         if (fi.open(QIODevice::ReadOnly | QIODevice::Text)) { | 
					
						
							|  |  |  |             while (!fi.atEnd()) { | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  |                 QByteArray line = fi.readLine(); | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |                 if (line.startsWith("CMAKE_GENERATOR:INTERNAL=")) { | 
					
						
							|  |  |  |                     int splitpos = line.indexOf('='); | 
					
						
							|  |  |  |                     if (splitpos != -1) { | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  |                         QByteArray cachedGenerator = line.mid(splitpos + 1).trimmed(); | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |                         if (!cachedGenerator.isEmpty()) | 
					
						
							|  |  |  |                             return cachedGenerator; | 
					
						
							|  |  |  |                     } | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  |     return QByteArray(); | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-27 20:44:50 +01:00
										 |  |  | void CMakeRunPage::initializePage() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-04-20 14:35:25 +02:00
										 |  |  |     if (m_mode == Initial) { | 
					
						
							| 
									
										
										
										
											2013-09-03 18:48:02 +02:00
										 |  |  |         bool upToDateXmlFile = m_cmakeWizard->existsUpToDateXmlFile(); | 
					
						
							| 
									
										
										
										
											2009-03-27 20:44:50 +01:00
										 |  |  |         m_buildDirectory = m_cmakeWizard->buildDirectory(); | 
					
						
							| 
									
										
										
										
											2009-07-03 12:46:19 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |         if (upToDateXmlFile) { | 
					
						
							| 
									
										
										
										
											2009-07-03 12:46:19 +02:00
										 |  |  |             m_descriptionLabel->setText( | 
					
						
							| 
									
										
										
										
											2009-07-31 16:41:12 +02:00
										 |  |  |                     tr("The directory %1 already contains a cbp file, which is recent enough. " | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |                        "You can pass special arguments and rerun CMake. " | 
					
						
							| 
									
										
										
										
											2010-09-14 14:51:50 +02:00
										 |  |  |                        "Or simply finish the wizard directly.").arg(m_buildDirectory)); | 
					
						
							| 
									
										
										
										
											2013-02-13 12:16:02 +01:00
										 |  |  |             m_haveCbpFile = true; | 
					
						
							| 
									
										
										
										
											2009-07-03 12:46:19 +02:00
										 |  |  |         } else { | 
					
						
							|  |  |  |             m_descriptionLabel->setText( | 
					
						
							| 
									
										
										
										
											2010-09-14 14:51:50 +02:00
										 |  |  |                     tr("The directory %1 does not contain a cbp file. Qt Creator needs to create this file by running CMake. " | 
					
						
							|  |  |  |                        "Some projects require command line arguments to the initial CMake call.").arg(m_buildDirectory)); | 
					
						
							| 
									
										
										
										
											2009-07-03 12:46:19 +02:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2010-09-02 13:57:14 +02:00
										 |  |  |     } else if (m_mode == CMakeRunPage::NeedToUpdate) { | 
					
						
							| 
									
										
										
										
											2009-04-20 14:35:25 +02:00
										 |  |  |         m_descriptionLabel->setText(tr("The directory %1 contains an outdated .cbp file. Qt " | 
					
						
							| 
									
										
										
										
											2010-09-14 14:51:50 +02:00
										 |  |  |                                        "Creator needs to update this file by running CMake. " | 
					
						
							| 
									
										
										
										
											2009-04-20 14:35:25 +02:00
										 |  |  |                                        "If you want to add additional command line arguments, " | 
					
						
							| 
									
										
										
										
											2010-09-14 14:51:50 +02:00
										 |  |  |                                        "add them below. Note that CMake remembers command " | 
					
						
							| 
									
										
										
										
											2009-05-07 15:34:52 +02:00
										 |  |  |                                        "line arguments from the previous runs.").arg(m_buildDirectory)); | 
					
						
							| 
									
										
										
										
											2011-12-01 14:03:15 +01:00
										 |  |  |     } else if (m_mode == CMakeRunPage::Recreate) { | 
					
						
							| 
									
										
										
										
											2009-05-07 15:34:52 +02:00
										 |  |  |         m_descriptionLabel->setText(tr("The directory %1 specified in a build-configuration, " | 
					
						
							| 
									
										
										
										
											2009-04-20 14:35:25 +02:00
										 |  |  |                                        "does not contain a cbp file. Qt Creator needs to " | 
					
						
							| 
									
										
										
										
											2010-09-14 14:51:50 +02:00
										 |  |  |                                        "recreate this file, by running CMake. " | 
					
						
							| 
									
										
										
										
											2009-04-20 14:35:25 +02:00
										 |  |  |                                        "Some projects require command line arguments to " | 
					
						
							| 
									
										
										
										
											2010-09-14 14:51:50 +02:00
										 |  |  |                                        "the initial CMake call. Note that CMake remembers command " | 
					
						
							| 
									
										
										
										
											2009-05-07 15:34:52 +02:00
										 |  |  |                                        "line arguments from the previous runs.").arg(m_buildDirectory)); | 
					
						
							| 
									
										
										
										
											2011-12-01 14:03:15 +01:00
										 |  |  |     } else if (m_mode == CMakeRunPage::ChangeDirectory) { | 
					
						
							| 
									
										
										
										
											2009-04-20 14:35:25 +02:00
										 |  |  |         m_buildDirectory = m_cmakeWizard->buildDirectory(); | 
					
						
							| 
									
										
										
										
											2010-09-14 14:51:50 +02:00
										 |  |  |         m_descriptionLabel->setText(tr("Qt Creator needs to run CMake in the new build directory. " | 
					
						
							| 
									
										
										
										
											2009-04-20 14:35:25 +02:00
										 |  |  |                                        "Some projects require command line arguments to the " | 
					
						
							| 
									
										
										
										
											2010-09-14 14:51:50 +02:00
										 |  |  |                                        "initial CMake call.")); | 
					
						
							| 
									
										
										
										
											2010-09-02 13:57:14 +02:00
										 |  |  |     } else if (m_mode == CMakeRunPage::WantToUpdate) { | 
					
						
							|  |  |  |         m_descriptionLabel->setText(tr("Refreshing cbp file in %1.").arg(m_buildDirectory)); | 
					
						
							| 
									
										
										
										
											2009-03-27 20:44:50 +01:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2011-06-14 13:42:45 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Build the list of generators/toolchains we want to offer
 | 
					
						
							|  |  |  |     m_generatorComboBox->clear(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     bool hasCodeBlocksGenerator = m_cmakeWizard->cmakeManager()->hasCodeBlocksMsvcGenerator(); | 
					
						
							|  |  |  |     bool hasNinjaGenerator = m_cmakeWizard->cmakeManager()->hasCodeBlocksNinjaGenerator(); | 
					
						
							| 
									
										
										
										
											2013-02-16 14:54:13 +08:00
										 |  |  |     bool preferNinja = m_cmakeWizard->cmakeManager()->preferNinja(); | 
					
						
							| 
									
										
										
										
											2012-04-24 15:49:09 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     if (m_mode == Initial) { | 
					
						
							|  |  |  |         // Try figuring out generator and toolchain from CMakeCache.txt
 | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  |         QByteArray cachedGenerator = cachedGeneratorFromFile(m_buildDirectory + QLatin1String("/CMakeCache.txt")); | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         m_generatorComboBox->show(); | 
					
						
							| 
									
										
										
										
											2013-08-21 12:48:46 +02:00
										 |  |  |         QList<ProjectExplorer::Kit *> kitList = ProjectExplorer::KitManager::kits(); | 
					
						
							| 
									
										
										
										
											2013-02-23 09:39:26 +08:00
										 |  |  |         int defaultIndex = 0; | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         foreach (ProjectExplorer::Kit *k, kitList) { | 
					
						
							|  |  |  |             QList<GeneratorInfo> infos = GeneratorInfo::generatorInfosFor(k, | 
					
						
							|  |  |  |                                                                           hasNinjaGenerator ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja, | 
					
						
							| 
									
										
										
										
											2013-02-16 14:54:13 +08:00
										 |  |  |                                                                           preferNinja, | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |                                                                           hasCodeBlocksGenerator); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-08-21 12:48:46 +02:00
										 |  |  |             if (k == ProjectExplorer::KitManager::defaultKit()) | 
					
						
							| 
									
										
										
										
											2013-02-23 09:39:26 +08:00
										 |  |  |                 defaultIndex = m_generatorComboBox->count(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |             foreach (const GeneratorInfo &info, infos) | 
					
						
							|  |  |  |                 if (cachedGenerator.isEmpty() || info.generator() == cachedGenerator) | 
					
						
							|  |  |  |                     m_generatorComboBox->addItem(info.displayName(), qVariantFromValue(info)); | 
					
						
							| 
									
										
										
										
											2009-12-03 19:45:09 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2013-02-23 09:39:26 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |         m_generatorComboBox->setCurrentIndex(defaultIndex); | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     } else { | 
					
						
							|  |  |  |         // Note: We don't compare the actually cached generator to what is set in the buildconfiguration
 | 
					
						
							|  |  |  |         // We assume that the buildconfiguration is correct
 | 
					
						
							|  |  |  |         GeneratorInfo::Ninja ninja; | 
					
						
							|  |  |  |         if (m_mode == CMakeRunPage::NeedToUpdate || m_mode == CMakeRunPage::WantToUpdate) { | 
					
						
							|  |  |  |             ninja = m_cmakeWizard->useNinja() ? GeneratorInfo::ForceNinja : GeneratorInfo::NoNinja; | 
					
						
							|  |  |  |         } else { // Recreate, ChangeDirectory
 | 
					
						
							|  |  |  |             // Note: ReCreate is technically just a removed .cbp file, we assume the cache
 | 
					
						
							|  |  |  |             // got removed too. If the cache still exists the error message from cmake should
 | 
					
						
							|  |  |  |             // be a good hint to change the generator
 | 
					
						
							|  |  |  |             ninja = hasNinjaGenerator ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja; | 
					
						
							| 
									
										
										
										
											2009-12-03 19:45:09 +01:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |         QList<GeneratorInfo> infos = GeneratorInfo::generatorInfosFor(m_cmakeWizard->kit(), | 
					
						
							|  |  |  |                                                                       ninja, | 
					
						
							| 
									
										
										
										
											2013-02-16 14:54:13 +08:00
										 |  |  |                                                                       preferNinja, | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |                                                                       true); | 
					
						
							|  |  |  |         foreach (const GeneratorInfo &info, infos) | 
					
						
							| 
									
										
										
										
											2012-11-06 12:54:12 +01:00
										 |  |  |             m_generatorComboBox->addItem(info.displayName(), qVariantFromValue(info)); | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool CMakeRunPage::validatePage() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-02-14 12:11:54 +01:00
										 |  |  |     int index = m_generatorComboBox->currentIndex(); | 
					
						
							|  |  |  |     if (index == -1) | 
					
						
							|  |  |  |         return false; | 
					
						
							|  |  |  |     GeneratorInfo generatorInfo = m_generatorComboBox->itemData(index).value<GeneratorInfo>(); | 
					
						
							|  |  |  |     m_cmakeWizard->setKit(generatorInfo.kit()); | 
					
						
							|  |  |  |     m_cmakeWizard->setUseNinja(generatorInfo.isNinja()); | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     return QWizardPage::validatePage(); | 
					
						
							| 
									
										
										
										
											2009-03-27 20:44:50 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | void CMakeRunPage::runCMake() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-02-13 12:16:02 +01:00
										 |  |  |     m_haveCbpFile = false; | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     Utils::Environment env = m_cmakeWizard->environment(); | 
					
						
							| 
									
										
										
										
											2011-02-01 18:36:00 +01:00
										 |  |  |     int index = m_generatorComboBox->currentIndex(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     if (index == -1) { | 
					
						
							| 
									
										
										
										
											2011-08-23 15:36:02 +02:00
										 |  |  |         m_output->appendPlainText(tr("No generator selected.")); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     GeneratorInfo generatorInfo = m_generatorComboBox->itemData(index).value<GeneratorInfo>(); | 
					
						
							|  |  |  |     m_cmakeWizard->setKit(generatorInfo.kit()); | 
					
						
							|  |  |  |     m_cmakeWizard->setUseNinja(generatorInfo.isNinja()); | 
					
						
							| 
									
										
										
										
											2011-06-14 13:42:45 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     // If mode is initial the user chooses the kit, otherwise it's already choosen
 | 
					
						
							|  |  |  |     // and the environment already contains the kit
 | 
					
						
							|  |  |  |     if (m_mode == Initial) | 
					
						
							|  |  |  |         generatorInfo.kit()->addToEnvironment(env); | 
					
						
							| 
									
										
										
										
											2011-02-01 18:36:00 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  |     m_runCMake->setEnabled(false); | 
					
						
							|  |  |  |     m_argumentsLineEdit->setEnabled(false); | 
					
						
							| 
									
										
										
										
											2011-02-01 18:36:00 +01:00
										 |  |  |     m_generatorComboBox->setEnabled(false); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-09-23 14:33:05 +02:00
										 |  |  |     m_output->clear(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |     CMakeManager *cmakeManager = m_cmakeWizard->cmakeManager(); | 
					
						
							| 
									
										
										
										
											2009-09-23 14:33:05 +02:00
										 |  |  |     if (m_cmakeWizard->cmakeManager()->isCMakeExecutableValid()) { | 
					
						
							| 
									
										
										
										
											2010-10-19 11:14:03 +02:00
										 |  |  |         m_cmakeProcess = new Utils::QtcProcess(); | 
					
						
							| 
									
										
										
										
											2010-10-04 17:52:55 +02:00
										 |  |  |         connect(m_cmakeProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(cmakeReadyReadStandardOutput())); | 
					
						
							|  |  |  |         connect(m_cmakeProcess, SIGNAL(readyReadStandardError()), this, SLOT(cmakeReadyReadStandardError())); | 
					
						
							| 
									
										
										
										
											2009-09-23 14:33:05 +02:00
										 |  |  |         connect(m_cmakeProcess, SIGNAL(finished(int)), this, SLOT(cmakeFinished())); | 
					
						
							| 
									
										
										
										
											2012-10-02 17:46:19 +02:00
										 |  |  |         cmakeManager->createXmlFile(m_cmakeProcess, m_argumentsLineEdit->text(), m_cmakeWizard->sourceDirectory(), | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  |                                     m_buildDirectory, env, QString::fromLatin1(generatorInfo.generatorArgument())); | 
					
						
							| 
									
										
										
										
											2009-09-23 14:33:05 +02:00
										 |  |  |     } else { | 
					
						
							|  |  |  |         m_runCMake->setEnabled(true); | 
					
						
							|  |  |  |         m_argumentsLineEdit->setEnabled(true); | 
					
						
							| 
									
										
										
										
											2011-02-01 18:36:00 +01:00
										 |  |  |         m_generatorComboBox->setEnabled(true); | 
					
						
							| 
									
										
										
										
											2013-02-12 15:35:09 +01:00
										 |  |  |         m_output->appendPlainText(tr("No valid CMake executable specified.")); | 
					
						
							| 
									
										
										
										
											2009-09-23 14:33:05 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-04 17:52:55 +02:00
										 |  |  | static QColor mix_colors(QColor a, QColor b) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return QColor((a.red() + 2 * b.red()) / 3, (a.green() + 2 * b.green()) / 3, | 
					
						
							|  |  |  |                   (a.blue() + 2* b.blue()) / 3, (a.alpha() + 2 * b.alpha()) / 3); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void CMakeRunPage::cmakeReadyReadStandardOutput() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     QTextCursor cursor(m_output->document()); | 
					
						
							| 
									
										
										
										
											2011-04-27 14:41:15 +02:00
										 |  |  |     cursor.movePosition(QTextCursor::End); | 
					
						
							| 
									
										
										
										
											2010-10-04 17:52:55 +02:00
										 |  |  |     QTextCharFormat tf; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QFont font = m_output->font(); | 
					
						
							|  |  |  |     tf.setFont(font); | 
					
						
							|  |  |  |     tf.setForeground(m_output->palette().color(QPalette::Text)); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  |     cursor.insertText(QString::fromLocal8Bit(m_cmakeProcess->readAllStandardOutput()), tf); | 
					
						
							| 
									
										
										
										
											2010-10-04 17:52:55 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void CMakeRunPage::cmakeReadyReadStandardError() | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2010-10-04 17:52:55 +02:00
										 |  |  |     QTextCursor cursor(m_output->document()); | 
					
						
							|  |  |  |     QTextCharFormat tf; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     QFont font = m_output->font(); | 
					
						
							|  |  |  |     QFont boldFont = font; | 
					
						
							|  |  |  |     boldFont.setBold(true); | 
					
						
							|  |  |  |     tf.setFont(boldFont); | 
					
						
							|  |  |  |     tf.setForeground(mix_colors(m_output->palette().color(QPalette::Text), QColor(Qt::red))); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-21 23:54:06 +02:00
										 |  |  |     cursor.insertText(QString::fromLocal8Bit(m_cmakeProcess->readAllStandardError()), tf); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void CMakeRunPage::cmakeFinished() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_runCMake->setEnabled(true); | 
					
						
							|  |  |  |     m_argumentsLineEdit->setEnabled(true); | 
					
						
							| 
									
										
										
										
											2011-02-01 18:36:00 +01:00
										 |  |  |     m_generatorComboBox->setEnabled(true); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-10-04 17:52:55 +02:00
										 |  |  |     if (m_cmakeProcess->exitCode() != 0) { | 
					
						
							|  |  |  |         m_exitCodeLabel->setVisible(true); | 
					
						
							| 
									
										
										
										
											2011-03-31 09:57:24 +02:00
										 |  |  |         m_exitCodeLabel->setText(tr("CMake exited with errors. Please check CMake output.")); | 
					
						
							| 
									
										
										
										
											2013-02-15 13:50:03 +08:00
										 |  |  |         static_cast<Utils::HistoryCompleter *>(m_argumentsLineEdit->completer())->removeHistoryItem(0); | 
					
						
							| 
									
										
										
										
											2013-02-13 12:16:02 +01:00
										 |  |  |         m_haveCbpFile = false; | 
					
						
							| 
									
										
										
										
											2010-10-04 17:52:55 +02:00
										 |  |  |     } else { | 
					
						
							|  |  |  |         m_exitCodeLabel->setVisible(false); | 
					
						
							| 
									
										
										
										
											2013-02-13 12:16:02 +01:00
										 |  |  |         m_haveCbpFile = true; | 
					
						
							| 
									
										
										
										
											2010-10-04 17:52:55 +02:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  |     m_cmakeProcess->deleteLater(); | 
					
						
							|  |  |  |     m_cmakeProcess = 0; | 
					
						
							| 
									
										
										
										
											2010-10-19 11:14:03 +02:00
										 |  |  |     m_cmakeWizard->setArguments(m_argumentsLineEdit->text()); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  |     emit completeChanged(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void CMakeRunPage::cleanupPage() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_output->clear(); | 
					
						
							| 
									
										
										
										
											2013-02-13 12:16:02 +01:00
										 |  |  |     m_haveCbpFile = false; | 
					
						
							| 
									
										
										
										
											2010-10-04 17:52:55 +02:00
										 |  |  |     m_exitCodeLabel->setVisible(false); | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  |     emit completeChanged(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool CMakeRunPage::isComplete() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2013-02-14 12:11:54 +01:00
										 |  |  |     int index = m_generatorComboBox->currentIndex(); | 
					
						
							|  |  |  |     return index != -1 && m_haveCbpFile; | 
					
						
							| 
									
										
										
										
											2009-03-10 09:36:18 +01:00
										 |  |  | } |