qtcreator-plugin-cmake-3.0.1+14.04.20140415/0000755000015301777760000000000012323170262020465 5ustar pbusernogroup00000000000000qtcreator-plugin-cmake-3.0.1+14.04.20140415/LICENSE.LGPL0000644000015301777760000006350212323167666022253 0ustar pbusernogroup00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! qtcreator-plugin-cmake-3.0.1+14.04.20140415/qtcreatorplugin.pri0000644000015301777760000000142212323167666024441 0ustar pbusernogroup00000000000000## Where the Qt Creator headers are located at QTCREATOR_SOURCES = $$(QTC_SOURCE) isEmpty(QTCREATOR_SOURCES):QTCREATOR_SOURCES=/usr/src/qtcreator ## Where our plugin will be compiled to IDE_BUILD_TREE = $$(QTC_BUILD) isEmpty(IDE_BUILD_TREE):IDE_BUILD_TREE=../../builddir UBUNTU_LOCAL_BUILD = $$(UBUNTU_QTC_PLUGIN_LOCALBUILD) !isEmpty(UBUNTU_LOCAL_BUILD) { message("!!!!!!!!!!BUILDING LOCAL VERSION OF PLUGIN !!!!!!!!!!!!!!!!!!!") USE_USER_DESTDIR = yes PATHSTR = '\\"$${PWD}/../share/qtcreator\\"' DEFINES += UBUNTU_RESOURCE_PATH_LOCAL=\"$${PATHSTR}\" UBUNTU_BUILD_LOCAL } include($$QTCREATOR_SOURCES/src/qtcreatorplugin.pri) INCLUDEPATH += $$QTCREATOR_SOURCES/src/ LIBS += -L$$[QT_INSTALL_LIBS]/qtcreator LIBS += -L$$[QT_INSTALL_LIBS]/qtcreator/plugins/QtProject qtcreator-plugin-cmake-3.0.1+14.04.20140415/LGPL_EXCEPTION.txt0000644000015301777760000000224312323167666023421 0ustar pbusernogroup00000000000000Digia Qt LGPL Exception version 1.1 As an additional permission to the GNU Lesser General Public License version 2.1, the object code form of a "work that uses the Library" may incorporate material from a header file that is part of the Library. You may distribute such object code under terms of your choice, provided that: (i) the header files of the Library have not been modified; and (ii) the incorporated material is limited to numerical parameters, data structure layouts, accessors, macros, inline functions and templates; and (iii) you comply with the terms of Section 6 of the GNU Lesser General Public License version 2.1. Moreover, you may apply this exception to a modified version of the Library, provided that such modification does not involve copying material from the Library into the modified Library's header files unless such material is limited to (i) numerical parameters; (ii) data structure layouts; (iii) accessors; and (iv) small macros, templates and inline functions of five lines or less in length. Furthermore, you are not required to apply this additional permission to a modified version of the Library. qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/0000755000015301777760000000000012323170262021254 5ustar pbusernogroup00000000000000qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/0000755000015301777760000000000012323170262025256 5ustar pbusernogroup00000000000000qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakevalidator.h0000644000015301777760000000572512323167666030444 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEVALIDATOR_H #define CMAKEVALIDATOR_H #include #include #include #include QT_FORWARD_DECLARE_CLASS(QProcess) namespace CMakeProjectManager { namespace Internal { class CMakeValidator : public QObject { Q_OBJECT public: CMakeValidator(); ~CMakeValidator(); enum State { Invalid, RunningBasic, RunningFunctionList, RunningFunctionDetails, RunningPropertyList, RunningVariableList, RunningDone }; void cancel(); bool isValid() const; void setCMakeExecutable(const QString &executable); QString cmakeExecutable() const; bool hasCodeBlocksMsvcGenerator() const; bool hasCodeBlocksNinjaGenerator() const; TextEditor::Keywords keywords(); private slots: void finished(int exitCode); private: void finishStep(); void startNextStep(); bool startProcess(const QStringList &args); void parseFunctionOutput(const QByteArray &output); void parseFunctionDetailsOutput(const QByteArray &output); void parseVariableOutput(const QByteArray &output); void parseDone(); QString formatFunctionDetails(const QString &command, const QString &args); State m_state; QProcess *m_process; bool m_hasCodeBlocksMsvcGenerator; bool m_hasCodeBlocksNinjaGenerator; QString m_executable; QMap m_functionArgs; QStringList m_variables; QStringList m_functions; }; } // namespace Internal } // namespace CMakeProjectManager #endif // CMAKEVALIDATOR_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeeditor.cpp0000644000015301777760000001671512323167666030301 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmakeeditor.h" #include "cmakefilecompletionassist.h" #include "cmakehighlighter.h" #include "cmakeeditorfactory.h" #include "cmakeprojectconstants.h" #include "cmakeproject.h" #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace CMakeProjectManager; using namespace CMakeProjectManager::Internal; // // ProFileEditorEditable // CMakeEditor::CMakeEditor(CMakeEditorWidget *editor) : BaseTextEditor(editor) { setContext(Core::Context(CMakeProjectManager::Constants::C_CMAKEEDITOR, TextEditor::Constants::C_TEXTEDITOR)); connect(document(), SIGNAL(changed()), this, SLOT(markAsChanged())); } Core::IEditor *CMakeEditor::duplicate(QWidget *parent) { CMakeEditorWidget *w = qobject_cast(widget()); CMakeEditorWidget *ret = new CMakeEditorWidget(parent, w->factory(), w->actionHandler()); ret->duplicateFrom(w); TextEditor::TextEditorSettings::initializeEditor(ret); return ret->editor(); } Core::Id CMakeEditor::id() const { return Core::Id(CMakeProjectManager::Constants::CMAKE_EDITOR_ID); } TextEditor::CompletionAssistProvider *CMakeEditor::completionAssistProvider() { return ExtensionSystem::PluginManager::getObject(); } void CMakeEditor::markAsChanged() { if (!document()->isModified()) return; Core::InfoBar *infoBar = document()->infoBar(); Core::Id infoRunCmake("CMakeEditor.RunCMake"); if (!infoBar->canInfoBeAdded(infoRunCmake)) return; Core::InfoBarEntry info(infoRunCmake, tr("Changes to cmake files are shown in the project tree after building."), Core::InfoBarEntry::GlobalSuppressionEnabled); info.setCustomButtonInfo(tr("Build now"), this, SLOT(build())); infoBar->addInfo(info); } void CMakeEditor::build() { foreach (ProjectExplorer::Project *p, ProjectExplorer::SessionManager::projects()) { CMakeProject *cmakeProject = qobject_cast(p); if (cmakeProject) { if (cmakeProject->isProjectFile(document()->filePath())) { ProjectExplorer::ProjectExplorerPlugin::instance()->buildProject(cmakeProject); break; } } } } // // CMakeEditor // CMakeEditorWidget::CMakeEditorWidget(QWidget *parent, CMakeEditorFactory *factory, TextEditor::TextEditorActionHandler *ah) : BaseTextEditorWidget(parent), m_factory(factory), m_ah(ah) { QSharedPointer doc(new CMakeDocument); doc->setMimeType(QLatin1String(CMakeProjectManager::Constants::CMAKEMIMETYPE)); setBaseTextDocument(doc); baseTextDocument()->setSyntaxHighlighter(new CMakeHighlighter); m_commentDefinition.clearCommentStyles(); m_commentDefinition.singleLine = QLatin1Char('#'); ah->setupActions(this); } TextEditor::BaseTextEditor *CMakeEditorWidget::createEditor() { return new CMakeEditor(this); } void CMakeEditorWidget::unCommentSelection() { Utils::unCommentSelection(this, m_commentDefinition); } void CMakeEditorWidget::contextMenuEvent(QContextMenuEvent *e) { showDefaultContextMenu(e, Constants::M_CONTEXT); } static bool isValidFileNameChar(const QChar &c) { if (c.isLetterOrNumber() || c == QLatin1Char('.') || c == QLatin1Char('_') || c == QLatin1Char('-') || c == QLatin1Char('/') || c == QLatin1Char('\\')) return true; return false; } CMakeEditorWidget::Link CMakeEditorWidget::findLinkAt(const QTextCursor &cursor, bool/* resolveTarget*/, bool /*inNextSplit*/) { Link link; int lineNumber = 0, positionInBlock = 0; convertPosition(cursor.position(), &lineNumber, &positionInBlock); const QString block = cursor.block().text(); // check if the current position is commented out const int hashPos = block.indexOf(QLatin1Char('#')); if (hashPos >= 0 && hashPos < positionInBlock) return link; // find the beginning of a filename QString buffer; int beginPos = positionInBlock - 1; while (beginPos >= 0) { QChar c = block.at(beginPos); if (isValidFileNameChar(c)) { buffer.prepend(c); beginPos--; } else { break; } } // find the end of a filename int endPos = positionInBlock; while (endPos < block.count()) { QChar c = block.at(endPos); if (isValidFileNameChar(c)) { buffer.append(c); endPos++; } else { break; } } if (buffer.isEmpty()) return link; // TODO: Resolve variables QDir dir(QFileInfo(editorDocument()->filePath()).absolutePath()); QString fileName = dir.filePath(buffer); QFileInfo fi(fileName); if (fi.exists()) { if (fi.isDir()) { QDir subDir(fi.absoluteFilePath()); QString subProject = subDir.filePath(QLatin1String("CMakeLists.txt")); if (QFileInfo(subProject).exists()) fileName = subProject; else return link; } link.targetFileName = fileName; link.linkTextStart = cursor.position() - positionInBlock + beginPos + 1; link.linkTextEnd = cursor.position() - positionInBlock + endPos; } return link; } // // CMakeDocument // CMakeDocument::CMakeDocument() : TextEditor::BaseTextDocument() { } QString CMakeDocument::defaultPath() const { QFileInfo fi(filePath()); return fi.absolutePath(); } QString CMakeDocument::suggestedFileName() const { QFileInfo fi(filePath()); return fi.fileName(); } qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeeditorfactory.h0000644000015301777760000000410212323167666031321 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEEDITORFACTORY_H #define CMAKEEDITORFACTORY_H #include "cmakeprojectmanager.h" #include namespace TextEditor { class TextEditorActionHandler; } namespace CMakeProjectManager { namespace Internal { class CMakeEditorFactory : public Core::IEditorFactory { Q_OBJECT public: CMakeEditorFactory(CMakeManager *parent); Core::IEditor *createEditor(QWidget *parent); private: const QStringList m_mimeTypes; CMakeManager *m_manager; TextEditor::TextEditorActionHandler *m_actionHandler; }; } // namespace Internal } // namespace CMakeProjectManager #endif // CMAKEEDITORFACTORY_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeproject.h0000644000015301777760000001724712323167666030127 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEPROJECT_H #define CMAKEPROJECT_H #include "cmakeprojectmanager_global.h" #include "cmakeprojectmanager.h" #include "cmakeprojectnodes.h" #include "cmakebuildconfiguration.h" #include "makestep.h" #include #include #include #include #include #include #include #include #include #include #include #include QT_BEGIN_NAMESPACE class QFileSystemWatcher; QT_END_NAMESPACE namespace ProjectExplorer { class Target; } namespace CMakeProjectManager { class ArgumentsLineEdit; namespace Internal{ class CMakeFile; class CMakeBuildSettingsWidget; } struct CMAKEPROJECTMANAGER_EXPORT CMakeBuildTarget { QString title; QString executable; // TODO: rename to output? bool library; QString workingDirectory; QString makeCommand; QString makeCleanCommand; void clear(); }; class CMAKEPROJECTMANAGER_EXPORT CMakeProject : public ProjectExplorer::Project { Q_OBJECT // for changeBuildDirectory friend class CMakeBuildSettingsWidget; public: CMakeProject(CMakeManager *manager, const QString &filename); ~CMakeProject(); QString displayName() const; Core::Id id() const; Core::IDocument *document() const; CMakeManager *projectManager() const; ProjectExplorer::ProjectNode *rootProjectNode() const; QStringList files(FilesMode fileMode) const; QStringList buildTargetTitles(bool runnable = false) const; QList buildTargets() const; bool hasBuildTarget(const QString &title) const; CMakeBuildTarget buildTargetForTitle(const QString &title); static QString shadowBuildDirectory(const QString &projectFilePath, const ProjectExplorer::Kit *k, const QString &bcName); bool isProjectFile(const QString &fileName); bool hasInSourceBuild() const; static bool hasInSourceBuild (const QString &sourcePath); // Project interface ProjectExplorer::KitMatcher *createRequiredKitMatcher() const; bool supportsKit(ProjectExplorer::Kit *k, QString *errorMessage) const; bool supportsNoTargetPanel() const; bool needsConfiguration() const; public slots: bool parseCMakeLists(ProjectExplorer::Target* t = 0); signals: /// emitted after parsing void buildTargetsChanged(); protected: bool fromMap(const QVariantMap &map); bool setupTarget(ProjectExplorer::Target *t); // called by CMakeBuildSettingsWidget void changeBuildDirectory(CMakeBuildConfiguration *bc, const QString &newBuildDirectory); private slots: void fileChanged(const QString &fileName); void activeTargetWasChanged(ProjectExplorer::Target *target); void changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*); void updateConfigurations(); private: void buildTree(Internal::CMakeProjectNode *rootNode, QList list); void gatherFileNodes(ProjectExplorer::FolderNode *parent, QList &list); ProjectExplorer::FolderNode *findOrCreateFolder(Internal::CMakeProjectNode *rootNode, QString directory); void createUiCodeModelSupport(); QString uiHeaderFile(const QString &uiFile); void updateConfigurations(ProjectExplorer::Target *t); void updateApplicationAndDeploymentTargets(); CMakeManager *m_manager; ProjectExplorer::Target *m_activeTarget; QString m_fileName; Internal::CMakeFile *m_file; QString m_projectName; // TODO probably need a CMake specific node structure Internal::CMakeProjectNode *m_rootNode; QStringList m_files; QList m_buildTargets; QFileSystemWatcher *m_watcher; QSet m_watchedFiles; QFuture m_codeModelFuture; }; namespace Internal { class CMakeCbpParser : public QXmlStreamReader { public: bool parseCbpFile(const QString &fileName); QList fileList(); QList cmakeFileList(); QStringList includeFiles(); QList buildTargets(); QByteArray defines() const; QString projectName() const; QString compilerName() const; bool hasCMakeFiles(); private: void parseCodeBlocks_project_file(); void parseProject(); void parseBuild(); void parseOption(); void parseBuildTarget(); void parseBuildTargetOption(); void parseMakeCommands(); void parseBuildTargetBuild(); void parseBuildTargetClean(); void parseCompiler(); void parseAdd(); void parseUnit(); void parseUnitOption(); void parseUnknownElement(); QList m_fileList; QList m_cmakeFileList; QSet m_processedUnits; bool m_parsingCmakeUnit; QStringList m_includeFiles; QStringList m_compilerOptions; QByteArray m_defines; CMakeBuildTarget m_buildTarget; QList m_buildTargets; QString m_projectName; QString m_compiler; }; class CMakeFile : public Core::IDocument { Q_OBJECT public: CMakeFile(CMakeProject *parent, QString fileName); bool save(QString *errorString, const QString &fileName, bool autoSave); QString defaultPath() const; QString suggestedFileName() const; QString mimeType() const; bool isModified() const; bool isSaveAsAllowed() const; ReloadBehavior reloadBehavior(ChangeTrigger state, ChangeType type) const; bool reload(QString *errorString, ReloadFlag flag, ChangeType type); private: CMakeProject *m_project; }; class CMakeBuildSettingsWidget : public ProjectExplorer::NamedWidget { Q_OBJECT public: CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc); private slots: void openChangeBuildDirectoryDialog(); void onArgumentsChanged(); void onBuilddirChanged(); void onGeneratorSelected(); private: Utils::PathChooser *m_pathChooser; ArgumentsLineEdit *m_userArguments; QComboBox* m_generatorBox; CMakeBuildConfiguration *m_buildConfiguration; }; } // namespace Internal } // namespace CMakeProjectManager #endif // CMAKEPROJECT_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeprojectmanager.pro0000644000015301777760000000244212323167666032022 0ustar pbusernogroup00000000000000include(../../qtcreatorplugin.pri) HEADERS = cmakebuildinfo.h \ cmakeproject.h \ cmakeprojectplugin.h \ cmakeprojectmanager.h \ cmakeprojectmanager_global.h \ cmakeprojectconstants.h \ cmakeprojectnodes.h \ makestep.h \ cmakerunconfiguration.h \ cmakebuildconfiguration.h \ cmakeeditorfactory.h \ cmakeeditor.h \ cmakehighlighter.h \ cmakehighlighterfactory.h \ cmakelocatorfilter.h \ cmakefilecompletionassist.h \ cmakeparser.h \ generatorinfo.h \ cmakeappwizard.h \ cmakekitinformation.h \ cmaketool.h \ argumentslineedit.h \ cmaketoolmanager.h \ cmakesettingspage.h SOURCES = cmakeproject.cpp \ cmakeprojectplugin.cpp \ cmakeprojectmanager.cpp \ cmakeprojectnodes.cpp \ makestep.cpp \ cmakerunconfiguration.cpp \ cmakebuildconfiguration.cpp \ cmakeeditorfactory.cpp \ cmakeeditor.cpp \ cmakehighlighter.cpp \ cmakehighlighterfactory.cpp \ cmakelocatorfilter.cpp \ cmakefilecompletionassist.cpp \ cmakeparser.cpp \ generatorinfo.cpp \ cmakeappwizard.cpp \ cmakekitinformation.cpp \ cmaketool.cpp \ argumentslineedit.cpp \ cmaketoolmanager.cpp \ cmakesettingspage.cpp RESOURCES += cmakeproject.qrc DEFINES += CMAKEPROJECTMANAGER_LIBRARY qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeprojectnodes.cpp0000644000015301777760000000576112323167666031511 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmakeprojectnodes.h" using namespace CMakeProjectManager; using namespace CMakeProjectManager::Internal; CMakeProjectNode::CMakeProjectNode(const QString &fileName) : ProjectExplorer::ProjectNode(fileName) { } bool CMakeProjectNode::hasBuildTargets() const { // TODO return true; } QList CMakeProjectNode::supportedActions(Node *node) const { Q_UNUSED(node); return QList(); } bool CMakeProjectNode::canAddSubProject(const QString &proFilePath) const { Q_UNUSED(proFilePath) return false; } bool CMakeProjectNode::addSubProjects(const QStringList &proFilePaths) { Q_UNUSED(proFilePaths) return false; } bool CMakeProjectNode::removeSubProjects(const QStringList &proFilePaths) { Q_UNUSED(proFilePaths) return false; } bool CMakeProjectNode::addFiles(const QStringList &filePaths, QStringList *notAdded) { Q_UNUSED(filePaths) Q_UNUSED(notAdded) return false; } bool CMakeProjectNode::removeFiles(const QStringList &filePaths, QStringList *notRemoved) { Q_UNUSED(filePaths) Q_UNUSED(notRemoved) return false; } bool CMakeProjectNode::deleteFiles(const QStringList &filePaths) { Q_UNUSED(filePaths) return false; } bool CMakeProjectNode::renameFile(const QString &filePath, const QString &newFilePath) { Q_UNUSED(filePath) Q_UNUSED(newFilePath) return false; } QList CMakeProjectNode::runConfigurationsFor(Node *node) { Q_UNUSED(node) return QList(); } qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeproject.qrc0000644000015301777760000000017412323167666030454 0ustar pbusernogroup00000000000000 CMakeProjectManager.mimetypes.xml ././@LongLink0000000000000000000000000000014600000000000011216 Lustar 00000000000000qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/CMakeProjectManager.pluginspec.inqtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/CMakeProjectManager.pluginspec.i0000644000015301777760000000200312323167666033413 0ustar pbusernogroup00000000000000 Digia Plc (C) 2014 Digia Plc Commercial Usage Licensees holding valid Qt Commercial licenses may use this plugin in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Digia. GNU Lesser General Public License Usage Alternatively, this plugin may be used under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. 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. Build Systems CMake support http://www.qt-project.org $$dependencyList qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakebuildconfiguration.h0000644000015301777760000001072412323167666032341 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEBUILDCONFIGURATION_H #define CMAKEBUILDCONFIGURATION_H #include "cmakeprojectmanager_global.h" #include #include namespace ProjectExplorer { class ToolChain; } namespace CMakeProjectManager { class CMakeBuildInfo; class CMakeProject; class CMakeBuildConfigurationFactory; class CMAKEPROJECTMANAGER_EXPORT CMakeBuildConfiguration : public ProjectExplorer::BuildConfiguration { Q_OBJECT friend class CMakeBuildConfigurationFactory; public: CMakeBuildConfiguration(ProjectExplorer::Target *parent); ~CMakeBuildConfiguration(); ProjectExplorer::NamedWidget *createConfigWidget(); QVariantMap toMap() const; BuildType buildType() const; bool useNinja() const; void setUseNinja(bool); QStringList arguments() const; void setArguments (const QStringList &args); QByteArray generator () const; static QByteArray cachedGeneratorFromFile(const QString &cache); void setBuildDirectory(const Utils::FileName &directory); signals: void useNinjaChanged(bool); void argumentsChanged(const QStringList& list); protected: CMakeBuildConfiguration(ProjectExplorer::Target *parent, const Core::Id& id); CMakeBuildConfiguration(ProjectExplorer::Target *parent, CMakeBuildConfiguration *source); bool fromMap(const QVariantMap &map); protected slots: void cleanAndRunCMake(); void runCMake(); private: void init(ProjectExplorer::Target* parent); QStringList m_arguments; QString m_msvcVersion; bool m_useNinja; friend class CMakeProject; }; class CMAKEPROJECTMANAGER_EXPORT CMakeBuildConfigurationFactory : public ProjectExplorer::IBuildConfigurationFactory { Q_OBJECT public: CMakeBuildConfigurationFactory(QObject *parent = 0); ~CMakeBuildConfigurationFactory(); int priority(const ProjectExplorer::Target *parent) const; QList availableBuilds(const ProjectExplorer::Target *parent) const; int priority(const ProjectExplorer::Kit *k, const QString &projectPath) const; QList availableSetups(const ProjectExplorer::Kit *k, const QString &projectPath) const; ProjectExplorer::BuildConfiguration *create(ProjectExplorer::Target *parent, const ProjectExplorer::BuildInfo *info) const; bool canClone(const ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source) const; CMakeBuildConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source); bool canRestore(const ProjectExplorer::Target *parent, const QVariantMap &map) const; CMakeBuildConfiguration *restore(ProjectExplorer::Target *parent, const QVariantMap &map); private: bool canHandle(const ProjectExplorer::Target *t) const; CMakeBuildInfo *createBuildInfo(const ProjectExplorer::Kit *k, const QString &sourceDir) const; }; } // namespace CMakeProjectManager #endif // CMAKEBUILDCONFIGURATION_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeparser.h0000644000015301777760000000375612323167666027755 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Axonian LLC. ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEOUTPUTPARSER_H #define CMAKEOUTPUTPARSER_H #include #include namespace CMakeProjectManager { namespace Internal { class CMakeParser : public ProjectExplorer::IOutputParser { Q_OBJECT public: explicit CMakeParser(); void stdError(const QString &line); protected: void doFlush(); private: ProjectExplorer::Task m_lastTask; QRegExp m_commonError; QRegExp m_nextSubError; bool m_skippedFirstEmptyLine; }; } // namespace CMakeProjectManager } // namespace Internal #endif // CMAKEOUTPUTPARSER_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakefilecompletionassist.h0000644000015301777760000000413412323167666032710 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEFILECOMPLETIONASSIST_H #define CMAKEFILECOMPLETIONASSIST_H #include namespace CMakeProjectManager { namespace Internal { class CMakeSettingsPage; class CMakeFileCompletionAssistProvider : public TextEditor::CompletionAssistProvider { Q_OBJECT public: CMakeFileCompletionAssistProvider(CMakeSettingsPage *settingsPage); ~CMakeFileCompletionAssistProvider(); bool supportsEditor(const Core::Id &editorId) const; TextEditor::IAssistProcessor *createProcessor() const; private: CMakeSettingsPage *m_settingsPage; }; } // Internal } // CMakeProjectManager #endif // CMAKEFILECOMPLETIONASSIST_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmaketoolmanager.cpp0000644000015301777760000001022512323167666031311 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Canonical Ltd. ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmaketoolmanager.h" #include "cmakeprojectconstants.h" #include "cmakekitinformation.h" #include #include #include #include namespace CMakeProjectManager { CMakeToolManager* CMakeToolManager::m_instance = 0; CMakeToolManager::CMakeToolManager() { m_instance = this; m_cmakeToolForSystem.setCMakeExecutable(findCmakeExecutable()); QSettings *settings = Core::ICore::settings(); settings->beginGroup(QLatin1String("CMakeSettings")); m_cmakeToolForUser.setCMakeExecutable(settings->value(QLatin1String("cmakeExecutable")).toString()); settings->endGroup(); } CMakeToolManager::~CMakeToolManager() { m_instance = 0; m_cmakeToolForSystem.cancel(); m_cmakeToolForUser.cancel(); //clean up created cmake tools qDeleteAll(m_cmakeTools.begin(),m_cmakeTools.end()); } void CMakeToolManager::setUserCmakePath(const QString &path) { m_instance->m_cmakeToolForUser.setCMakeExecutable(path); } QString CMakeToolManager::userCMakePath() { return m_instance->m_cmakeToolForUser.cmakeExecutable(); } /*! * \brief CMakeToolManager::defaultCMakeTool * Returns a pointer to the internal default cmake tool instance */ CMakeTool *CMakeToolManager::defaultCMakeTool() { if(m_instance->m_cmakeToolForUser.isValid()) return &m_instance->m_cmakeToolForUser; return &m_instance->m_cmakeToolForSystem; } bool CMakeToolManager::registerCMakeTool(ICMakeTool *tool) { if(m_instance->m_cmakeTools.contains(tool->id().uniqueIdentifier())) return false; m_instance->m_cmakeTools.insert(tool->id().uniqueIdentifier(),tool); return true; } ICMakeTool *CMakeToolManager::cmakeTool(const Core::Id &id) { if(id == Constants::CMAKE_TOOL_ID) return defaultCMakeTool(); if(m_instance->m_cmakeTools.contains(id.uniqueIdentifier())) return m_instance->m_cmakeTools[id.uniqueIdentifier()]; qDebug()<<"Don't know "< factories = ExtensionSystem::PluginManager::getObjects(); foreach(ICMakeToolFactory* factory, factories) { if(factory->canCreate(id)) { ICMakeTool* cmake = factory->create(id); m_instance->m_cmakeTools.insert(id.uniqueIdentifier(),cmake); return cmake; } } return 0; } ICMakeTool *CMakeToolManager::cmakeToolForKit(const ProjectExplorer::Kit *kit) { return CMakeKitInformation::cmakeTool(kit); } QString CMakeToolManager::findCmakeExecutable() { return Utils::Environment::systemEnvironment().searchInPath(QLatin1String("cmake")); } } // namespace CMakeProjectManager qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeopenprojectwizard.h0000644000015301777760000001311312323167666032216 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEOPENPROJECTWIZARD_H #define CMAKEOPENPROJECTWIZARD_H #include "cmakebuildconfiguration.h" #include "cmakebuildinfo.h" #include #include #include #include #include #include #include #include #include #include namespace Utils { class FancyLineEdit; class PathChooser; } namespace ProjectExplorer { class Kit; } namespace CMakeProjectManager { namespace Internal { class CMakeManager; class CMakeOpenProjectWizard : public Utils::Wizard { Q_OBJECT public: enum Mode { Nothing, NeedToCreate, NeedToUpdate, WantToUpdate, ChangeDirectory }; /// used at importing a project without a .user file CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, Utils::Environment env); /// used to update if we have already a .user file /// recreates or updates the cbp file /// Also used to change the build directory of one buildconfiguration or create a new buildconfiguration CMakeOpenProjectWizard(CMakeManager *cmakeManager, Mode mode, const CMakeBuildInfo *info); QString buildDirectory() const; QString sourceDirectory() const; void setBuildDirectory(const QString &directory); bool useNinja() const; void setUseNinja(bool b); CMakeManager *cmakeManager() const; QString arguments() const; void setArguments(const QString &args); Utils::Environment environment() const; ProjectExplorer::Kit *kit() const; void setKit(ProjectExplorer::Kit *kit); bool existsUpToDateXmlFile() const; bool compatibleKitExist() const; private: void init(); bool hasInSourceBuild() const; CMakeManager *m_cmakeManager; QString m_buildDirectory; QString m_sourceDirectory; QString m_arguments; Utils::Environment m_environment; bool m_useNinja; ProjectExplorer::Kit *m_kit; }; class NoKitPage : public QWizardPage { Q_OBJECT public: NoKitPage(CMakeOpenProjectWizard *cmakeWizard); bool isComplete() const; private slots: void kitsChanged(); void showOptions(); private: QLabel *m_descriptionLabel; QPushButton *m_optionsButton; CMakeOpenProjectWizard *m_cmakeWizard; }; class InSourceBuildPage : public QWizardPage { Q_OBJECT public: InSourceBuildPage(CMakeOpenProjectWizard *cmakeWizard); private: CMakeOpenProjectWizard *m_cmakeWizard; }; class ShadowBuildPage : public QWizardPage { Q_OBJECT public: explicit ShadowBuildPage(CMakeOpenProjectWizard *cmakeWizard, bool change = false); private slots: void buildDirectoryChanged(); private: CMakeOpenProjectWizard *m_cmakeWizard; Utils::PathChooser *m_pc; }; class ChooseCMakePage : public QWizardPage { Q_OBJECT public: ChooseCMakePage(CMakeOpenProjectWizard *cmakeWizard); virtual bool isComplete() const; public slots: void cmakeExecutableChanged(); private: void updateErrorText(); QLabel *m_cmakeLabel; CMakeOpenProjectWizard *m_cmakeWizard; Utils::PathChooser *m_cmakeExecutable; }; class CMakeRunPage : public QWizardPage { Q_OBJECT public: enum Mode { Initial, NeedToUpdate, Recreate, ChangeDirectory, WantToUpdate }; explicit CMakeRunPage(CMakeOpenProjectWizard *cmakeWizard, Mode mode = Initial, const QString &buildDirectory = QString()); virtual void initializePage(); virtual bool validatePage(); virtual void cleanupPage(); virtual bool isComplete() const; private slots: void runCMake(); void cmakeFinished(); void cmakeReadyReadStandardOutput(); void cmakeReadyReadStandardError(); private: void initWidgets(); QByteArray cachedGeneratorFromFile(const QString &cache); CMakeOpenProjectWizard *m_cmakeWizard; QPlainTextEdit *m_output; QPushButton *m_runCMake; Utils::QtcProcess *m_cmakeProcess; Utils::FancyLineEdit *m_argumentsLineEdit; QComboBox *m_generatorComboBox; QLabel *m_descriptionLabel; QLabel *m_exitCodeLabel; bool m_haveCbpFile; Mode m_mode; QString m_buildDirectory; }; } } #endif // CMAKEOPENPROJECTWIZARD_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakebuildinfo.h0000644000015301777760000000521712323167666030426 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEBUILDINFO_H #define CMAKEBUILDINFO_H #include "cmakebuildconfiguration.h" #include "cmakeprojectmanager_global.h" #include #include #include #include #include #include namespace CMakeProjectManager { class CMAKEPROJECTMANAGER_EXPORT CMakeBuildInfo : public ProjectExplorer::BuildInfo { public: CMakeBuildInfo(const ProjectExplorer::IBuildConfigurationFactory *f) : ProjectExplorer::BuildInfo(f), useNinja(false) { } CMakeBuildInfo(const CMakeBuildConfiguration *bc) : ProjectExplorer::BuildInfo(ProjectExplorer::IBuildConfigurationFactory::find(bc->target())) { displayName = bc->displayName(); buildDirectory = bc->buildDirectory(); kitId = bc->target()->kit()->id(); environment = bc->environment(); useNinja = bc->useNinja(); QTC_ASSERT(bc->target()->project(), return); sourceDirectory = bc->target()->project()->projectDirectory(); } Utils::Environment environment; QString sourceDirectory; bool useNinja; }; } // namespace CMakeProjectManager #endif // CMAKEBUILDINFO_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeprojectmanager_global.h0000644000015301777760000000331512323167666032771 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEPROJECTMANAGER_GLOBAL_H #define CMAKEPROJECTMANAGER_GLOBAL_H #include #if defined(CMAKEPROJECTMANAGER_LIBRARY) # define CMAKEPROJECTMANAGER_EXPORT Q_DECL_EXPORT #else # define CMAKEPROJECTMANAGER_EXPORT Q_DECL_IMPORT #endif #endif // QMAKEPROJECTMANAGER_GLOBAL_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeprojectplugin.cpp0000644000015301777760000000733012323167666031671 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmakeprojectplugin.h" #include "cmakeprojectmanager.h" #include "cmakebuildconfiguration.h" #include "cmakerunconfiguration.h" #include "cmakeeditorfactory.h" #include "makestep.h" #include "cmakeprojectconstants.h" #include "cmakelocatorfilter.h" #include "cmakefilecompletionassist.h" #include "cmakehighlighterfactory.h" #include "cmakeappwizard.h" #include "cmaketoolmanager.h" #include "cmakekitinformation.h" #include #include #include #include #include #include using namespace CMakeProjectManager::Internal; class CMakeFeatureProvider : public Core::IFeatureProvider { Core::FeatureSet availableFeatures(const QString & /* platform */) const { return Core::FeatureSet(Core::Id(CMakeProjectManager::Constants::CMAKE_SUPPORT_FEATURE)); } QStringList availablePlatforms() const { return QStringList(); } QString displayNameForPlatform(const QString & /* platform */) const { return QString(); } }; CMakeProjectPlugin::CMakeProjectPlugin() { } CMakeProjectPlugin::~CMakeProjectPlugin() { } bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage) { if (!Core::MimeDatabase::addMimeTypes(QLatin1String(":cmakeproject/CMakeProjectManager.mimetypes.xml"), errorMessage)) return false; addAutoReleasedObject(new CMakeToolManager); CMakeSettingsPage *cmp = new CMakeSettingsPage(); addAutoReleasedObject(cmp); CMakeManager *manager = new CMakeManager(cmp); addAutoReleasedObject(manager); addAutoReleasedObject(new MakeStepFactory); addAutoReleasedObject(new CMakeRunConfigurationFactory); addAutoReleasedObject(new CMakeBuildConfigurationFactory); addAutoReleasedObject(new CMakeEditorFactory(manager)); addAutoReleasedObject(new CMakeLocatorFilter); addAutoReleasedObject(new CMakeFileCompletionAssistProvider(cmp)); addAutoReleasedObject(new CMakeFeatureProvider); addAutoReleasedObject(new CMakeHighlighterFactory); CMakeAppWizard::registerSelf(); ProjectExplorer::KitManager::registerKitInformation(new CMakeKitInformation()); return true; } void CMakeProjectPlugin::extensionsInitialized() { } Q_EXPORT_PLUGIN(CMakeProjectPlugin) qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeeditorfactory.cpp0000644000015301777760000000623412323167666031664 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmakeeditorfactory.h" #include "cmakeprojectconstants.h" #include "cmakeeditor.h" #include #include #include #include #include #include #include using namespace CMakeProjectManager; using namespace CMakeProjectManager::Internal; CMakeEditorFactory::CMakeEditorFactory(CMakeManager *manager) : m_manager(manager) { using namespace Core; using namespace TextEditor; setId(CMakeProjectManager::Constants::CMAKE_EDITOR_ID); setDisplayName(tr(CMakeProjectManager::Constants::CMAKE_EDITOR_DISPLAY_NAME)); addMimeType(CMakeProjectManager::Constants::CMAKEMIMETYPE); m_actionHandler = new TextEditorActionHandler(Constants::C_CMAKEEDITOR, TextEditorActionHandler::UnCommentSelection | TextEditorActionHandler::JumpToFileUnderCursor); ActionContainer *contextMenu = Core::ActionManager::createMenu(Constants::M_CONTEXT); Command *cmd; Context cmakeEditorContext = Context(Constants::C_CMAKEEDITOR); cmd = Core::ActionManager::command(TextEditor::Constants::JUMP_TO_FILE_UNDER_CURSOR); contextMenu->addAction(cmd); contextMenu->addSeparator(cmakeEditorContext); cmd = Core::ActionManager::command(TextEditor::Constants::UN_COMMENT_SELECTION); contextMenu->addAction(cmd); } Core::IEditor *CMakeEditorFactory::createEditor(QWidget *parent) { CMakeEditorWidget *rc = new CMakeEditorWidget(parent, this, m_actionHandler); TextEditor::TextEditorSettings::initializeEditor(rc); return rc->editor(); } qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/makestep.cpp0000644000015301777760000004351712323167675027623 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "makestep.h" #include "cmakebuildconfiguration.h" #include "cmakeparser.h" #include "cmakeprojectconstants.h" #include "cmakeproject.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace CMakeProjectManager; using namespace CMakeProjectManager::Internal; using namespace ProjectExplorer; namespace { const char MS_ID[] = "CMakeProjectManager.MakeStep"; const char CLEAN_KEY[] = "CMakeProjectManager.MakeStep.Clean"; const char BUILD_TARGETS_KEY[] = "CMakeProjectManager.MakeStep.BuildTargets"; const char ADDITIONAL_ARGUMENTS_KEY[] = "CMakeProjectManager.MakeStep.AdditionalArguments"; const char USE_NINJA_KEY[] = "CMakeProjectManager.MakeStep.UseNinja"; } MakeStep::MakeStep(BuildStepList *bsl) : AbstractProcessStep(bsl, Core::Id(MS_ID)), m_clean(false) { ctor(); } MakeStep::MakeStep(BuildStepList *bsl, const Core::Id id) : AbstractProcessStep(bsl, id), m_clean(false) { ctor(); } MakeStep::MakeStep(BuildStepList *bsl, MakeStep *bs) : AbstractProcessStep(bsl, bs), m_clean(bs->m_clean), m_buildTargets(bs->m_buildTargets), m_additionalArguments(bs->m_additionalArguments) { ctor(); } void MakeStep::ctor() { m_percentProgress = QRegExp(QLatin1String("^\\[\\s*(\\d*)%\\]")); m_ninjaProgress = QRegExp(QLatin1String("^\\[\\s*(\\d*)/\\s*(\\d*)")); m_ninjaProgressString = QLatin1String("[%f/%t "); // ninja: [33/100 //: Default display name for the cmake make step. setDefaultDisplayName(tr("Make")); CMakeBuildConfiguration *bc = cmakeBuildConfiguration(); if (bc) { m_useNinja = bc->useNinja(); m_activeConfiguration = 0; connect(bc, SIGNAL(useNinjaChanged(bool)), this, SLOT(setUseNinja(bool))); } else { // That means the step is in the deploylist, so we listen to the active build config // changed signal and react to the activeBuildConfigurationChanged() signal of the buildconfiguration m_activeConfiguration = targetsActiveBuildConfiguration(); m_useNinja = m_activeConfiguration->useNinja(); connect (target(), SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)), this, SLOT(activeBuildConfigurationChanged())); activeBuildConfigurationChanged(); } connect(static_cast(project()), SIGNAL(buildTargetsChanged()), this, SLOT(buildTargetsChanged())); } MakeStep::~MakeStep() { } CMakeBuildConfiguration *MakeStep::cmakeBuildConfiguration() const { return static_cast(buildConfiguration()); } CMakeBuildConfiguration *MakeStep::targetsActiveBuildConfiguration() const { return static_cast(target()->activeBuildConfiguration()); } void MakeStep::activeBuildConfigurationChanged() { if (m_activeConfiguration) disconnect(m_activeConfiguration, SIGNAL(useNinjaChanged(bool)), this, SLOT(setUseNinja(bool))); m_activeConfiguration = targetsActiveBuildConfiguration(); if (m_activeConfiguration) { connect(m_activeConfiguration, SIGNAL(useNinjaChanged(bool)), this, SLOT(setUseNinja(bool))); setUseNinja(m_activeConfiguration->useNinja()); } } void MakeStep::buildTargetsChanged() { QStringList filteredTargets; foreach (const QString t, static_cast(project())->buildTargetTitles()) { if (m_buildTargets.contains(t)) filteredTargets.append(t); } setBuildTargets(filteredTargets); } void MakeStep::setClean(bool clean) { m_clean = clean; } QVariantMap MakeStep::toMap() const { QVariantMap map(AbstractProcessStep::toMap()); map.insert(QLatin1String(CLEAN_KEY), m_clean); map.insert(QLatin1String(BUILD_TARGETS_KEY), m_buildTargets); map.insert(QLatin1String(ADDITIONAL_ARGUMENTS_KEY), m_additionalArguments); map.insert(QLatin1String(USE_NINJA_KEY), m_useNinja); return map; } bool MakeStep::fromMap(const QVariantMap &map) { m_clean = map.value(QLatin1String(CLEAN_KEY)).toBool(); m_buildTargets = map.value(QLatin1String(BUILD_TARGETS_KEY)).toStringList(); m_additionalArguments = map.value(QLatin1String(ADDITIONAL_ARGUMENTS_KEY)).toString(); m_useNinja = map.value(QLatin1String(USE_NINJA_KEY)).toBool(); return BuildStep::fromMap(map); } bool MakeStep::init() { CMakeBuildConfiguration *bc = cmakeBuildConfiguration(); if (!bc) bc = static_cast(target()->activeBuildConfiguration()); m_tasks.clear(); ToolChain *tc = ToolChainKitInformation::toolChain(target()->kit()); if (!tc) { m_tasks.append(Task(Task::Error, tr("Qt Creator needs a compiler set up to build. Configure a compiler in the kit options."), Utils::FileName(), -1, ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)); return true; // otherwise the tasks will not get reported } QString arguments = Utils::QtcProcess::joinArgs(m_buildTargets); Utils::QtcProcess::addArgs(&arguments, additionalArguments()); setIgnoreReturnValue(m_clean); ProcessParameters *pp = processParameters(); pp->setMacroExpander(bc->macroExpander()); Utils::Environment env = bc->environment(); // Force output to english for the parsers. Do this here and not in the toolchain's // addToEnvironment() to not screw up the users run environment. env.set(QLatin1String("LC_ALL"), QLatin1String("C")); if (m_useNinja && !env.value(QLatin1String("NINJA_STATUS")).startsWith(m_ninjaProgressString)) env.set(QLatin1String("NINJA_STATUS"), m_ninjaProgressString + QLatin1String("%o/sec] ")); pp->setEnvironment(env); pp->setWorkingDirectory(bc->buildDirectory().toString()); pp->setCommand(makeCommand(tc, bc->environment())); pp->setArguments(arguments); pp->resolveAll(); setOutputParser(new CMakeParser()); IOutputParser *parser = target()->kit()->createOutputParser(); if (parser) appendOutputParser(parser); outputParser()->setWorkingDirectory(pp->effectiveWorkingDirectory()); return AbstractProcessStep::init(); } void MakeStep::run(QFutureInterface &fi) { bool canContinue = true; foreach (const Task &t, m_tasks) { addTask(t); canContinue = false; } if (!canContinue) { emit addOutput(tr("Configuration is faulty. Check the Issues view for details."), BuildStep::MessageOutput); fi.reportResult(false); emit finished(); return; } AbstractProcessStep::run(fi); } BuildStepConfigWidget *MakeStep::createConfigWidget() { return new MakeStepConfigWidget(this); } bool MakeStep::immutable() const { return false; } void MakeStep::stdOutput(const QString &line) { if (m_percentProgress.indexIn(line) != -1) { bool ok = false; int percent = m_percentProgress.cap(1).toInt(&ok); if (ok) futureInterface()->setProgressValue(percent); } else if (m_ninjaProgress.indexIn(line) != -1) { bool ok = false; int done = m_ninjaProgress.cap(1).toInt(&ok); if (ok) { int all = m_ninjaProgress.cap(2).toInt(&ok); if (ok && all != 0) { int percent = 100.0 * done/all; futureInterface()->setProgressValue(percent); } } } if (m_useNinja) AbstractProcessStep::stdError(line); else AbstractProcessStep::stdOutput(line); } QStringList MakeStep::buildTargets() const { return m_buildTargets; } bool MakeStep::buildsBuildTarget(const QString &target) const { return m_buildTargets.contains(target); } void MakeStep::setBuildTarget(const QString &buildTarget, bool on) { QStringList old = m_buildTargets; if (on && !old.contains(buildTarget)) old << buildTarget; else if (!on && old.contains(buildTarget)) old.removeOne(buildTarget); setBuildTargets(old); } void MakeStep::setBuildTargets(const QStringList &targets) { if (targets != m_buildTargets) { m_buildTargets = targets; emit targetsToBuildChanged(); } } void MakeStep::clearBuildTargets() { m_buildTargets.clear(); } QString MakeStep::additionalArguments() const { return m_additionalArguments; } void MakeStep::setAdditionalArguments(const QString &list) { m_additionalArguments = list; } QString MakeStep::makeCommand(ProjectExplorer::ToolChain *tc, const Utils::Environment &env) const { if (m_useNinja) return QLatin1String("ninja"); if (tc) return tc->makeCommand(env); return QLatin1String("make"); } void MakeStep::setUseNinja(bool useNinja) { if (m_useNinja != useNinja) { m_useNinja = useNinja; emit makeCommandChanged(); } } // // MakeStepConfigWidget // MakeStepConfigWidget::MakeStepConfigWidget(MakeStep *makeStep) : m_makeStep(makeStep) { QFormLayout *fl = new QFormLayout(this); fl->setMargin(0); fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); setLayout(fl); m_additionalArguments = new QLineEdit(this); fl->addRow(tr("Additional arguments:"), m_additionalArguments); m_additionalArguments->setText(m_makeStep->additionalArguments()); m_buildTargetsList = new QListWidget; m_buildTargetsList->setMinimumHeight(200); fl->addRow(tr("Targets:"), m_buildTargetsList); // TODO update this list also on rescans of the CMakeLists.txt CMakeProject *pro = static_cast(m_makeStep->project()); QStringList targetList = pro->buildTargetTitles(); targetList.sort(); foreach (const QString &buildTarget, targetList) { QListWidgetItem *item = new QListWidgetItem(buildTarget, m_buildTargetsList); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setCheckState(m_makeStep->buildsBuildTarget(item->text()) ? Qt::Checked : Qt::Unchecked); } updateDetails(); connect(m_additionalArguments, SIGNAL(textEdited(QString)), this, SLOT(additionalArgumentsEdited())); connect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*))); connect(ProjectExplorer::ProjectExplorerPlugin::instance(), SIGNAL(settingsChanged()), this, SLOT(updateDetails())); connect(pro, SIGNAL(buildTargetsChanged()), this, SLOT(buildTargetsChanged())); connect(m_makeStep, SIGNAL(targetsToBuildChanged()), this, SLOT(selectedBuildTargetsChanged())); connect(pro, SIGNAL(environmentChanged()), this, SLOT(updateDetails())); connect(m_makeStep, SIGNAL(makeCommandChanged()), this, SLOT(updateDetails())); } void MakeStepConfigWidget::additionalArgumentsEdited() { m_makeStep->setAdditionalArguments(m_additionalArguments->text()); updateDetails(); } void MakeStepConfigWidget::itemChanged(QListWidgetItem *item) { m_makeStep->setBuildTarget(item->text(), item->checkState() & Qt::Checked); updateDetails(); } QString MakeStepConfigWidget::displayName() const { return tr("Make", "CMakeProjectManager::MakeStepConfigWidget display name."); } void MakeStepConfigWidget::buildTargetsChanged() { disconnect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*))); m_buildTargetsList->clear(); CMakeProject *pro = static_cast(m_makeStep->target()->project()); foreach (const QString& buildTarget, pro->buildTargetTitles()) { QListWidgetItem *item = new QListWidgetItem(buildTarget, m_buildTargetsList); item->setFlags(item->flags() | Qt::ItemIsUserCheckable); item->setCheckState(m_makeStep->buildsBuildTarget(item->text()) ? Qt::Checked : Qt::Unchecked); } connect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*))); updateSummary(); } void MakeStepConfigWidget::selectedBuildTargetsChanged() { disconnect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*))); for (int y = 0; y < m_buildTargetsList->count(); ++y) { QListWidgetItem *item = m_buildTargetsList->item(y); item->setCheckState(m_makeStep->buildsBuildTarget(item->text()) ? Qt::Checked : Qt::Unchecked); } connect(m_buildTargetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*))); updateSummary(); } void MakeStepConfigWidget::updateDetails() { BuildConfiguration *bc = m_makeStep->buildConfiguration(); if (!bc) bc = m_makeStep->target()->activeBuildConfiguration(); if (!bc) { m_summaryText = tr("No build configuration found on this kit."); updateSummary(); return; } ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(m_makeStep->target()->kit()); if (tc) { QString arguments = Utils::QtcProcess::joinArgs(m_makeStep->buildTargets()); Utils::QtcProcess::addArgs(&arguments, m_makeStep->additionalArguments()); ProcessParameters param; param.setMacroExpander(bc->macroExpander()); param.setEnvironment(bc->environment()); param.setWorkingDirectory(bc->buildDirectory().toString()); param.setCommand(m_makeStep->makeCommand(tc, bc->environment())); param.setArguments(arguments); m_summaryText = param.summary(displayName()); } else { m_summaryText = QLatin1String("") + ProjectExplorer::ToolChainKitInformation::msgNoToolChainInTarget() + QLatin1String(""); } emit updateSummary(); } QString MakeStepConfigWidget::summaryText() const { return m_summaryText; } // // MakeStepFactory // MakeStepFactory::MakeStepFactory(QObject *parent) : ProjectExplorer::IBuildStepFactory(parent) { } MakeStepFactory::~MakeStepFactory() { } bool MakeStepFactory::canCreate(BuildStepList *parent, const Core::Id id) const { if(!canHandle(parent)) return false; if (parent->target()->project()->id() == Constants::CMAKEPROJECT_ID) return id == MS_ID; return false; } BuildStep *MakeStepFactory::create(BuildStepList *parent, const Core::Id id) { if (!canCreate(parent, id)) return 0; MakeStep *step = new MakeStep(parent); if (parent->id() == ProjectExplorer::Constants::BUILDSTEPS_CLEAN) { step->setClean(true); step->setAdditionalArguments(QLatin1String("clean")); } return step; } bool MakeStepFactory::canClone(BuildStepList *parent, BuildStep *source) const { return canCreate(parent, source->id()); } BuildStep *MakeStepFactory::clone(BuildStepList *parent, BuildStep *source) { if (!canClone(parent, source)) return 0; return new MakeStep(parent, static_cast(source)); } bool MakeStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const { return canCreate(parent, idFromMap(map)); } BuildStep *MakeStepFactory::restore(BuildStepList *parent, const QVariantMap &map) { if (!canRestore(parent, map)) return 0; MakeStep *bs(new MakeStep(parent)); if (bs->fromMap(map)) return bs; delete bs; return 0; } QList MakeStepFactory::availableCreationIds(ProjectExplorer::BuildStepList *parent) const { if (canHandle(parent) && parent->target()->project()->id() == Constants::CMAKEPROJECT_ID) return QList() << Core::Id(MS_ID); return QList(); } QString MakeStepFactory::displayNameForId(const Core::Id id) const { if (id == MS_ID) return tr("Make", "Display name for CMakeProjectManager::MakeStep id."); return QString(); } bool MakeStepFactory::canHandle(BuildStepList *parent) const { if(!parent->parent()) return false; //only create buildsteps for a CMakeBuildConfiguration return parent->parent()->metaObject() == &CMakeBuildConfiguration::staticMetaObject; } void MakeStep::processStarted() { futureInterface()->setProgressRange(0, 100); AbstractProcessStep::processStarted(); } void MakeStep::processFinished(int exitCode, QProcess::ExitStatus status) { AbstractProcessStep::processFinished(exitCode, status); futureInterface()->setProgressValue(100); } qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/generatorinfo.h0000644000015301777760000000465612323167666030322 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKE_INTERNAL_GENERATORINFO_H #define CMAKE_INTERNAL_GENERATORINFO_H #include "cmakeprojectmanager.h" #include "cmakeprojectmanager_global.h" #include #include #include namespace CMakeProjectManager { class CMAKEPROJECTMANAGER_EXPORT GeneratorInfo { Q_DECLARE_TR_FUNCTIONS(CMakeProjectManager::GeneratorInfo) public: enum Ninja { NoNinja, OfferNinja, ForceNinja }; static QList generatorInfosFor(ProjectExplorer::Kit *k, Ninja n, bool preferNinja, bool hasCodeBlocks); GeneratorInfo(); explicit GeneratorInfo(ProjectExplorer::Kit *kit, bool ninja = false); ProjectExplorer::Kit *kit() const; bool isNinja() const; QString displayName() const; QByteArray generatorArgument() const; QByteArray generator() const; private: ProjectExplorer::Kit *m_kit; bool m_isNinja; }; } // namespace CMake Q_DECLARE_METATYPE(CMakeProjectManager::GeneratorInfo) #endif // CMAKE_INTERNAL_GENERATORINFO_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeeditor.h0000644000015301777760000000636312323167666027744 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEEDITOR_H #define CMAKEEDITOR_H #include "cmakeeditorfactory.h" #include #include #include #include namespace TextEditor { class FontSettings; } namespace CMakeProjectManager { class CMakeManager; namespace Internal { class CMakeEditorWidget; class CMakeHighlighter; class CMakeEditor : public TextEditor::BaseTextEditor { Q_OBJECT public: CMakeEditor(CMakeEditorWidget *); bool duplicateSupported() const { return true; } Core::IEditor *duplicate(QWidget *parent); Core::Id id() const; TextEditor::CompletionAssistProvider *completionAssistProvider(); private slots: void markAsChanged(); void build(); }; class CMakeEditorWidget : public TextEditor::BaseTextEditorWidget { Q_OBJECT public: CMakeEditorWidget(QWidget *parent, CMakeEditorFactory *factory, TextEditor::TextEditorActionHandler *ah); bool save(const QString &fileName = QString()); CMakeEditorFactory *factory() { return m_factory; } TextEditor::TextEditorActionHandler *actionHandler() const { return m_ah; } Link findLinkAt(const QTextCursor &cursor, bool resolveTarget = true, bool inNextSplit = false); protected: TextEditor::BaseTextEditor *createEditor(); void contextMenuEvent(QContextMenuEvent *e); public slots: void unCommentSelection(); private: CMakeEditorFactory *m_factory; TextEditor::TextEditorActionHandler *m_ah; Utils::CommentDefinition m_commentDefinition; }; class CMakeDocument : public TextEditor::BaseTextDocument { Q_OBJECT public: CMakeDocument(); QString defaultPath() const; QString suggestedFileName() const; }; } // namespace Internal } // namespace CMakeProjectManager #endif // CMAKEEDITOR_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakefilecompletionassist.cpp0000644000015301777760000000445212323167666033246 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmakefilecompletionassist.h" #include "cmakeprojectconstants.h" #include "cmakeprojectmanager.h" #include using namespace CMakeProjectManager::Internal; using namespace TextEditor; // ------------------------------- // CMakeFileCompletionAssistProvider // ------------------------------- CMakeFileCompletionAssistProvider::CMakeFileCompletionAssistProvider(CMakeSettingsPage *settingsPage) : m_settingsPage(settingsPage) {} CMakeFileCompletionAssistProvider::~CMakeFileCompletionAssistProvider() {} bool CMakeFileCompletionAssistProvider::supportsEditor(const Core::Id &editorId) const { return editorId == CMakeProjectManager::Constants::CMAKE_EDITOR_ID; } IAssistProcessor *CMakeFileCompletionAssistProvider::createProcessor() const { return new KeywordsCompletionAssistProcessor(m_settingsPage->keywords()); } qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakekitinformation.cpp0000644000015301777760000001252312323167675032041 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Canonical Ltd. ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmakekitinformation.h" #include "cmaketool.h" #include "cmaketoolmanager.h" #include "cmakeprojectconstants.h" #include "generatorinfo.h" #include using namespace ProjectExplorer; using namespace Utils; namespace CMakeProjectManager { CMakeKitInformation::CMakeKitInformation() { setId(CMakeKitInformation::id()); } QVariant CMakeKitInformation::defaultValue(Kit *kit) const { Q_UNUSED(kit); return QString::fromLatin1(Constants::CMAKE_TOOL_ID); } QList CMakeKitInformation::validate(const Kit *) const { return QList(); } KitInformation::ItemList CMakeKitInformation::toUserOutput(const Kit *kit) const { return KitInformation::ItemList() << qMakePair(tr("CMake Tool"), cmakeTool(kit)->displayName()); } KitConfigWidget *CMakeKitInformation::createConfigWidget(Kit *kit) const { return new CMakeKitInformationWidget(kit, this); } Core::Id CMakeKitInformation::id() { return "CMakeProjectManager.KitInformation"; } bool CMakeKitInformation::hasSpecialCMakeTool(const Kit *kit) { QString id(kit->value(CMakeKitInformation::id()).toString()); if(id.isNull()) return false; if(id == QString::fromLatin1(Constants::CMAKE_TOOL_ID)) return false; return true; } ICMakeTool* CMakeKitInformation::cmakeTool(const Kit *kit) { Core::Id id = cmakeToolId(kit); if(!id.isValid() || id == Constants::CMAKE_TOOL_ID) return CMakeToolManager::defaultCMakeTool(); ICMakeTool* tool = CMakeToolManager::cmakeTool(id); //the cmake tool id is not known, fall back to default tool //should we also remove the ID from the KIT? if(!tool) { return CMakeToolManager::defaultCMakeTool(); } return tool; } Core::Id CMakeKitInformation::cmakeToolId(const Kit *kit) { Core::Id test = Core::Id::fromSetting(kit->value(CMakeKitInformation::id())); qDebug()<<"Id for kit: "<displayName()<<" "<setValue(CMakeKitInformation::id(), toolId.toSetting()); } /////////////// // CMakeKitInformationWidget /////////////// CMakeKitInformationWidget::CMakeKitInformationWidget(Kit *kit, const KitInformation *ki) : KitConfigWidget(kit, ki), m_label(new ElidingLabel) { refresh(); } CMakeKitInformationWidget::~CMakeKitInformationWidget() { delete m_label; } QString CMakeKitInformationWidget::displayName() const { return tr("CMake Tool"); } QString CMakeKitInformationWidget::toolTip() const { return tr("The CMake Tool used for this Kit."); } void CMakeKitInformationWidget::makeReadOnly() { } void CMakeKitInformationWidget::refresh() { m_label->setText(CMakeKitInformation::cmakeTool(m_kit)->displayName()); } bool CMakeKitInformationWidget::visibleInKit() { Core::Id toolId = CMakeKitInformation::cmakeToolId(m_kit); if(!toolId.isValid() || toolId == Constants::CMAKE_TOOL_ID) return false; return true; } QWidget *CMakeKitInformationWidget::mainWidget() const { return m_label; } QWidget *CMakeKitInformationWidget::buttonWidget() const { return 0; } bool CMakeKitMatcher::matches(const ProjectExplorer::Kit *k) const { //this is safe, since the returned list is not used for more than checking //if there are any results ProjectExplorer::Kit* otherKit = const_cast(k); ICMakeTool* cmake = CMakeToolManager::cmakeToolForKit(k); if(!cmake) return false; QList infos = GeneratorInfo::generatorInfosFor(otherKit ,GeneratorInfo::OfferNinja ,false //not relevant at this place ,cmake->hasCodeBlocksMsvcGenerator()); return (infos.size() > 0); } } // namespace CMakeProjectManager qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/makestep.h0000644000015301777760000001245112323167666027261 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef MAKESTEP_H #define MAKESTEP_H #include "cmakeprojectmanager_global.h" #include QT_BEGIN_NAMESPACE class QLineEdit; class QListWidget; class QListWidgetItem; QT_END_NAMESPACE namespace ProjectExplorer { class ToolChain; } namespace CMakeProjectManager { class CMakeBuildConfiguration; class MakeStepFactory; class CMAKEPROJECTMANAGER_EXPORT MakeStep : public ProjectExplorer::AbstractProcessStep { Q_OBJECT friend class MakeStepFactory; public: MakeStep(ProjectExplorer::BuildStepList *bsl); virtual ~MakeStep(); CMakeBuildConfiguration *cmakeBuildConfiguration() const; virtual bool init(); virtual void run(QFutureInterface &fi); virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); virtual bool immutable() const; QStringList buildTargets() const; bool buildsBuildTarget(const QString &target) const; void setBuildTarget(const QString &target, bool on); void setBuildTargets(const QStringList &targets); void clearBuildTargets(); QString additionalArguments() const; void setAdditionalArguments(const QString &list); virtual QString makeCommand(ProjectExplorer::ToolChain *tc, const Utils::Environment &env) const; void setClean(bool clean); QVariantMap toMap() const; public slots: void setUseNinja(bool); void activeBuildConfigurationChanged(); private slots: void buildTargetsChanged(); signals: void makeCommandChanged(); void targetsToBuildChanged(); protected: void processStarted(); void processFinished(int exitCode, QProcess::ExitStatus status); MakeStep(ProjectExplorer::BuildStepList *bsl, MakeStep *bs); MakeStep(ProjectExplorer::BuildStepList *bsl, const Core::Id id); bool fromMap(const QVariantMap &map); // For parsing [ 76%] virtual void stdOutput(const QString &line); private: void ctor(); CMakeBuildConfiguration *targetsActiveBuildConfiguration() const; bool m_clean; QRegExp m_percentProgress; QRegExp m_ninjaProgress; QString m_ninjaProgressString; QStringList m_buildTargets; QString m_additionalArguments; QList m_tasks; bool m_useNinja; CMakeBuildConfiguration *m_activeConfiguration; }; class CMAKEPROJECTMANAGER_EXPORT MakeStepConfigWidget :public ProjectExplorer::BuildStepConfigWidget { Q_OBJECT public: MakeStepConfigWidget(MakeStep *makeStep); virtual QString displayName() const; virtual QString summaryText() const; private slots: void itemChanged(QListWidgetItem*); void additionalArgumentsEdited(); void updateDetails(); void buildTargetsChanged(); void selectedBuildTargetsChanged(); private: MakeStep *m_makeStep; QListWidget *m_buildTargetsList; QLineEdit *m_additionalArguments; QString m_summaryText; }; class CMAKEPROJECTMANAGER_EXPORT MakeStepFactory : public ProjectExplorer::IBuildStepFactory { Q_OBJECT public: explicit MakeStepFactory(QObject *parent = 0); virtual ~MakeStepFactory(); bool canCreate(ProjectExplorer::BuildStepList *parent, const Core::Id id) const; ProjectExplorer::BuildStep *create(ProjectExplorer::BuildStepList *parent, const Core::Id id); bool canClone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *source) const; ProjectExplorer::BuildStep *clone(ProjectExplorer::BuildStepList *parent, ProjectExplorer::BuildStep *source); bool canRestore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map) const; ProjectExplorer::BuildStep *restore(ProjectExplorer::BuildStepList *parent, const QVariantMap &map); QList availableCreationIds(ProjectExplorer::BuildStepList *bc) const; QString displayNameForId(const Core::Id id) const; private: bool canHandle (ProjectExplorer::BuildStepList *parent) const; }; } // namespace CMakeProjectManager #endif // MAKESTEP_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakevalidator.cpp0000644000015301777760000002540512323167666030774 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmakevalidator.h" #include #include #include using namespace CMakeProjectManager::Internal; /////////////////////////// // CMakeValidator /////////////////////////// CMakeValidator::CMakeValidator() : m_state(Invalid), m_process(0), m_hasCodeBlocksMsvcGenerator(false), m_hasCodeBlocksNinjaGenerator(false) { } CMakeValidator::~CMakeValidator() { cancel(); } void CMakeValidator::cancel() { if (m_process) { disconnect(m_process, SIGNAL(finished(int))); m_process->waitForFinished(); delete m_process; m_process = 0; } } void CMakeValidator::setCMakeExecutable(const QString &executable) { cancel(); m_process = new QProcess(); connect(m_process, SIGNAL(finished(int)), this, SLOT(finished(int))); m_executable = executable; QFileInfo fi(m_executable); if (fi.exists() && fi.isExecutable()) { // Run it to find out more m_state = CMakeValidator::RunningBasic; if (!startProcess(QStringList(QLatin1String("--help")))) m_state = CMakeValidator::Invalid; } else { m_state = CMakeValidator::Invalid; } } void CMakeValidator::finished(int exitCode) { if (exitCode) { m_state = CMakeValidator::Invalid; return; } if (m_state == CMakeValidator::RunningBasic) { QByteArray response = m_process->readAll(); m_hasCodeBlocksMsvcGenerator = response.contains("CodeBlocks - NMake Makefiles"); m_hasCodeBlocksNinjaGenerator = response.contains("CodeBlocks - Ninja"); if (response.isEmpty()) { m_state = CMakeValidator::Invalid; } else { m_state = CMakeValidator::RunningFunctionList; if (!startProcess(QStringList(QLatin1String("--help-command-list")))) finished(0); // should never happen, just continue } } else if (m_state == CMakeValidator::RunningFunctionList) { parseFunctionOutput(m_process->readAll()); m_state = CMakeValidator::RunningFunctionDetails; if (!startProcess(QStringList(QLatin1String("--help-commands")))) finished(0); // should never happen, just continue } else if (m_state == CMakeValidator::RunningFunctionDetails) { parseFunctionDetailsOutput(m_process->readAll()); m_state = CMakeValidator::RunningPropertyList; if (!startProcess(QStringList(QLatin1String("--help-property-list")))) finished(0); // should never happen, just continue } else if (m_state == CMakeValidator::RunningPropertyList) { parseVariableOutput(m_process->readAll()); m_state = CMakeValidator::RunningVariableList; if (!startProcess(QStringList(QLatin1String("--help-variable-list")))) finished(0); // should never happen, just continue } else if (m_state == CMakeValidator::RunningVariableList) { parseVariableOutput(m_process->readAll()); parseDone(); m_state = CMakeValidator::RunningDone; } } bool CMakeValidator::isValid() const { if (m_state == CMakeValidator::Invalid) return false; if (m_state == CMakeValidator::RunningBasic) m_process->waitForFinished(); return (m_state != CMakeValidator::Invalid); } bool CMakeValidator::startProcess(const QStringList &args) { m_process->start(m_executable, args); return m_process->waitForStarted(2000); } QString CMakeValidator::cmakeExecutable() const { return m_executable; } bool CMakeValidator::hasCodeBlocksMsvcGenerator() const { if (!isValid()) return false; return m_hasCodeBlocksMsvcGenerator; } bool CMakeValidator::hasCodeBlocksNinjaGenerator() const { if (!isValid()) return false; return m_hasCodeBlocksNinjaGenerator; } TextEditor::Keywords CMakeValidator::keywords() { while (m_state != RunningDone && m_state != CMakeValidator::Invalid) { m_process->waitForFinished(); } if (m_state == CMakeValidator::Invalid) return TextEditor::Keywords(QStringList(), QStringList(), QMap()); return TextEditor::Keywords(m_variables, m_functions, m_functionArgs); } static void extractKeywords(const QByteArray &input, QStringList *destination) { if (!destination) return; QString keyword; int ignoreZone = 0; for (int i = 0; i < input.count(); ++i) { const QChar chr = QLatin1Char(input.at(i)); if (chr == QLatin1Char('{')) ++ignoreZone; if (chr == QLatin1Char('}')) --ignoreZone; if (ignoreZone == 0) { if ((chr.isLetterOrNumber() && chr.isUpper()) || chr == QLatin1Char('_')) { keyword += chr; } else { if (!keyword.isEmpty()) { if (keyword.size() > 1) *destination << keyword; keyword.clear(); } } } } if (keyword.size() > 1) *destination << keyword; } void CMakeValidator::parseFunctionOutput(const QByteArray &output) { QList cmakeFunctionsList = output.split('\n'); m_functions.clear(); if (!cmakeFunctionsList.isEmpty()) { cmakeFunctionsList.removeFirst(); //remove version string foreach (const QByteArray &function, cmakeFunctionsList) m_functions << QString::fromLocal8Bit(function.trimmed()); } } QString CMakeValidator::formatFunctionDetails(const QString &command, const QString &args) { return QString::fromLatin1("") .arg(Qt::escape(command)).arg(Qt::escape(args)); } void CMakeValidator::parseFunctionDetailsOutput(const QByteArray &output) { QStringList cmakeFunctionsList = m_functions; QList cmakeCommandsHelp = output.split('\n'); for (int i = 0; i < cmakeCommandsHelp.count(); ++i) { QByteArray lineTrimmed = cmakeCommandsHelp.at(i).trimmed(); if (cmakeFunctionsList.isEmpty()) break; if (cmakeFunctionsList.first().toLatin1() == lineTrimmed) { QStringList commandSyntaxes; QString currentCommandSyntax; QString currentCommand = cmakeFunctionsList.takeFirst(); ++i; for (; i < cmakeCommandsHelp.count(); ++i) { lineTrimmed = cmakeCommandsHelp.at(i).trimmed(); if (!cmakeFunctionsList.isEmpty() && cmakeFunctionsList.first().toLatin1() == lineTrimmed) { //start of next function in output if (!currentCommandSyntax.isEmpty()) commandSyntaxes << currentCommandSyntax.append(QLatin1String("
%1%2
")); --i; break; } if (lineTrimmed.startsWith(currentCommand.toLatin1() + "(")) { if (!currentCommandSyntax.isEmpty()) commandSyntaxes << currentCommandSyntax.append(QLatin1String("")); QByteArray argLine = lineTrimmed.mid(currentCommand.length()); extractKeywords(argLine, &m_variables); currentCommandSyntax = formatFunctionDetails(currentCommand, QString::fromUtf8(argLine)); } else { if (!currentCommandSyntax.isEmpty()) { if (lineTrimmed.isEmpty()) { commandSyntaxes << currentCommandSyntax.append(QLatin1String("")); currentCommandSyntax.clear(); } else { extractKeywords(lineTrimmed, &m_variables); currentCommandSyntax += QString::fromLatin1(" %1") .arg(Qt::escape(QString::fromLocal8Bit(lineTrimmed))); } } } } m_functionArgs[currentCommand] = commandSyntaxes; } } m_functions = m_functionArgs.keys(); } void CMakeValidator::parseVariableOutput(const QByteArray &output) { QList variableList = output.split('\n'); if (!variableList.isEmpty()) { variableList.removeFirst(); //remove version string foreach (const QByteArray &variable, variableList) { if (variable.contains("_")) { m_variables << QString::fromLocal8Bit(variable).replace(QLatin1String("_"), QLatin1String("_DEBUG")); m_variables << QString::fromLocal8Bit(variable).replace(QLatin1String("_"), QLatin1String("_RELEASE")); m_variables << QString::fromLocal8Bit(variable).replace(QLatin1String("_"), QLatin1String("_MINSIZEREL")); m_variables << QString::fromLocal8Bit(variable).replace(QLatin1String("_"), QLatin1String("_RELWITHDEBINFO")); } else if (variable.contains("_")) { m_variables << QString::fromLocal8Bit(variable).replace(QLatin1String("_"), QLatin1String("_C")); m_variables << QString::fromLocal8Bit(variable).replace(QLatin1String("_"), QLatin1String("_CXX")); } else if (!variable.contains("_<") && !variable.contains('[')) { m_variables << QString::fromLocal8Bit(variable); } } } } void CMakeValidator::parseDone() { m_variables.sort(); m_variables.removeDuplicates(); } qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeprojectmanager.h0000644000015301777760000000613412323167666031453 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEPROJECTMANAGER_H #define CMAKEPROJECTMANAGER_H #include "cmakeprojectmanager_global.h" #include "cmakesettingspage.h" #include #include #include #include #include #include #include #include #include #include #include #include #include "cmakevalidator.h" QT_FORWARD_DECLARE_CLASS(QLabel) namespace Utils { class QtcProcess; } namespace CMakeProjectManager { class CMAKEPROJECTMANAGER_EXPORT CMakeManager : public ProjectExplorer::IProjectManager { Q_OBJECT public: CMakeManager(Internal::CMakeSettingsPage *cmakeSettingsPage); virtual ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString); virtual QString mimeType() const; static bool preferNinja(); static QString findCbpFile(const QDir &); static QString findDumperLibrary(const Utils::Environment &env); private slots: void updateContextMenu(ProjectExplorer::Project *project, ProjectExplorer::Node *node); void runCMake(); void runCMakeContextMenu(); private: void runCMake(ProjectExplorer::Project *project); static QString qtVersionForQMake(const QString &qmakePath); static QPair findQtDir(const Utils::Environment &env); Internal::CMakeSettingsPage *m_settingsPage; QAction *m_runCMakeAction; QAction *m_runCMakeActionContextMenu; ProjectExplorer::Project *m_contextProject; static CMakeManager* m_instance; }; } // namespace CMakeProjectManager #endif // CMAKEPROJECTMANAGER_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakelocatorfilter.cpp0000644000015301777760000001170512323167666031656 0ustar pbusernogroup00000000000000/************************************************************************** ** ** Copyright (C) 2014 Kläralvdalens Datakonsult AB, a KDAB Group company. ** Contact: Kläralvdalens Datakonsult AB (info@kdab.com) ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmakelocatorfilter.h" #include "cmakeproject.h" #include "makestep.h" #include #include #include #include #include #include using namespace CMakeProjectManager; using namespace CMakeProjectManager::Internal; using namespace ProjectExplorer; using namespace Utils; CMakeLocatorFilter::CMakeLocatorFilter() { setId("Build CMake target"); setDisplayName(tr("Build CMake target")); setShortcutString(QLatin1String("cm")); connect(SessionManager::instance(), SIGNAL(projectAdded(ProjectExplorer::Project*)), this, SLOT(slotProjectListUpdated())); connect(SessionManager::instance(), SIGNAL(projectRemoved(ProjectExplorer::Project*)), this, SLOT(slotProjectListUpdated())); // Initialize the filter slotProjectListUpdated(); } CMakeLocatorFilter::~CMakeLocatorFilter() { } QList CMakeLocatorFilter::matchesFor(QFutureInterface &future, const QString &entry) { Q_UNUSED(future) QList result; foreach (Project *p, SessionManager::projects()) { CMakeProject *cmakeProject = qobject_cast(p); if (cmakeProject) { foreach (const CMakeBuildTarget &ct, cmakeProject->buildTargets()) { if (ct.title.contains(entry)) { Locator::FilterEntry entry(this, ct.title, cmakeProject->projectFilePath()); entry.extraInfo = FileUtils::shortNativePath( FileName::fromString(cmakeProject->projectFilePath())); result.append(entry); } } } } return result; } void CMakeLocatorFilter::accept(Locator::FilterEntry selection) const { // Get the project containing the target selected CMakeProject *cmakeProject = 0; foreach (Project *p, SessionManager::projects()) { cmakeProject = qobject_cast(p); if (cmakeProject && cmakeProject->projectFilePath() == selection.internalData.toString()) break; cmakeProject = 0; } if (!cmakeProject) return; // Find the make step MakeStep *makeStep = 0; ProjectExplorer::BuildStepList *buildStepList = cmakeProject->activeTarget()->activeBuildConfiguration() ->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); for (int i = 0; i < buildStepList->count(); ++i) { makeStep = qobject_cast(buildStepList->at(i)); if (makeStep) break; } if (!makeStep) return; // Change the make step to build only the given target QStringList oldTargets = makeStep->buildTargets(); makeStep->setClean(false); makeStep->clearBuildTargets(); makeStep->setBuildTarget(selection.displayName, true); // Build ProjectExplorer::ProjectExplorerPlugin::instance()->buildProject(cmakeProject); makeStep->setBuildTargets(oldTargets); } void CMakeLocatorFilter::refresh(QFutureInterface &future) { Q_UNUSED(future) } void CMakeLocatorFilter::slotProjectListUpdated() { CMakeProject *cmakeProject = 0; foreach (Project *p, SessionManager::projects()) { cmakeProject = qobject_cast(p); if (cmakeProject) break; } // Enable the filter if there's at least one CMake project setEnabled(cmakeProject); } qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeprojectmanager.qbs0000644000015301777760000000307412323167666032011 0ustar pbusernogroup00000000000000import qbs.base 1.0 import QtcPlugin QtcPlugin { name: "CMakeProjectManager" Depends { name: "Qt.widgets" } Depends { name: "Core" } Depends { name: "CppTools" } Depends { name: "CPlusPlus" } Depends { name: "Locator" } Depends { name: "ProjectExplorer" } Depends { name: "TextEditor" } Depends { name: "QtSupport" } pluginRecommends: [ "Designer" ] files: [ "CMakeProjectManager.mimetypes.xml", "cmakebuildconfiguration.cpp", "cmakebuildconfiguration.h", "cmakebuildinfo.h", "cmakeeditor.cpp", "cmakeeditor.h", "cmakeeditorfactory.cpp", "cmakeeditorfactory.h", "cmakefilecompletionassist.cpp", "cmakefilecompletionassist.h", "cmakehighlighter.cpp", "cmakehighlighter.h", "cmakehighlighterfactory.cpp", "cmakehighlighterfactory.h", "cmakelocatorfilter.cpp", "cmakelocatorfilter.h", "cmakeopenprojectwizard.cpp", "cmakeopenprojectwizard.h", "cmakeparser.cpp", "cmakeparser.h", "cmakeproject.cpp", "cmakeproject.h", "cmakeproject.qrc", "cmakeprojectconstants.h", "cmakeprojectmanager.cpp", "cmakeprojectmanager.h", "cmakeprojectnodes.cpp", "cmakeprojectnodes.h", "cmakeprojectplugin.cpp", "cmakeprojectplugin.h", "cmakerunconfiguration.cpp", "cmakerunconfiguration.h", "cmakevalidator.cpp", "cmakevalidator.h", "makestep.cpp", "makestep.h", ] } qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeproject.cpp0000644000015301777760000012352412323167675030456 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmakeproject.h" #include "cmakebuildconfiguration.h" #include "cmakeprojectconstants.h" #include "cmakeprojectnodes.h" #include "cmakerunconfiguration.h" #include "cmakekitinformation.h" #include "cmakeappwizard.h" #include "makestep.h" #include "cmaketoolmanager.h" #include "argumentslineedit.h" #include "generatorinfo.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace CMakeProjectManager; using namespace CMakeProjectManager::Internal; using namespace ProjectExplorer; // QtCreator CMake Generator wishlist: // Which make targets we need to build to get all executables // What is the make we need to call // What is the actual compiler executable // DEFINES // Open Questions // Who sets up the environment for cl.exe ? INCLUDEPATH and so on /*! \class CMakeProject */ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName) : m_manager(manager), m_activeTarget(0), m_fileName(fileName), m_rootNode(new CMakeProjectNode(fileName)), m_watcher(new QFileSystemWatcher(this)) { setProjectContext(Core::Context(CMakeProjectManager::Constants::PROJECTCONTEXT)); setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX)); m_projectName = QFileInfo(fileName).absoluteDir().dirName(); m_file = new CMakeFile(this, fileName); connect(this, SIGNAL(buildTargetsChanged()), this, SLOT(updateConfigurations())); connect(m_watcher, SIGNAL(fileChanged(QString)), this, SLOT(fileChanged(QString))); } CMakeProject::~CMakeProject() { m_codeModelFuture.cancel(); delete m_rootNode; } void CMakeProject::fileChanged(const QString &fileName) { Q_UNUSED(fileName) parseCMakeLists(); } void CMakeProject::changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration *bc) { if (!bc) return; //@TODO handle no cmake case ICMakeTool* cmake = CMakeToolManager::cmakeToolForKit(bc->target()->kit()); cmake->runCMake(bc->target()); connect(cmake,SIGNAL(cmakeFinished(ProjectExplorer::Target*)),this,SLOT(parseCMakeLists(ProjectExplorer::Target*)),Qt::UniqueConnection); } void CMakeProject::activeTargetWasChanged(Target *target) { if (m_activeTarget) { disconnect(m_activeTarget, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)), this, SLOT(changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*))); } m_activeTarget = target; if (!m_activeTarget) return; connect(m_activeTarget, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)), this, SLOT(changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*))); changeActiveBuildConfiguration(m_activeTarget->activeBuildConfiguration()); } void CMakeProject::changeBuildDirectory(CMakeBuildConfiguration *bc, const QString &newBuildDirectory) { bc->setBuildDirectory(Utils::FileName::fromString(newBuildDirectory)); parseCMakeLists(); } QString CMakeProject::shadowBuildDirectory(const QString &projectFilePath, const Kit *k, const QString &bcName) { if (projectFilePath.isEmpty()) return QString(); QFileInfo info(projectFilePath); const QString projectName = QFileInfo(info.absolutePath()).fileName(); ProjectExplorer::ProjectMacroExpander expander(projectFilePath, projectName, k, bcName); QDir projectDir = QDir(projectDirectory(projectFilePath)); if(hasInSourceBuild(projectDir.absolutePath())) return projectDir.absolutePath(); QString buildPath = Utils::expandMacros(Core::DocumentManager::buildDirectory(), &expander); return QDir::cleanPath(projectDir.absoluteFilePath(buildPath)); } bool CMakeProject::parseCMakeLists(Target *t) { qDebug()<<"Running parseCMakeLists"; if (!activeTarget() || !activeTarget()->activeBuildConfiguration()) { return false; } //parse only if active target if(t && t != activeTarget()) return false; CMakeBuildConfiguration *activeBC = static_cast(activeTarget()->activeBuildConfiguration()); foreach (Core::IDocument *document, Core::EditorManager::documentModel()->openedDocuments()) if (isProjectFile(document->filePath())) document->infoBar()->removeInfo("CMakeEditor.RunCMake"); // Find cbp file QString cbpFile = CMakeManager::findCbpFile(activeBC->buildDirectory().toString()); if (cbpFile.isEmpty()) { emit buildTargetsChanged(); return false; } // setFolderName m_rootNode->setDisplayName(QFileInfo(cbpFile).completeBaseName()); CMakeCbpParser cbpparser; // Parsing //qDebug()<<"Parsing file "<files()) if (file != cbpFile) m_watcher->removePath(file); // how can we ensure that it is completely written? m_watcher->addPath(cbpFile); m_projectName = cbpparser.projectName(); m_rootNode->setDisplayName(cbpparser.projectName()); //qDebug()<<"Building Tree"; QList fileList = cbpparser.fileList(); QSet projectFiles; if (cbpparser.hasCMakeFiles()) { fileList.append(cbpparser.cmakeFileList()); foreach (const ProjectExplorer::FileNode *node, cbpparser.cmakeFileList()) projectFiles.insert(node->path()); } else { // Manually add the CMakeLists.txt file QString cmakeListTxt = projectDirectory() + QLatin1String("/CMakeLists.txt"); bool generated = false; fileList.append(new ProjectExplorer::FileNode(cmakeListTxt, ProjectExplorer::ProjectFileType, generated)); projectFiles.insert(cmakeListTxt); } m_watchedFiles = projectFiles; m_files.clear(); foreach (ProjectExplorer::FileNode *fn, fileList) m_files.append(fn->path()); m_files.sort(); buildTree(m_rootNode, fileList); //qDebug()<<"Adding Targets"; m_buildTargets = cbpparser.buildTargets(); // qDebug()<<"Printing targets"; // foreach (CMakeBuildTarget ct, m_buildTargets) { // qDebug()<kit(); ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k); if (!tc) { emit buildTargetsChanged(); emit fileListChanged(); return true; } QStringList cxxflags; bool found = false; foreach (const CMakeBuildTarget &buildTarget, m_buildTargets) { QString makeCommand = QDir::fromNativeSeparators(buildTarget.makeCommand); int startIndex = makeCommand.indexOf(QLatin1Char('\"')); int endIndex = makeCommand.indexOf(QLatin1Char('\"'), startIndex + 1); if (startIndex == -1 || endIndex == -1) continue; startIndex += 1; QString makefile = makeCommand.mid(startIndex, endIndex - startIndex); int slashIndex = makefile.lastIndexOf(QLatin1Char('/')); makefile.truncate(slashIndex); makefile.append(QLatin1String("/CMakeFiles/") + buildTarget.title + QLatin1String(".dir/flags.make")); QFile file(makefile); if (file.exists()) { file.open(QIODevice::ReadOnly | QIODevice::Text); QTextStream stream(&file); while (!stream.atEnd()) { QString line = stream.readLine().trimmed(); if (line.startsWith(QLatin1String("CXX_FLAGS ="))) { // Skip past = cxxflags = line.mid(11).trimmed().split(QLatin1Char(' '), QString::SkipEmptyParts); found = true; break; } } } if (found) break; } // Attempt to find build.ninja file and obtain FLAGS (CXX_FLAGS) from there if no suitable flags.make were // found if (!found && !cbpparser.buildTargets().isEmpty()) { // Get "all" target's working directory QString buildNinjaFile = QDir::fromNativeSeparators(cbpparser.buildTargets().at(0).workingDirectory); buildNinjaFile += QLatin1String("/build.ninja"); QFile buildNinja(buildNinjaFile); if (buildNinja.exists()) { buildNinja.open(QIODevice::ReadOnly | QIODevice::Text); QTextStream stream(&buildNinja); bool cxxFound = false; while (!stream.atEnd()) { QString line = stream.readLine().trimmed(); // Look for a build rule which invokes CXX_COMPILER if (line.startsWith(QLatin1String("build"))) { cxxFound = line.indexOf(QLatin1String("CXX_COMPILER")) != -1; } else if (cxxFound && line.startsWith(QLatin1String("FLAGS ="))) { // Skip past = cxxflags = line.mid(7).trimmed().split(QLatin1Char(' '), QString::SkipEmptyParts); break; } } } } CppTools::CppModelManagerInterface *modelmanager = CppTools::CppModelManagerInterface::instance(); if (modelmanager) { CppTools::CppModelManagerInterface::ProjectInfo pinfo = modelmanager->projectInfo(this); pinfo.clearProjectParts(); CppTools::ProjectPart::Ptr part(new CppTools::ProjectPart); part->project = this; part->displayName = displayName(); part->projectFile = projectFilePath(); part->evaluateToolchain(tc, cxxflags, cxxflags, SysRootKitInformation::sysRoot(k)); // This explicitly adds -I. to the include paths part->includePaths += projectDirectory(); part->includePaths += cbpparser.includeFiles(); part->defines += cbpparser.defines(); CppTools::ProjectFileAdder adder(part->files); foreach (const QString &file, m_files) adder.maybeAdd(file); pinfo.appendProjectPart(part); m_codeModelFuture.cancel(); m_codeModelFuture = modelmanager->updateProjectInfo(pinfo); setProjectLanguage(ProjectExplorer::Constants::LANG_CXX, !part->files.isEmpty()); } emit buildTargetsChanged(); emit fileListChanged(); return true; } KitMatcher *CMakeProject::createRequiredKitMatcher() const { return new CMakeKitMatcher(); } bool CMakeProject::supportsKit(Kit *k, QString *errorMessage) const { CMakeKitMatcher matcher; if(matcher.matches(k)) return true; if(errorMessage) *errorMessage = QLatin1String("Could not find compatible CMake Generators"); return false; } bool CMakeProject::supportsNoTargetPanel() const { return true; } bool CMakeProject::needsConfiguration() const { return targets().isEmpty(); } bool CMakeProject::isProjectFile(const QString &fileName) { return m_watchedFiles.contains(fileName); } bool CMakeProject::hasInSourceBuild() const { return hasInSourceBuild(projectDirectory()); } bool CMakeProject::hasInSourceBuild(const QString &sourcePath) { QFileInfo fi(sourcePath + QLatin1String("/CMakeCache.txt")); if (fi.exists()) return true; return false; } QList CMakeProject::buildTargets() const { return m_buildTargets; } QStringList CMakeProject::buildTargetTitles(bool runnable) const { QStringList results; foreach (const CMakeBuildTarget &ct, m_buildTargets) { if (runnable && (ct.executable.isEmpty() || ct.library)) continue; results << ct.title; } return results; } bool CMakeProject::hasBuildTarget(const QString &title) const { foreach (const CMakeBuildTarget &ct, m_buildTargets) { if (ct.title == title) return true; } return false; } void CMakeProject::gatherFileNodes(ProjectExplorer::FolderNode *parent, QList &list) { foreach (ProjectExplorer::FolderNode *folder, parent->subFolderNodes()) gatherFileNodes(folder, list); foreach (ProjectExplorer::FileNode *file, parent->fileNodes()) list.append(file); } bool sortNodesByPath(Node *a, Node *b) { return a->path() < b->path(); } void CMakeProject::buildTree(CMakeProjectNode *rootNode, QList newList) { // Gather old list QList oldList; gatherFileNodes(rootNode, oldList); qSort(oldList.begin(), oldList.end(), sortNodesByPath); qSort(newList.begin(), newList.end(), sortNodesByPath); // generate added and deleted list QList::const_iterator oldIt = oldList.constBegin(); QList::const_iterator oldEnd = oldList.constEnd(); QList::const_iterator newIt = newList.constBegin(); QList::const_iterator newEnd = newList.constEnd(); QList added; QList deleted; while (oldIt != oldEnd && newIt != newEnd) { if ( (*oldIt)->path() == (*newIt)->path()) { delete *newIt; ++oldIt; ++newIt; } else if ((*oldIt)->path() < (*newIt)->path()) { deleted.append(*oldIt); ++oldIt; } else { added.append(*newIt); ++newIt; } } while (oldIt != oldEnd) { deleted.append(*oldIt); ++oldIt; } while (newIt != newEnd) { added.append(*newIt); ++newIt; } // add added nodes foreach (ProjectExplorer::FileNode *fn, added) { // qDebug()<<"added"<path(); // Get relative path to rootNode QString parentDir = QFileInfo(fn->path()).absolutePath(); ProjectExplorer::FolderNode *folder = findOrCreateFolder(rootNode, parentDir); rootNode->addFileNodes(QList()<< fn, folder); } // remove old file nodes and check whether folder nodes can be removed foreach (ProjectExplorer::FileNode *fn, deleted) { ProjectExplorer::FolderNode *parent = fn->parentFolderNode(); // qDebug()<<"removed"<path(); rootNode->removeFileNodes(QList() << fn, parent); // Check for empty parent while (parent->subFolderNodes().isEmpty() && parent->fileNodes().isEmpty()) { ProjectExplorer::FolderNode *grandparent = parent->parentFolderNode(); rootNode->removeFolderNodes(QList() << parent, grandparent); parent = grandparent; if (parent == rootNode) break; } } } ProjectExplorer::FolderNode *CMakeProject::findOrCreateFolder(CMakeProjectNode *rootNode, QString directory) { QString relativePath = QDir(QFileInfo(rootNode->path()).path()).relativeFilePath(directory); QStringList parts = relativePath.split(QLatin1Char('/'), QString::SkipEmptyParts); ProjectExplorer::FolderNode *parent = rootNode; QString path = QFileInfo(rootNode->path()).path(); foreach (const QString &part, parts) { path += QLatin1Char('/'); path += part; // Find folder in subFolders bool found = false; foreach (ProjectExplorer::FolderNode *folder, parent->subFolderNodes()) { if (folder->path() == path) { // yeah found something :) parent = folder; found = true; break; } } if (!found) { // No FolderNode yet, so create it ProjectExplorer::FolderNode *tmp = new ProjectExplorer::FolderNode(path); tmp->setDisplayName(part); rootNode->addFolderNodes(QList() << tmp, parent); parent = tmp; } } return parent; } QString CMakeProject::displayName() const { return m_projectName; } Core::Id CMakeProject::id() const { return Core::Id(Constants::CMAKEPROJECT_ID); } Core::IDocument *CMakeProject::document() const { return m_file; } CMakeManager *CMakeProject::projectManager() const { return m_manager; } ProjectExplorer::ProjectNode *CMakeProject::rootProjectNode() const { return m_rootNode; } QStringList CMakeProject::files(FilesMode fileMode) const { Q_UNUSED(fileMode) return m_files; } bool CMakeProject::fromMap(const QVariantMap &map) { if (!Project::fromMap(map)) return false; //make sure there is always a cmake available if(!CMakeToolManager::defaultCMakeTool()->isValid()) { ChooseCMakeWizard wiz; if(wiz.exec() != QDialog::Accepted) return false; if(!CMakeToolManager::defaultCMakeTool()->isValid()) return false; } //if there is no user file, just leave a empty project //the configure project pane will pup up for the rescue bool hasUserFile = activeTarget(); if ( hasUserFile ) { // We have a user file, but we could still be missing the cbp file // or simply run createXml with the saved settings CMakeBuildConfiguration *activeBC = qobject_cast(activeTarget()->activeBuildConfiguration()); if (!activeBC) return true; //give the user a chance to setup a cmake target //@TODO handle no cmake case ICMakeTool* cmake = CMakeToolManager::cmakeToolForKit(activeBC->target()->kit()); cmake->runCMake(activeBC->target()); connect(cmake,SIGNAL(cmakeFinished(ProjectExplorer::Target*)),this,SLOT(parseCMakeLists(ProjectExplorer::Target*)),Qt::UniqueConnection); } m_activeTarget = activeTarget(); if (m_activeTarget) connect(m_activeTarget, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)), this, SLOT(changeActiveBuildConfiguration(ProjectExplorer::BuildConfiguration*))); connect(this, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), this, SLOT(activeTargetWasChanged(ProjectExplorer::Target*))); return true; } bool CMakeProject::setupTarget(Target *t) { t->updateDefaultBuildConfigurations(); t->updateDefaultDeployConfigurations(); return true; } CMakeBuildTarget CMakeProject::buildTargetForTitle(const QString &title) { foreach (const CMakeBuildTarget &ct, m_buildTargets) if (ct.title == title) return ct; return CMakeBuildTarget(); } QString CMakeProject::uiHeaderFile(const QString &uiFile) { QFileInfo fi(uiFile); Utils::FileName project = Utils::FileName::fromString(projectDirectory()); Utils::FileName baseDirectory = Utils::FileName::fromString(fi.absolutePath()); while (baseDirectory.isChildOf(project)) { Utils::FileName cmakeListsTxt = baseDirectory; cmakeListsTxt.appendPath(QLatin1String("CMakeLists.txt")); if (cmakeListsTxt.toFileInfo().exists()) break; QDir dir(baseDirectory.toString()); dir.cdUp(); baseDirectory = Utils::FileName::fromString(dir.absolutePath()); } QDir srcDirRoot = QDir(project.toString()); QString relativePath = srcDirRoot.relativeFilePath(baseDirectory.toString()); QDir buildDir = QDir(activeTarget()->activeBuildConfiguration()->buildDirectory().toString()); QString uiHeaderFilePath = buildDir.absoluteFilePath(relativePath); uiHeaderFilePath += QLatin1String("/ui_"); uiHeaderFilePath += fi.completeBaseName(); uiHeaderFilePath += QLatin1String(".h"); return QDir::cleanPath(uiHeaderFilePath); } void CMakeProject::updateConfigurations() { foreach (Target *t, targets()) updateConfigurations(t); } void CMakeProject::updateConfigurations(Target *t) { //t->updateDefaultDeployConfigurations(); t->updateDefaultRunConfigurations(); if (t->runConfigurations().isEmpty()) { // Oh no, no run configuration, // create a custom executable run configuration t->addRunConfiguration(new QtSupport::CustomExecutableRunConfiguration(t)); } #if 0 // *Update* runconfigurations: QMultiMap existingRunConfigurations; QList toRemove; foreach (ProjectExplorer::RunConfiguration *rc, t->runConfigurations()) { if (CMakeRunConfiguration* cmakeRC = qobject_cast(rc)) existingRunConfigurations.insert(cmakeRC->title(), cmakeRC); QtSupport::CustomExecutableRunConfiguration *ceRC = qobject_cast(rc); if (ceRC && !ceRC->isConfigured()) toRemove << rc; } foreach (const CMakeBuildTarget &ct, buildTargets()) { if (ct.library) continue; if (ct.executable.isEmpty()) continue; QList list = existingRunConfigurations.values(ct.title); if (!list.isEmpty()) { // Already exists, so override the settings... foreach (CMakeRunConfiguration *rc, list) { rc->setExecutable(ct.executable); rc->setBaseWorkingDirectory(ct.workingDirectory); rc->setEnabled(true); } existingRunConfigurations.remove(ct.title); } else { // Does not exist yet Core::Id id = CMakeRunConfigurationFactory::idFromBuildTarget(ct.title); CMakeRunConfiguration *rc = new CMakeRunConfiguration(t, id, ct.executable, ct.workingDirectory, ct.title); t->addRunConfiguration(rc); } } QMultiMap::const_iterator it = existingRunConfigurations.constBegin(); for ( ; it != existingRunConfigurations.constEnd(); ++it) { CMakeRunConfiguration *rc = it.value(); // The executables for those runconfigurations aren't build by the current buildconfiguration // We just set a disable flag and show that in the display name rc->setEnabled(false); // removeRunConfiguration(rc); } foreach (ProjectExplorer::RunConfiguration *rc, toRemove) t->removeRunConfiguration(rc); if (t->runConfigurations().isEmpty()) { // Oh no, no run configuration, // create a custom executable run configuration t->addRunConfiguration(new QtSupport::CustomExecutableRunConfiguration(t)); } #endif } void CMakeProject::updateApplicationAndDeploymentTargets() { Target *t = activeTarget(); QFile deploymentFile; QTextStream deploymentStream; QString deploymentPrefix; QDir sourceDir; sourceDir.setPath(t->project()->projectDirectory()); deploymentFile.setFileName(sourceDir.filePath(QLatin1String("QtCreatorDeployment.txt"))); if (deploymentFile.open(QFile::ReadOnly | QFile::Text)) { deploymentStream.setDevice(&deploymentFile); deploymentPrefix = deploymentStream.readLine(); if (!deploymentPrefix.endsWith(QLatin1Char('/'))) deploymentPrefix.append(QLatin1Char('/')); } BuildTargetInfoList appTargetList; DeploymentData deploymentData; QDir buildDir(t->activeBuildConfiguration()->buildDirectory().toString()); foreach (const CMakeBuildTarget &ct, m_buildTargets) { if (ct.executable.isEmpty()) continue; deploymentData.addFile(ct.executable, deploymentPrefix + buildDir.relativeFilePath(QFileInfo(ct.executable).dir().path()), DeployableFile::TypeExecutable); if (!ct.library) { // TODO: Put a path to corresponding .cbp file into projectFilePath? appTargetList.list << BuildTargetInfo(ct.executable, ct.executable); } } QString absoluteSourcePath = sourceDir.absolutePath(); if (!absoluteSourcePath.endsWith(QLatin1Char('/'))) absoluteSourcePath.append(QLatin1Char('/')); while (!deploymentStream.atEnd()) { QStringList file = deploymentStream.readLine().split(QLatin1Char(':')); deploymentData.addFile(absoluteSourcePath + file.at(0), deploymentPrefix + file.at(1)); } t->setApplicationTargets(appTargetList); t->setDeploymentData(deploymentData); } void CMakeProject::createUiCodeModelSupport() { QHash uiFileHash; // Find all ui files foreach (const QString &uiFile, m_files) { if (uiFile.endsWith(QLatin1String(".ui"))) uiFileHash.insert(uiFile, uiHeaderFile(uiFile)); } QtSupport::UiCodeModelManager::update(this, uiFileHash); } // CMakeFile CMakeFile::CMakeFile(CMakeProject *parent, QString fileName) : Core::IDocument(parent), m_project(parent) { setFilePath(fileName); } bool CMakeFile::save(QString *errorString, const QString &fileName, bool autoSave) { // Once we have an texteditor open for this file, we probably do // need to implement this, don't we. Q_UNUSED(errorString) Q_UNUSED(fileName) Q_UNUSED(autoSave) return false; } QString CMakeFile::defaultPath() const { return QString(); } QString CMakeFile::suggestedFileName() const { return QString(); } QString CMakeFile::mimeType() const { return QLatin1String(Constants::CMAKEMIMETYPE); } bool CMakeFile::isModified() const { return false; } bool CMakeFile::isSaveAsAllowed() const { return false; } Core::IDocument::ReloadBehavior CMakeFile::reloadBehavior(ChangeTrigger state, ChangeType type) const { Q_UNUSED(state) Q_UNUSED(type) return BehaviorSilent; } bool CMakeFile::reload(QString *errorString, ReloadFlag flag, ChangeType type) { Q_UNUSED(errorString) Q_UNUSED(flag) Q_UNUSED(type) return true; } CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc) : m_buildConfiguration(bc) { QFormLayout *fl = new QFormLayout(this); fl->setContentsMargins(20, -1, 0, -1); fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); setLayout(fl); bool inSource = CMakeProject::hasInSourceBuild(bc->target()->project()->projectDirectory()); if(inSource) { QLabel* inSourceLabel = new QLabel(this); inSourceLabel->setWordWrap(true); inSourceLabel->setText(tr("Qt Creator has detected an in-source-build in %1 " "which prevents shadow builds. Qt Creator will not allow you to change the build directory. " "If you want a shadow build, clean your source directory and re-open the project.") .arg(bc->target()->project()->projectDirectory())); fl->addRow(inSourceLabel); } if(!inSource) { m_pathChooser = new Utils::PathChooser(this); m_pathChooser->setPath(m_buildConfiguration->rawBuildDirectory().toString()); fl->addRow(tr("Build directory:"), m_pathChooser); connect(m_pathChooser->lineEdit(),SIGNAL(editingFinished()),this,SLOT(onBuilddirChanged())); } m_userArguments = new ArgumentsLineEdit(this); fl->addRow(tr("CMake arguments:"),m_userArguments); m_userArguments->setText(Utils::QtcProcess::joinArgs(m_buildConfiguration->arguments())); //m_userArguments->setHistoryCompleter(QLatin1String("CMakeArgumentsLineEdit")); connect(m_userArguments,SIGNAL(editingFinished()),this,SLOT(onArgumentsChanged())); m_generatorBox = new QComboBox(this); ICMakeTool* cmake = CMakeToolManager::cmakeToolForKit(bc->target()->kit()); QList infos = GeneratorInfo::generatorInfosFor(bc->target()->kit(), cmake->hasCodeBlocksNinjaGenerator() ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja, CMakeManager::preferNinja(), cmake->hasCodeBlocksMsvcGenerator()); int idx = -1; QByteArray cachedGenerator = bc->generator(); for(int i = 0; i < infos.size(); i++) { const GeneratorInfo &info = infos.at(i); m_generatorBox->addItem(info.displayName(), qVariantFromValue(info)); if(info.generator() == cachedGenerator) idx = i; } if(idx >= 0) m_generatorBox->setCurrentIndex(idx); connect(m_generatorBox,SIGNAL(currentIndexChanged(int)),this,SLOT(onGeneratorSelected())); fl->addRow(tr("Generator:"),m_generatorBox); setDisplayName(tr("CMake")); } void CMakeBuildSettingsWidget::openChangeBuildDirectoryDialog() { #if 0 CMakeProject *project = static_cast(m_buildConfiguration->target()->project()); CMakeBuildInfo info(m_buildConfiguration); CMakeOpenProjectWizard copw(project->projectManager(), CMakeOpenProjectWizard::ChangeDirectory, &info); if (copw.exec() == QDialog::Accepted) { project->changeBuildDirectory(m_buildConfiguration, copw.buildDirectory()); m_buildConfiguration->setUseNinja(copw.useNinja()); m_pathLineEdit->setText(m_buildConfiguration->rawBuildDirectory().toString()); } #endif } void CMakeBuildSettingsWidget::onArgumentsChanged() { if(!m_userArguments->isValid()) return; QStringList args = Utils::QtcProcess::splitArgs(m_userArguments->text()); if(m_buildConfiguration->arguments() != args) m_buildConfiguration->setArguments(args); } void CMakeBuildSettingsWidget::onBuilddirChanged() { qDebug()<<"Changing builddir to: "<fileName().toString(); m_buildConfiguration->setBuildDirectory(m_pathChooser->fileName()); } void CMakeBuildSettingsWidget::onGeneratorSelected() { int curr = m_generatorBox->currentIndex(); GeneratorInfo info = m_generatorBox->itemData(curr).value(); m_buildConfiguration->setUseNinja(info.isNinja()); } ///// // CMakeCbpParser //// bool CMakeCbpParser::parseCbpFile(const QString &fileName) { QFile fi(fileName); if (fi.exists() && fi.open(QFile::ReadOnly)) { setDevice(&fi); while (!atEnd()) { readNext(); if (name() == QLatin1String("CodeBlocks_project_file")) parseCodeBlocks_project_file(); else if (isStartElement()) parseUnknownElement(); } fi.close(); m_includeFiles.sort(); m_includeFiles.removeDuplicates(); return true; } return false; } void CMakeCbpParser::parseCodeBlocks_project_file() { while (!atEnd()) { readNext(); if (isEndElement()) return; else if (name() == QLatin1String("Project")) parseProject(); else if (isStartElement()) parseUnknownElement(); } } void CMakeCbpParser::parseProject() { while (!atEnd()) { readNext(); if (isEndElement()) return; else if (name() == QLatin1String("Option")) parseOption(); else if (name() == QLatin1String("Unit")) parseUnit(); else if (name() == QLatin1String("Build")) parseBuild(); else if (isStartElement()) parseUnknownElement(); } } void CMakeCbpParser::parseBuild() { while (!atEnd()) { readNext(); if (isEndElement()) return; else if (name() == QLatin1String("Target")) parseBuildTarget(); else if (isStartElement()) parseUnknownElement(); } } void CMakeCbpParser::parseBuildTarget() { m_buildTarget.clear(); if (attributes().hasAttribute(QLatin1String("title"))) m_buildTarget.title = attributes().value(QLatin1String("title")).toString(); while (!atEnd()) { readNext(); if (isEndElement()) { if (!m_buildTarget.title.endsWith(QLatin1String("/fast"))) m_buildTargets.append(m_buildTarget); return; } else if (name() == QLatin1String("Compiler")) { parseCompiler(); } else if (name() == QLatin1String("Option")) { parseBuildTargetOption(); } else if (name() == QLatin1String("MakeCommands")) { parseMakeCommands(); } else if (isStartElement()) { parseUnknownElement(); } } } void CMakeCbpParser::parseBuildTargetOption() { if (attributes().hasAttribute(QLatin1String("output"))) { m_buildTarget.executable = attributes().value(QLatin1String("output")).toString(); } else if (attributes().hasAttribute(QLatin1String("type"))) { const QStringRef value = attributes().value(QLatin1String("type")); if (value == QLatin1String("2") || value == QLatin1String("3")) m_buildTarget.library = true; } else if (attributes().hasAttribute(QLatin1String("working_dir"))) { m_buildTarget.workingDirectory = attributes().value(QLatin1String("working_dir")).toString(); } while (!atEnd()) { readNext(); if (isEndElement()) return; else if (isStartElement()) parseUnknownElement(); } } QString CMakeCbpParser::projectName() const { return m_projectName; } void CMakeCbpParser::parseOption() { if (attributes().hasAttribute(QLatin1String("title"))) m_projectName = attributes().value(QLatin1String("title")).toString(); if (attributes().hasAttribute(QLatin1String("compiler"))) m_compiler = attributes().value(QLatin1String("compiler")).toString(); while (!atEnd()) { readNext(); if (isEndElement()) return; else if (isStartElement()) parseUnknownElement(); } } void CMakeCbpParser::parseMakeCommands() { while (!atEnd()) { readNext(); if (isEndElement()) return; else if (name() == QLatin1String("Build")) parseBuildTargetBuild(); else if (name() == QLatin1String("Clean")) parseBuildTargetClean(); else if (isStartElement()) parseUnknownElement(); } } void CMakeCbpParser::parseBuildTargetBuild() { if (attributes().hasAttribute(QLatin1String("command"))) m_buildTarget.makeCommand = attributes().value(QLatin1String("command")).toString(); while (!atEnd()) { readNext(); if (isEndElement()) return; else if (isStartElement()) parseUnknownElement(); } } void CMakeCbpParser::parseBuildTargetClean() { if (attributes().hasAttribute(QLatin1String("command"))) m_buildTarget.makeCleanCommand = attributes().value(QLatin1String("command")).toString(); while (!atEnd()) { readNext(); if (isEndElement()) return; else if (isStartElement()) parseUnknownElement(); } } void CMakeCbpParser::parseCompiler() { while (!atEnd()) { readNext(); if (isEndElement()) return; else if (name() == QLatin1String("Add")) parseAdd(); else if (isStartElement()) parseUnknownElement(); } } void CMakeCbpParser::parseAdd() { // CMake only supports and const QXmlStreamAttributes addAttributes = attributes(); const QString includeDirectory = addAttributes.value(QLatin1String("directory")).toString(); // allow adding multiple times because order happens if (!includeDirectory.isEmpty()) m_includeFiles.append(includeDirectory); QString compilerOption = addAttributes.value(QLatin1String("option")).toString(); // defining multiple times a macro to the same value makes no sense if (!compilerOption.isEmpty() && !m_compilerOptions.contains(compilerOption)) { m_compilerOptions.append(compilerOption); int macroNameIndex = compilerOption.indexOf(QLatin1String("-D")) + 2; if (macroNameIndex != 1) { int assignIndex = compilerOption.indexOf(QLatin1Char('='), macroNameIndex); if (assignIndex != -1) compilerOption[assignIndex] = ' '; m_defines.append("#define "); m_defines.append(compilerOption.mid(macroNameIndex).toUtf8()); m_defines.append('\n'); } } while (!atEnd()) { readNext(); if (isEndElement()) return; else if (isStartElement()) parseUnknownElement(); } } void CMakeCbpParser::parseUnit() { //qDebug()< CMakeCbpParser::fileList() { return m_fileList; } QList CMakeCbpParser::cmakeFileList() { return m_cmakeFileList; } bool CMakeCbpParser::hasCMakeFiles() { return !m_cmakeFileList.isEmpty(); } QStringList CMakeCbpParser::includeFiles() { return m_includeFiles; } QByteArray CMakeCbpParser::defines() const { return m_defines; } QList CMakeCbpParser::buildTargets() { return m_buildTargets; } QString CMakeCbpParser::compilerName() const { return m_compiler; } void CMakeBuildTarget::clear() { executable.clear(); makeCommand.clear(); makeCleanCommand.clear(); workingDirectory.clear(); title.clear(); library = false; } qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakehighlighter.cpp0000644000015301777760000001173712323167666031310 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmakehighlighter.h" #include #include using namespace CMakeProjectManager::Internal; static bool isVariable(const QByteArray &word) { if (word.length() < 4) // must be at least "${.}" return false; return word.startsWith("${") && word.endsWith('}'); } CMakeHighlighter::CMakeHighlighter(QTextDocument *document) : TextEditor::SyntaxHighlighter(document) { static QVector categories; if (categories.isEmpty()) { categories << TextEditor::C_LABEL // variables << TextEditor::C_KEYWORD // functions << TextEditor::C_COMMENT << TextEditor::C_STRING << TextEditor::C_VISUAL_WHITESPACE; } setTextFormatCategories(categories); } void CMakeHighlighter::highlightBlock(const QString &text) { QByteArray buf; bool inCommentMode = false; bool inStringMode = (previousBlockState() == 1); QTextCharFormat emptyFormat; int i=0; for (i=0; i < text.length(); i++) { char c = text.at(i).toLatin1(); if (inCommentMode) { setFormat(i, 1, formatForCategory(CMakeCommentFormat)); } else { if (c == '#') { if (!inStringMode) { inCommentMode = true; setFormat(i, 1, formatForCategory(CMakeCommentFormat)); buf.clear(); } else { buf += c; } } else if (c == '(') { if (!inStringMode) { if (!buf.isEmpty()) setFormat(i - buf.length(), buf.length(), formatForCategory(CMakeFunctionFormat)); buf.clear(); } else { buf += c; } } else if (text.at(i).isSpace()) { if (!inStringMode) buf.clear(); else buf += c; } else if (c == '\"') { buf += c; if (inStringMode) { setFormat(i + 1 - buf.length(), buf.length(), formatForCategory(CMakeStringFormat)); buf.clear(); } else { setFormat(i, 1, formatForCategory(CMakeStringFormat)); } inStringMode = !inStringMode; } else if (c == '\\') { setFormat(i, 1, emptyFormat); buf += c; i++; if (i < text.length()) { text.at(i); setFormat(i, 1, emptyFormat); buf += c; } } else if (c == '$') { if (inStringMode) setFormat(i - buf.length(), buf.length(), formatForCategory(CMakeStringFormat)); buf.clear(); buf += c; setFormat(i, 1, emptyFormat); } else if (c == '}') { buf += c; if (isVariable(buf)) { setFormat(i + 1 - buf.length(), buf.length(), formatForCategory(CMakeVariableFormat)); buf.clear(); } } else { buf += c; setFormat(i, 1, emptyFormat); } } } if (inStringMode) { setFormat(i - buf.length(), buf.length(), formatForCategory(CMakeStringFormat)); setCurrentBlockState(1); } else { setCurrentBlockState(0); } applyFormatToSpaces(text, formatForCategory(CMakeVisualWhiteSpaceFormat)); } qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeappwizard.h0000644000015301777760000000666512323167666030464 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Canonical Ltd. ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEPROJECTMANAGER_CMAKEAPPWIZARD_H #define CMAKEPROJECTMANAGER_CMAKEAPPWIZARD_H #include "cmakeprojectmanager_global.h" #include #include #include QT_BEGIN_NAMESPACE class QLabel; QT_END_NAMESPACE namespace Utils { class PathChooser; } namespace CMakeProjectManager { class ChooseCMakePage; class CMAKEPROJECTMANAGER_EXPORT CMakeAppWizard : public ProjectExplorer::CustomProjectWizard { Q_OBJECT public: CMakeAppWizard(); static void registerSelf(); private: QWizard *createWizardDialog(QWidget *parent, const Core::WizardDialogParameters &wizardDialogParameters) const; bool postGenerateFiles(const QWizard *, const Core::GeneratedFiles &l, QString *errorMessage); private: enum { targetPageId = 1 }; }; class CMAKEPROJECTMANAGER_EXPORT CMakeAppWizardDialog : public ProjectExplorer::BaseProjectWizardDialog { Q_OBJECT public: explicit CMakeAppWizardDialog(QWidget *parent, const Core::WizardDialogParameters ¶meters); virtual ~CMakeAppWizardDialog(); int addTargetSetupPage(int id = -1); int addChooseCMakePage(int id = -1); QList selectedKits() const; bool writeUserFile(const QString &cmakeFileName) const; private slots: void generateProfileName(const QString &name, const QString &path); private: ProjectExplorer::TargetSetupPage *m_targetSetupPage; ChooseCMakePage* m_cmakePage; void init(); }; class CMAKEPROJECTMANAGER_EXPORT ChooseCMakePage : public QWizardPage { Q_OBJECT public: ChooseCMakePage(QWidget *parent = 0); virtual bool isComplete() const; public slots: void cmakeExecutableChanged(); private: void updateErrorText(); QLabel *m_cmakeLabel; Utils::PathChooser *m_cmakeExecutable; }; class ChooseCMakeWizard : public Utils::Wizard { Q_OBJECT public: ChooseCMakeWizard(); }; } // namespace CMakeProjectManager #endif // CMAKEPROJECTMANAGER_CMAKEAPPWIZARD_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakerunconfiguration.h0000644000015301777760000001231712323167666032046 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKERUNCONFIGURATION_H #define CMAKERUNCONFIGURATION_H #include #include QT_BEGIN_NAMESPACE class QComboBox; QT_END_NAMESPACE namespace Utils { class PathChooser; class DetailsWidget; } namespace CMakeProjectManager { namespace Internal { class CMakeTarget; class CMakeRunConfiguration : public ProjectExplorer::LocalApplicationRunConfiguration { Q_OBJECT friend class CMakeRunConfigurationWidget; friend class CMakeRunConfigurationFactory; public: CMakeRunConfiguration(ProjectExplorer::Target *parent, Core::Id id, const QString &target, const QString &workingDirectory, const QString &title); ~CMakeRunConfiguration(); QString executable() const; RunMode runMode() const; void setRunMode(RunMode runMode); QString workingDirectory() const; QString commandLineArguments() const; QWidget *createConfigurationWidget(); void setExecutable(const QString &executable); void setBaseWorkingDirectory(const QString &workingDirectory); QString title() const; QString dumperLibrary() const; QStringList dumperLibraryLocations() const; QVariantMap toMap() const; void setEnabled(bool b); bool isEnabled() const; QString disabledReason() const; signals: void baseWorkingDirectoryChanged(const QString&); private slots: void setCommandLineArguments(const QString &newText); protected: CMakeRunConfiguration(ProjectExplorer::Target *parent, CMakeRunConfiguration *source); virtual bool fromMap(const QVariantMap &map); QString defaultDisplayName() const; private: void setUserWorkingDirectory(const QString &workingDirectory); QString baseWorkingDirectory() const; void ctor(); RunMode m_runMode; QString m_buildTarget; QString m_workingDirectory; QString m_userWorkingDirectory; QString m_title; QString m_arguments; bool m_enabled; }; class CMakeRunConfigurationWidget : public QWidget { Q_OBJECT public: explicit CMakeRunConfigurationWidget(CMakeRunConfiguration *cmakeRunConfiguration, QWidget *parent = 0); private slots: void setArguments(const QString &args); void setWorkingDirectory(); void resetWorkingDirectory(); void runInTerminalToggled(bool toggled); void environmentWasChanged(); void workingDirectoryChanged(const QString &workingDirectory); private: void ctor(); bool m_ignoreChange; CMakeRunConfiguration *m_cmakeRunConfiguration; Utils::PathChooser *m_workingDirectoryEdit; Utils::DetailsWidget *m_detailsContainer; }; class CMakeRunConfigurationFactory : public ProjectExplorer::IRunConfigurationFactory { Q_OBJECT public: explicit CMakeRunConfigurationFactory(QObject *parent = 0); ~CMakeRunConfigurationFactory(); bool canCreate(ProjectExplorer::Target *parent, const Core::Id id) const; bool canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const; bool canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *product) const; ProjectExplorer::RunConfiguration *clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *product); QList availableCreationIds(ProjectExplorer::Target *parent) const; QString displayNameForId(const Core::Id id) const; static Core::Id idFromBuildTarget(const QString &target); static QString buildTargetFromId(Core::Id id); private: bool canHandle(ProjectExplorer::Target *parent) const; ProjectExplorer::RunConfiguration *doCreate(ProjectExplorer::Target *parent, const Core::Id id); ProjectExplorer::RunConfiguration *doRestore(ProjectExplorer::Target *parent, const QVariantMap &map); }; } } #endif // CMAKERUNCONFIGURATION_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmaketoolmanager.h0000644000015301777760000000454312323167666030764 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Canonical Ltd. ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEPROJECTMANAGER_CMAKETOOLMANAGER_H #define CMAKEPROJECTMANAGER_CMAKETOOLMANAGER_H #include "cmakeprojectmanager_global.h" #include "cmaketool.h" #include namespace CMakeProjectManager { class CMAKEPROJECTMANAGER_EXPORT CMakeToolManager : public QObject { Q_OBJECT public: CMakeToolManager (); ~CMakeToolManager (); static void setUserCmakePath (const QString &path); static QString userCMakePath(); static CMakeTool *defaultCMakeTool (); static bool registerCMakeTool (ICMakeTool* tool); static ICMakeTool *cmakeTool (const Core::Id& id); static ICMakeTool *cmakeToolForKit (const ProjectExplorer::Kit *kit); static QString findCmakeExecutable(); private: static CMakeToolManager *m_instance; CMakeTool m_cmakeToolForUser; CMakeTool m_cmakeToolForSystem; QMap m_cmakeTools; }; } // namespace CMakeProjectManager #endif // CMAKEPROJECTMANAGER_CMAKETOOLMANAGER_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmaketool.cpp0000644000015301777760000004035312323167675027763 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Canonical Ltd. ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmaketool.h" #include "cmakeprojectmanager.h" #include "cmakeprojectconstants.h" #include "cmakebuildconfiguration.h" #include "generatorinfo.h" #include #include #include #include #include #include #include #include #include #include using namespace CMakeProjectManager; using namespace Internal; /*! * \class ICMakeTool * Generic interface for starting cmake to create the buildfiles * Can be linked to a specific Kit */ ICMakeTool::ICMakeTool(QObject *parent) : QObject(parent) { } ICMakeTool::~ICMakeTool() { } void ICMakeTool::addToEnvironment(Utils::Environment &env) const { } CMakeTool::CMakeTool(QObject *parent) : ICMakeTool(parent) , m_state(CMakeTool::RunningBasic) , m_process(0) , m_hasCodeBlocksMsvcGenerator(false) , m_hasCodeBlocksNinjaGenerator(false) , m_futureInterface(0) { setId(Constants::CMAKE_TOOL_ID); } CMakeTool::~CMakeTool() { cancel(); } void CMakeTool::cancel() { if (m_process) { if(m_futureInterface){ m_futureInterface->reportCanceled(); m_futureInterface->reportFinished(); } m_process->disconnect(this); m_process->terminate(); if(!m_process->waitForFinished(100)) { m_process->kill(); m_process->waitForFinished(); } m_process->deleteLater(); m_process = 0; if (m_state != CMakeTool::RunningDone) m_state = CMakeTool::Invalid; } m_pendingRuns.clear(); } void CMakeTool::setCMakeExecutable(const QString &executable) { cancel(); createProcessIfNotExists(); m_executable = executable; QFileInfo fi(m_executable); if (fi.exists() && fi.isExecutable()) { // Run it to find out more m_state = CMakeTool::RunningBasic; if (!startProcess(QStringList(QLatin1String("--help")))) m_state = CMakeTool::Invalid; } else { m_state = CMakeTool::Invalid; } } void CMakeTool::finished(int exitCode) { if (exitCode && m_state != CMakeTool::RunningProject) { flushOutput(); m_state = CMakeTool::Invalid; return; } if (m_state == CMakeTool::RunningBasic) { QByteArray response = m_process->readAll(); m_hasCodeBlocksMsvcGenerator = response.contains("CodeBlocks - NMake Makefiles"); m_hasCodeBlocksNinjaGenerator = response.contains("CodeBlocks - Ninja"); if (response.isEmpty()) { m_state = CMakeTool::Invalid; } else { m_state = CMakeTool::RunningFunctionList; if (!startProcess(QStringList(QLatin1String("--help-command-list")))) finished(0); // should never happen, just continue } } else if (m_state == CMakeTool::RunningFunctionList) { parseFunctionOutput(m_process->readAll()); m_state = CMakeTool::RunningFunctionDetails; if (!startProcess(QStringList(QLatin1String("--help-commands")))) finished(0); // should never happen, just continue } else if (m_state == CMakeTool::RunningFunctionDetails) { parseFunctionDetailsOutput(m_process->readAll()); m_state = CMakeTool::RunningPropertyList; if (!startProcess(QStringList(QLatin1String("--help-property-list")))) finished(0); // should never happen, just continue } else if (m_state == CMakeTool::RunningPropertyList) { parseVariableOutput(m_process->readAll()); m_state = CMakeTool::RunningVariableList; if (!startProcess(QStringList(QLatin1String("--help-variable-list")))) finished(0); // should never happen, just continue } else if (m_state == CMakeTool::RunningVariableList) { parseVariableOutput(m_process->readAll()); parseDone(); m_state = CMakeTool::RunningDone; }else if (m_state == CMakeTool::RunningProject) { //cmake run is finished no matter if we were successful or not m_currentRun.clear(); m_state = CMakeTool::RunningDone; if(m_futureInterface) { if(exitCode) m_futureInterface->reportCanceled(); m_futureInterface->reportFinished(); } flushOutput(); emit cmakeFinished(m_currentRun.data()); } if(m_state == CMakeTool::RunningDone ) startNextRun(); } void CMakeTool::onProcessReadyRead() { //we only care about cmake project building output if(m_state != CMakeTool::RunningProject) return; QString stderr = QString::fromLocal8Bit(m_process->readAllStandardError()).trimmed(); QString stdout = QString::fromLocal8Bit(m_process->readAllStandardOutput()).trimmed(); if (!stderr.isEmpty()) { Core::MessageManager::write(QString(QLatin1String("%0")).arg(stderr),Core::MessageManager::ModeSwitch); } if (!stdout.isEmpty()) { Core::MessageManager::write(QString(QLatin1String("%0")).arg(stdout),Core::MessageManager::NoModeSwitch); } } void CMakeTool::flushOutput() { QString errorMsg = QString::fromLocal8Bit(m_process->readAllStandardError()); if (errorMsg.trimmed().length()>0) Core::MessageManager::write(errorMsg,Core::MessageManager::ModeSwitch); QString msg = QString::fromLocal8Bit(m_process->readAllStandardOutput()); if (msg.trimmed().length()>0) Core::MessageManager::write(msg,Core::MessageManager::NoModeSwitch); } void CMakeTool::createProcessIfNotExists() { if(!m_process) { m_process = new Utils::QtcProcess(); connect(m_process, SIGNAL(finished(int)), this, SLOT(finished(int))); connect(m_process,SIGNAL(readyRead()), this,SLOT(onProcessReadyRead())); } } bool CMakeTool::isValid() const { if (m_state == CMakeTool::Invalid) return false; if (m_state == CMakeTool::RunningBasic) m_process->waitForFinished(); return (m_state != CMakeTool::Invalid); } bool CMakeTool::startProcess(const QStringList &args, Utils::Environment env) { QString argsStr = Utils::QtcProcess::joinArgs(args); //add custom cmake environment vars addToEnvironment(env); qDebug()<<"Starting process: " <setEnvironment(env); m_process->setCommand(m_executable, argsStr); m_process->start(); return m_process->waitForStarted(2000); } QString CMakeTool::cmakeExecutable() const { return m_executable; } bool CMakeTool::hasCodeBlocksMsvcGenerator() const { if (!isValid()) return false; return m_hasCodeBlocksMsvcGenerator; } bool CMakeTool::hasCodeBlocksNinjaGenerator() const { if (!isValid()) return false; return m_hasCodeBlocksNinjaGenerator; } TextEditor::Keywords CMakeTool::keywords() { while (m_state != RunningDone && m_state != CMakeTool::Invalid) { m_process->waitForFinished(); } if (m_state == CMakeTool::Invalid) return TextEditor::Keywords(QStringList(), QStringList(), QMap()); return TextEditor::Keywords(m_variables, m_functions, m_functionArgs); } void CMakeTool::runCMake( ProjectExplorer::Target* target ) { if(!isValid()) return; QPointer ptrTarget(target); if(!m_pendingRuns.contains(ptrTarget)) m_pendingRuns.append(ptrTarget); if(m_state != CMakeTool::RunningDone) return; return startNextRun(); } QString CMakeTool::displayName() { return QString::fromLatin1("Default"); } void CMakeTool::startNextRun() { QPointer ptrMyTarget; while(!m_pendingRuns.isEmpty() && ptrMyTarget.isNull()) ptrMyTarget = m_pendingRuns.dequeue(); if(!ptrMyTarget) return; // We create a cbp file, only if we didn't find a cbp file in the base directory // Yet that can still override cbp files in subdirectories // And we are creating tons of files in the source directories // All of that is not really nice. // The mid term plan is to move away from the CodeBlocks Generator and use our own // QtCreator generator, which actually can be very similar to the CodeBlock Generator CMakeBuildConfiguration* config = qobject_cast(ptrMyTarget->activeBuildConfiguration()); if(!config) return; Utils::Environment env = config->environment(); QDir buildDirectory(config->buildDirectory().toString()); QString buildDirectoryPath = buildDirectory.absolutePath(); buildDirectory.mkpath(buildDirectoryPath); //user chose the kit on project creation ptrMyTarget->kit()->addToEnvironment(env); createProcessIfNotExists(); m_state = CMakeTool::RunningProject; GeneratorInfo gInfo(ptrMyTarget->kit(),config->useNinja()); QStringList args; args << ptrMyTarget->project()->projectDirectory() << config->arguments() << QLatin1String(gInfo.generatorArgument()); m_process->setWorkingDirectory(buildDirectoryPath); if(m_futureInterface) delete m_futureInterface; m_futureInterface = new QFutureInterface(); m_futureInterface->setProgressRange(0,1); Core::FutureProgress* futureProgress = Core::ProgressManager::addTask(m_futureInterface->future() ,tr("Parsing ProjectFile") ,Core::Id("CMakeProjectManager.CMakeTaskID")); connect(futureProgress,SIGNAL(canceled()),this,SLOT(cancel())); m_futureInterface->reportStarted(); startProcess(args,env); } static void extractKeywords(const QByteArray &input, QStringList *destination) { if (!destination) return; QString keyword; int ignoreZone = 0; for (int i = 0; i < input.count(); ++i) { const QChar chr = QLatin1Char(input.at(i)); if (chr == QLatin1Char('{')) ++ignoreZone; if (chr == QLatin1Char('}')) --ignoreZone; if (ignoreZone == 0) { if ((chr.isLetterOrNumber() && chr.isUpper()) || chr == QLatin1Char('_')) { keyword += chr; } else { if (!keyword.isEmpty()) { if (keyword.size() > 1) *destination << keyword; keyword.clear(); } } } } if (keyword.size() > 1) *destination << keyword; } void CMakeTool::parseFunctionOutput(const QByteArray &output) { QList cmakeFunctionsList = output.split('\n'); m_functions.clear(); if (!cmakeFunctionsList.isEmpty()) { cmakeFunctionsList.removeFirst(); //remove version string foreach (const QByteArray &function, cmakeFunctionsList) m_functions << QString::fromLocal8Bit(function.trimmed()); } } QString CMakeTool::formatFunctionDetails(const QString &command, const QString &args) { return QString::fromLatin1("") .arg(Qt::escape(command)).arg(Qt::escape(args)); } void CMakeTool::parseFunctionDetailsOutput(const QByteArray &output) { QStringList cmakeFunctionsList = m_functions; QList cmakeCommandsHelp = output.split('\n'); for (int i = 0; i < cmakeCommandsHelp.count(); ++i) { QByteArray lineTrimmed = cmakeCommandsHelp.at(i).trimmed(); if (cmakeFunctionsList.isEmpty()) break; if (cmakeFunctionsList.first().toLatin1() == lineTrimmed) { QStringList commandSyntaxes; QString currentCommandSyntax; QString currentCommand = cmakeFunctionsList.takeFirst(); ++i; for (; i < cmakeCommandsHelp.count(); ++i) { lineTrimmed = cmakeCommandsHelp.at(i).trimmed(); if (!cmakeFunctionsList.isEmpty() && cmakeFunctionsList.first().toLatin1() == lineTrimmed) { //start of next function in output if (!currentCommandSyntax.isEmpty()) commandSyntaxes << currentCommandSyntax.append(QLatin1String("
%1%2
")); --i; break; } if (lineTrimmed.startsWith(currentCommand.toLatin1() + "(")) { if (!currentCommandSyntax.isEmpty()) commandSyntaxes << currentCommandSyntax.append(QLatin1String("")); QByteArray argLine = lineTrimmed.mid(currentCommand.length()); extractKeywords(argLine, &m_variables); currentCommandSyntax = formatFunctionDetails(currentCommand, QString::fromUtf8(argLine)); } else { if (!currentCommandSyntax.isEmpty()) { if (lineTrimmed.isEmpty()) { commandSyntaxes << currentCommandSyntax.append(QLatin1String("")); currentCommandSyntax.clear(); } else { extractKeywords(lineTrimmed, &m_variables); currentCommandSyntax += QString::fromLatin1(" %1") .arg(Qt::escape(QString::fromLocal8Bit(lineTrimmed))); } } } } m_functionArgs[currentCommand] = commandSyntaxes; } } m_functions = m_functionArgs.keys(); } void CMakeTool::parseVariableOutput(const QByteArray &output) { QList variableList = output.split('\n'); if (!variableList.isEmpty()) { variableList.removeFirst(); //remove version string foreach (const QByteArray &variable, variableList) { if (variable.contains("_")) { m_variables << QString::fromLocal8Bit(variable).replace(QLatin1String("_"), QLatin1String("_DEBUG")); m_variables << QString::fromLocal8Bit(variable).replace(QLatin1String("_"), QLatin1String("_RELEASE")); m_variables << QString::fromLocal8Bit(variable).replace(QLatin1String("_"), QLatin1String("_MINSIZEREL")); m_variables << QString::fromLocal8Bit(variable).replace(QLatin1String("_"), QLatin1String("_RELWITHDEBINFO")); } else if (variable.contains("_")) { m_variables << QString::fromLocal8Bit(variable).replace(QLatin1String("_"), QLatin1String("_C")); m_variables << QString::fromLocal8Bit(variable).replace(QLatin1String("_"), QLatin1String("_CXX")); } else if (!variable.contains("_<") && !variable.contains('[')) { m_variables << QString::fromLocal8Bit(variable); } } } } void CMakeTool::parseDone() { m_variables.sort(); m_variables.removeDuplicates(); } qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakesettingspage.h0000644000015301777760000000464012323167666031147 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEPROJECTMANAGER_INTERNAL_CMAKESETTINGSPAGE_H #define CMAKEPROJECTMANAGER_INTERNAL_CMAKESETTINGSPAGE_H #include #include #include #include namespace CMakeProjectManager { namespace Internal { class CMakeSettingsPage : public Core::IOptionsPage { Q_OBJECT public: CMakeSettingsPage(); ~CMakeSettingsPage(); QWidget *createPage(QWidget *parent); void apply(); void finish(); bool isCMakeExecutableValid() const; bool hasCodeBlocksMsvcGenerator() const; bool hasCodeBlocksNinjaGenerator() const; bool preferNinja() const; TextEditor::Keywords keywords(); private: void saveSettings() const; QString findCmakeExecutable() const; Utils::PathChooser *m_pathchooser; QCheckBox *m_preferNinja; }; } // namespace Internal } // namespace CMakeProjectManager #endif // CMAKEPROJECTMANAGER_INTERNAL_CMAKESETTINGSPAGE_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeprojectmanager.cpp0000644000015301777760000001714212323167675032007 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmakeprojectmanager.h" #include "cmakeprojectconstants.h" #include "cmakeproject.h" #include "cmaketoolmanager.h" #include #include #include #include #include #include #include #include #include #include //#include #include #include #include #include #include #include #include #include #include #include #include using namespace CMakeProjectManager; using namespace CMakeProjectManager::Internal; CMakeManager* CMakeManager::m_instance = 0; CMakeManager::CMakeManager(CMakeSettingsPage *cmakeSettingsPage) : m_settingsPage(cmakeSettingsPage) { m_instance = this; ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance(); connect(projectExplorer, SIGNAL(aboutToShowContextMenu(ProjectExplorer::Project*,ProjectExplorer::Node*)), this, SLOT(updateContextMenu(ProjectExplorer::Project*,ProjectExplorer::Node*))); Core::ActionContainer *mbuild = Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_BUILDPROJECT); Core::ActionContainer *mproject = Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_PROJECTCONTEXT); Core::ActionContainer *msubproject = Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_SUBPROJECTCONTEXT); const Core::Context projectContext(CMakeProjectManager::Constants::PROJECTCONTEXT); m_runCMakeAction = new QAction(QIcon(), tr("Run CMake"), this); Core::Command *command = Core::ActionManager::registerAction(m_runCMakeAction, Constants::RUNCMAKE, projectContext); command->setAttribute(Core::Command::CA_Hide); mbuild->addAction(command, ProjectExplorer::Constants::G_BUILD_DEPLOY); connect(m_runCMakeAction, SIGNAL(triggered()), this, SLOT(runCMake())); m_runCMakeActionContextMenu = new QAction(QIcon(), tr("Run CMake"), this); command = Core::ActionManager::registerAction(m_runCMakeActionContextMenu, Constants::RUNCMAKECONTEXTMENU, projectContext); command->setAttribute(Core::Command::CA_Hide); mproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); msubproject->addAction(command, ProjectExplorer::Constants::G_PROJECT_BUILD); connect(m_runCMakeActionContextMenu, SIGNAL(triggered()), this, SLOT(runCMakeContextMenu())); } void CMakeManager::updateContextMenu(ProjectExplorer::Project *project, ProjectExplorer::Node *node) { Q_UNUSED(node); m_contextProject = project; } void CMakeManager::runCMake() { runCMake(ProjectExplorer::ProjectExplorerPlugin::currentProject()); } void CMakeManager::runCMakeContextMenu() { runCMake(m_contextProject); } void CMakeManager::runCMake(ProjectExplorer::Project *project) { if (!project) return; if(project->id() != Constants::CMAKEPROJECT_ID) return; CMakeProject *cmakeProject = static_cast(project); if (!cmakeProject) return; else if (!cmakeProject->activeTarget() || !cmakeProject->activeTarget()->activeBuildConfiguration()) return; if (!ProjectExplorer::ProjectExplorerPlugin::instance()->saveModifiedFiles()) return; ICMakeTool* cmake = CMakeToolManager::cmakeToolForKit(cmakeProject->activeTarget()->kit()); cmake->runCMake(cmakeProject->activeTarget()); connect(cmake,SIGNAL(cmakeFinished(ProjectExplorer::Target*)),cmakeProject,SLOT(parseCMakeLists(ProjectExplorer::Target*)),Qt::UniqueConnection); } ProjectExplorer::Project *CMakeManager::openProject(const QString &fileName, QString *errorString) { if (!QFileInfo(fileName).isFile()) { if (errorString) *errorString = tr("Failed opening project '%1': Project is not a file") .arg(fileName); return 0; } return new CMakeProject(this, fileName); } QString CMakeManager::mimeType() const { return QLatin1String(Constants::CMAKEMIMETYPE); } bool CMakeManager::preferNinja() { return m_instance->m_settingsPage->preferNinja(); } QString CMakeManager::findCbpFile(const QDir &directory) { // Find the cbp file // the cbp file is named like the project() command in the CMakeList.txt file // so this function below could find the wrong cbp file, if the user changes the project() // 2name QDateTime t; QString file; foreach (const QString &cbpFile , directory.entryList()) { if (cbpFile.endsWith(QLatin1String(".cbp"))) { QFileInfo fi(directory.path() + QLatin1Char('/') + cbpFile); if (t.isNull() || fi.lastModified() > t) { file = directory.path() + QLatin1Char('/') + cbpFile; t = fi.lastModified(); } } } return file; } // This code is duplicated from qtversionmanager QString CMakeManager::qtVersionForQMake(const QString &qmakePath) { QProcess qmake; qmake.start(qmakePath, QStringList(QLatin1String("--version"))); if (!qmake.waitForStarted()) { qWarning("Cannot start '%s': %s", qPrintable(qmakePath), qPrintable(qmake.errorString())); return QString(); } if (!qmake.waitForFinished()) { Utils::SynchronousProcess::stopProcess(qmake); qWarning("Timeout running '%s'.", qPrintable(qmakePath)); return QString(); } QString output = QString::fromLocal8Bit(qmake.readAllStandardOutput()); QRegExp regexp(QLatin1String("(QMake version|Qmake version:)[\\s]*([\\d.]*)")); regexp.indexIn(output); if (regexp.cap(2).startsWith(QLatin1String("2."))) { QRegExp regexp2(QLatin1String("Using Qt version[\\s]*([\\d\\.]*)")); regexp2.indexIn(output); return regexp2.cap(1); } return QString(); } ././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeprojectmanager_dependencies.priqtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeprojectmanager_dependencies0000644000015301777760000000033312323167675033726 0ustar pbusernogroup00000000000000QTC_PLUGIN_NAME = CMakeProjectManager QTC_PLUGIN_DEPENDS += \ coreplugin \ locator \ projectexplorer \ cpptools \ texteditor \ qtsupport \ remotelinux QTC_PLUGIN_RECOMMENDS += \ designer qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeparser.cpp0000644000015301777760000002125012323167666030275 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Axonian LLC. ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmakeparser.h" #include #include #include using namespace CMakeProjectManager; using namespace Internal; using namespace ProjectExplorer; const char COMMON_ERROR_PATTERN[] = "^CMake Error at (.*):([0-9]*) \\((.*)\\):"; const char NEXT_SUBERROR_PATTERN[] = "^CMake Error in (.*):"; CMakeParser::CMakeParser() : m_skippedFirstEmptyLine(false) { m_commonError.setPattern(QLatin1String(COMMON_ERROR_PATTERN)); m_commonError.setMinimal(true); QTC_CHECK(m_commonError.isValid()); m_nextSubError.setPattern(QLatin1String(NEXT_SUBERROR_PATTERN)); m_nextSubError.setMinimal(true); QTC_CHECK(m_nextSubError.isValid()); appendOutputParser(new GnuMakeParser()); } void CMakeParser::stdError(const QString &line) { QString trimmedLine = rightTrimmed(line); if (trimmedLine.isEmpty() && !m_lastTask.isNull()) { if (m_skippedFirstEmptyLine) doFlush(); else m_skippedFirstEmptyLine = true; return; } if (m_skippedFirstEmptyLine) m_skippedFirstEmptyLine= false; if (m_commonError.indexIn(trimmedLine) != -1) { m_lastTask = Task(Task::Error, QString(), Utils::FileName::fromUserInput(m_commonError.cap(1)), m_commonError.cap(2).toInt(), Constants::TASK_CATEGORY_BUILDSYSTEM); return; } else if (m_nextSubError.indexIn(trimmedLine) != -1) { m_lastTask = Task(Task::Error, QString(), Utils::FileName::fromUserInput(m_nextSubError.cap(1)), -1, Constants::TASK_CATEGORY_BUILDSYSTEM); return; } else if (trimmedLine.startsWith(QLatin1String(" ")) && !m_lastTask.isNull()) { if (!m_lastTask.description.isEmpty()) m_lastTask.description.append(QLatin1Char(' ')); m_lastTask.description.append(trimmedLine.trimmed()); return; } IOutputParser::stdError(line); } void CMakeParser::doFlush() { if (m_lastTask.isNull()) return; Task t = m_lastTask; m_lastTask.clear(); emit addTask(t); } #ifdef WITH_TESTS #include "cmakeprojectplugin.h" #include #include void CMakeProjectPlugin::testCMakeParser_data() { QTest::addColumn("input"); QTest::addColumn("inputChannel"); QTest::addColumn("childStdOutLines"); QTest::addColumn("childStdErrLines"); QTest::addColumn >("tasks"); QTest::addColumn("outputLines"); const Core::Id categoryBuild = Constants::TASK_CATEGORY_BUILDSYSTEM; // negative tests QTest::newRow("pass-through stdout") << QString::fromLatin1("Sometext") << OutputParserTester::STDOUT << QString::fromLatin1("Sometext\n") << QString() << QList() << QString(); QTest::newRow("pass-through stderr") << QString::fromLatin1("Sometext") << OutputParserTester::STDERR << QString() << QString::fromLatin1("Sometext\n") << QList() << QString(); // positive tests QTest::newRow("add custom target") << QString::fromLatin1("CMake Error at src/1/app/CMakeLists.txt:70 (add_custom_target):\n" " Cannot find source file:\n\n" " unknownFile.qml\n\n" " Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp\n" " .hxx .in .txx\n\n\n" "CMake Error in src/1/app/CMakeLists.txt:\n" " Cannot find source file:\n\n" " CMakeLists.txt2\n\n" " Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp\n" " .hxx .in .txx\n\n") << OutputParserTester::STDERR << QString() << QString() << (QList() << Task(Task::Error, QLatin1String("Cannot find source file: unknownFile.qml Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx"), Utils::FileName::fromUserInput(QLatin1String("src/1/app/CMakeLists.txt")), 70, categoryBuild) << Task(Task::Error, QLatin1String("Cannot find source file: CMakeLists.txt2 Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx"), Utils::FileName::fromUserInput(QLatin1String("src/1/app/CMakeLists.txt")), -1, categoryBuild)) << QString(); QTest::newRow("add subdirectory") << QString::fromLatin1("CMake Error at src/1/CMakeLists.txt:8 (add_subdirectory):\n" " add_subdirectory given source \"app1\" which is not an existing directory.\n\n") << OutputParserTester::STDERR << QString() << QString() << (QList() << Task(Task::Error, QLatin1String("add_subdirectory given source \"app1\" which is not an existing directory."), Utils::FileName::fromUserInput(QLatin1String("src/1/CMakeLists.txt")), 8, categoryBuild)) << QString(); QTest::newRow("unknown command") << QString::fromLatin1("CMake Error at src/1/CMakeLists.txt:8 (i_am_wrong_command):\n" " Unknown CMake command \"i_am_wrong_command\".\n\n") << OutputParserTester::STDERR << QString() << QString() << (QList() << Task(Task::Error, QLatin1String("Unknown CMake command \"i_am_wrong_command\"."), Utils::FileName::fromUserInput(QLatin1String("src/1/CMakeLists.txt")), 8, categoryBuild)) << QString(); QTest::newRow("incorrect arguments") << QString::fromLatin1("CMake Error at src/1/CMakeLists.txt:8 (message):\n" " message called with incorrect number of arguments\n\n") << OutputParserTester::STDERR << QString() << QString() << (QList() << Task(Task::Error, QLatin1String("message called with incorrect number of arguments"), Utils::FileName::fromUserInput(QLatin1String("src/1/CMakeLists.txt")), 8, categoryBuild)) << QString(); } void CMakeProjectPlugin::testCMakeParser() { #if 0 OutputParserTester testbench; testbench.appendOutputParser(new CMakeParser); QFETCH(QString, input); QFETCH(OutputParserTester::Channel, inputChannel); QFETCH(QList, tasks); QFETCH(QString, childStdOutLines); QFETCH(QString, childStdErrLines); QFETCH(QString, outputLines); testbench.testParsing(input, inputChannel, tasks, childStdOutLines, childStdErrLines, outputLines); #endif } #endif qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeprojectconstants.h0000644000015301777760000000463212323167666032056 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEPROJECTCONSTANTS_H #define CMAKEPROJECTCONSTANTS_H namespace CMakeProjectManager { namespace Constants { const char PROJECTCONTEXT[] = "CMakeProject.ProjectContext"; const char CMAKEMIMETYPE[] = "text/x-cmake"; const char CMAKE_EDITOR_ID[] = "CMakeProject.CMakeEditor"; const char CMAKE_EDITOR_DISPLAY_NAME[] = "CMake Editor"; const char C_CMAKEEDITOR[] = "CMakeProject.Context.CMakeEditor"; const char RUNCMAKE[] = "CMakeProject.RunCMake"; const char RUNCMAKECONTEXTMENU[] = "CMakeProject.RunCMakeContextMenu"; const char CMAKE_SUPPORT_FEATURE[] = "CMake.CMakeSupport"; // Project const char CMAKEPROJECT_ID[] = "CMakeProjectManager.CMakeProject"; // Buildconfiguration const char CMAKE_BC_ID[] = "CMakeProjectManager.CMakeBuildConfiguration"; // Menu const char M_CONTEXT[] = "CMakeEditor.ContextMenu"; // CMake Tool const char CMAKE_TOOL_ID[] = "CMakeProjectManager.DefaultCMakeTool"; } // namespace Constants } // namespace CMakeProjectManager #endif // CMAKEPROJECTCONSTANTS_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/generatorinfo.cpp0000644000015301777760000001421112323167666030641 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "generatorinfo.h" #include "cmakekitinformation.h" #include "cmakeprojectconstants.h" #include #include #include #include #include #include namespace CMakeProjectManager { 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; } QByteArray GeneratorInfo::generator() const { if (!m_kit) return QByteArray(); ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(m_kit); ProjectExplorer::Abi targetAbi = tc->targetAbi(); if (m_isNinja) { return "Ninja"; } 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) { return "NMake Makefiles"; } else if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor) { if (Utils::HostOsInfo::isWindowsHost()) return "MinGW Makefiles"; else return "Unix Makefiles"; } } return "Unix Makefiles"; } QByteArray GeneratorInfo::generatorArgument() const { QByteArray tmp = generator(); if (tmp.isEmpty()) return tmp; return QByteArray("-GCodeBlocks - ") + tmp; } QString GeneratorInfo::displayName() const { if (!m_kit) return QString(); if (m_isNinja) return tr("Ninja"); 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) { return tr("NMake Generator"); } else if (targetAbi.osFlavor() == ProjectExplorer::Abi::WindowsMSysFlavor) { if (Utils::HostOsInfo::isWindowsHost()) return tr("MinGW Generator"); else return tr("Unix Generator"); } } else { // Non windows return tr("Unix Generator"); } return QString(); } QList GeneratorInfo::generatorInfosFor(ProjectExplorer::Kit *k, Ninja n, bool preferNinja, bool hasCodeBlocks) { QList results; ProjectExplorer::ToolChain *tc = ProjectExplorer::ToolChainKitInformation::toolChain(k); if (!tc) return results; Core::Id deviceType = ProjectExplorer::DeviceTypeKitInformation::deviceTypeId(k); //check only for the default CMake Tool, if there is a other tool set for the Kit it has //to be compatible with the kit if (CMakeKitInformation::cmakeToolId(k) == CMakeProjectManager::Constants::CMAKE_TOOL_ID && deviceType != ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE && deviceType != RemoteLinux::Constants::GenericLinuxOsType) return results; 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); } } if (n != NoNinja) { if (preferNinja) results.prepend(GeneratorInfo(k, true)); else results.append(GeneratorInfo(k, true)); } return results; } } // namespace CMake qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeopenprojectwizard.cpp0000644000015301777760000006177412323167666032571 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmakeopenprojectwizard.h" #include "cmakeprojectmanager.h" #include "cmakebuildconfiguration.h" #include "cmakebuildinfo.h" #include "generatorinfo.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include 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 ////////////// /// CMakeOpenProjectWizard ////////////// CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, const QString &sourceDirectory, Utils::Environment env) : m_cmakeManager(cmakeManager), m_sourceDirectory(sourceDirectory), m_environment(env), m_useNinja(false), m_kit(0) { if (!compatibleKitExist()) addPage(new NoKitPage(this)); if (hasInSourceBuild()) { m_buildDirectory = m_sourceDirectory; addPage(new InSourceBuildPage(this)); } else { m_buildDirectory = m_sourceDirectory + QLatin1String("-build"); addPage(new ShadowBuildPage(this)); } if (!m_cmakeManager->isCMakeExecutableValid()) addPage(new ChooseCMakePage(this)); addPage(new CMakeRunPage(this)); init(); } CMakeOpenProjectWizard::CMakeOpenProjectWizard(CMakeManager *cmakeManager, CMakeOpenProjectWizard::Mode mode, const CMakeBuildInfo *info) : m_cmakeManager(cmakeManager), m_sourceDirectory(info->sourceDirectory), m_environment(info->environment), m_useNinja(info->useNinja), m_kit(0) { m_kit = ProjectExplorer::KitManager::find(info->kitId); CMakeRunPage::Mode rmode; if (mode == CMakeOpenProjectWizard::NeedToCreate) rmode = CMakeRunPage::Recreate; else if (mode == CMakeOpenProjectWizard::WantToUpdate) rmode = CMakeRunPage::WantToUpdate; else if (mode == CMakeOpenProjectWizard::NeedToUpdate) rmode = CMakeRunPage::NeedToUpdate; else rmode = CMakeRunPage::ChangeDirectory; if (mode == CMakeOpenProjectWizard::ChangeDirectory) { m_buildDirectory = info->buildDirectory.toString(); addPage(new ShadowBuildPage(this, true)); } if (!m_cmakeManager->isCMakeExecutableValid()) addPage(new ChooseCMakePage(this)); addPage(new CMakeRunPage(this, rmode, info->buildDirectory.toString())); init(); } void CMakeOpenProjectWizard::init() { setWindowTitle(tr("CMake Wizard")); } CMakeManager *CMakeOpenProjectWizard::cmakeManager() const { return m_cmakeManager; } bool CMakeOpenProjectWizard::hasInSourceBuild() const { QFileInfo fi(m_sourceDirectory + QLatin1String("/CMakeCache.txt")); if (fi.exists()) return true; return false; } bool CMakeOpenProjectWizard::compatibleKitExist() const { bool hasCodeBlocksGenerator = m_cmakeManager->hasCodeBlocksMsvcGenerator(); bool hasNinjaGenerator = m_cmakeManager->hasCodeBlocksNinjaGenerator(); bool preferNinja = m_cmakeManager->preferNinja(); QList kitList = ProjectExplorer::KitManager::kits(); 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 infos = GeneratorInfo::generatorInfosFor(k, hasNinjaGenerator ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja, preferNinja, hasCodeBlocksGenerator); if (!infos.isEmpty()) return true; } return false; } bool CMakeOpenProjectWizard::existsUpToDateXmlFile() const { QString cbpFile = CMakeManager::findCbpFile(QDir(buildDirectory())); if (!cbpFile.isEmpty()) { // We already have a cbp file QFileInfo cbpFileInfo(cbpFile); QFileInfo cmakeListsFileInfo(sourceDirectory() + QLatin1String("/CMakeLists.txt")); 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; } bool CMakeOpenProjectWizard::useNinja() const { return m_useNinja; } void CMakeOpenProjectWizard::setUseNinja(bool b) { m_useNinja = b; } QString CMakeOpenProjectWizard::arguments() const { return m_arguments; } void CMakeOpenProjectWizard::setArguments(const QString &args) { m_arguments = args; } Utils::Environment CMakeOpenProjectWizard::environment() const { return m_environment; } ProjectExplorer::Kit *CMakeOpenProjectWizard::kit() const { return m_kit; } void CMakeOpenProjectWizard::setKit(ProjectExplorer::Kit *kit) { m_kit = kit; } ////// // 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; m_optionsButton->setText(tr("Show Options")); 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); } InSourceBuildPage::InSourceBuildPage(CMakeOpenProjectWizard *cmakeWizard) : QWizardPage(cmakeWizard), m_cmakeWizard(cmakeWizard) { setLayout(new QVBoxLayout); QLabel *label = new QLabel(this); label->setWordWrap(true); label->setText(tr("Qt Creator has detected an in-source-build in %1 " "which prevents shadow builds. Qt Creator will not allow you to change the build directory. " "If you want a shadow build, clean your source directory and re-open the project.") .arg(m_cmakeWizard->buildDirectory())); layout()->addWidget(label); setTitle(tr("Build Location")); } ShadowBuildPage::ShadowBuildPage(CMakeOpenProjectWizard *cmakeWizard, bool change) : QWizardPage(cmakeWizard), m_cmakeWizard(cmakeWizard) { QFormLayout *fl = new QFormLayout; this->setLayout(fl); QLabel *label = new QLabel(this); label->setWordWrap(true); if (change) label->setText(tr("Please enter the directory in which you want to build your project.") + QLatin1Char(' ')); 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.")); fl->addRow(label); m_pc = new Utils::PathChooser(this); m_pc->setBaseDirectory(m_cmakeWizard->sourceDirectory()); m_pc->setPath(m_cmakeWizard->buildDirectory()); m_pc->setExpectedKind(Utils::PathChooser::Directory); connect(m_pc, SIGNAL(changed(QString)), this, SLOT(buildDirectoryChanged())); fl->addRow(tr("Build directory:"), m_pc); setTitle(tr("Build Location")); } void ShadowBuildPage::buildDirectoryChanged() { m_cmakeWizard->setBuildDirectory(m_pc->path()); } 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); fl->addRow(tr("CMake Executable:"), m_cmakeExecutable); connect(m_cmakeExecutable, SIGNAL(editingFinished()), this, SLOT(cmakeExecutableChanged())); connect(m_cmakeExecutable, SIGNAL(browsingFinished()), this, SLOT(cmakeExecutableChanged())); setTitle(tr("Choose CMake Executable")); } void ChooseCMakePage::updateErrorText() { QString cmakeExecutable = m_cmakeWizard->cmakeManager()->cmakeExecutable(); if (m_cmakeWizard->cmakeManager()->isCMakeExecutableValid()) { m_cmakeLabel->setText(tr("The CMake executable is valid.")); } else { QString text = tr("Specify the path to the CMake executable. No CMake executable was found in the path."); if (!cmakeExecutable.isEmpty()) { text += QLatin1Char(' '); QFileInfo fi(cmakeExecutable); if (!fi.exists()) text += tr("The CMake executable (%1) does not exist.").arg(cmakeExecutable); else if (!fi.isExecutable()) text += tr("The path %1 is not an executable.").arg(cmakeExecutable); else text += tr("The path %1 is not a valid CMake executable.").arg(cmakeExecutable); } 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(); } CMakeRunPage::CMakeRunPage(CMakeOpenProjectWizard *cmakeWizard, Mode mode, const QString &buildDirectory) : QWizardPage(cmakeWizard), m_cmakeWizard(cmakeWizard), m_haveCbpFile(false), m_mode(mode), m_buildDirectory(buildDirectory) { initWidgets(); } void CMakeRunPage::initWidgets() { QFormLayout *fl = new QFormLayout; fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); setLayout(fl); // Description Label m_descriptionLabel = new QLabel(this); m_descriptionLabel->setWordWrap(true); fl->addRow(m_descriptionLabel); // Run CMake Line (with arguments) m_argumentsLineEdit = new Utils::FancyLineEdit(this); m_argumentsLineEdit->setHistoryCompleter(QLatin1String("CMakeArgumentsLineEdit")); m_argumentsLineEdit->selectAll(); connect(m_argumentsLineEdit,SIGNAL(returnPressed()), this, SLOT(runCMake())); fl->addRow(tr("Arguments:"), m_argumentsLineEdit); m_generatorComboBox = new QComboBox(this); fl->addRow(tr("Generator:"), m_generatorComboBox); m_runCMake = new QPushButton(this); m_runCMake->setText(tr("Run CMake")); connect(m_runCMake, SIGNAL(clicked()), this, SLOT(runCMake())); QHBoxLayout *hbox2 = new QHBoxLayout; hbox2->addStretch(10); hbox2->addWidget(m_runCMake); fl->addRow(hbox2); // Bottom output window m_output = new QPlainTextEdit(this); m_output->setReadOnly(true); // 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); QFont f(TextEditor::FontSettings::defaultFixedFontFamily()); f.setStyleHint(QFont::TypeWriter); m_output->setFont(f); QSizePolicy pl = m_output->sizePolicy(); pl.setVerticalStretch(1); m_output->setSizePolicy(pl); fl->addRow(m_output); m_exitCodeLabel = new QLabel(this); m_exitCodeLabel->setVisible(false); fl->addRow(m_exitCodeLabel); setTitle(tr("Run CMake")); setMinimumSize(600, 400); } QByteArray CMakeRunPage::cachedGeneratorFromFile(const QString &cache) { QFile fi(cache); if (fi.exists()) { // Cache exists, then read it... if (fi.open(QIODevice::ReadOnly | QIODevice::Text)) { while (!fi.atEnd()) { QByteArray line = fi.readLine(); if (line.startsWith("CMAKE_GENERATOR:INTERNAL=")) { int splitpos = line.indexOf('='); if (splitpos != -1) { QByteArray cachedGenerator = line.mid(splitpos + 1).trimmed(); if (!cachedGenerator.isEmpty()) return cachedGenerator; } } } } } return QByteArray(); } void CMakeRunPage::initializePage() { if (m_mode == Initial) { bool upToDateXmlFile = m_cmakeWizard->existsUpToDateXmlFile(); m_buildDirectory = m_cmakeWizard->buildDirectory(); if (upToDateXmlFile) { m_descriptionLabel->setText( tr("The directory %1 already contains a cbp file, which is recent enough. " "You can pass special arguments and rerun CMake. " "Or simply finish the wizard directly.").arg(m_buildDirectory)); m_haveCbpFile = true; } else { m_descriptionLabel->setText( 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)); } } else if (m_mode == CMakeRunPage::NeedToUpdate) { m_descriptionLabel->setText(tr("The directory %1 contains an outdated .cbp file. Qt " "Creator needs to update this file by running CMake. " "If you want to add additional command line arguments, " "add them below. Note that CMake remembers command " "line arguments from the previous runs.").arg(m_buildDirectory)); } else if (m_mode == CMakeRunPage::Recreate) { m_descriptionLabel->setText(tr("The directory %1 specified in a build-configuration, " "does not contain a cbp file. Qt Creator needs to " "recreate this file, by running CMake. " "Some projects require command line arguments to " "the initial CMake call. Note that CMake remembers command " "line arguments from the previous runs.").arg(m_buildDirectory)); } else if (m_mode == CMakeRunPage::ChangeDirectory) { m_buildDirectory = m_cmakeWizard->buildDirectory(); m_descriptionLabel->setText(tr("Qt Creator needs to run CMake in the new build directory. " "Some projects require command line arguments to the " "initial CMake call.")); } else if (m_mode == CMakeRunPage::WantToUpdate) { m_descriptionLabel->setText(tr("Refreshing cbp file in %1.").arg(m_buildDirectory)); } // Build the list of generators/toolchains we want to offer m_generatorComboBox->clear(); bool hasCodeBlocksGenerator = m_cmakeWizard->cmakeManager()->hasCodeBlocksMsvcGenerator(); bool hasNinjaGenerator = m_cmakeWizard->cmakeManager()->hasCodeBlocksNinjaGenerator(); bool preferNinja = m_cmakeWizard->cmakeManager()->preferNinja(); if (m_mode == Initial) { // Try figuring out generator and toolchain from CMakeCache.txt QByteArray cachedGenerator = cachedGeneratorFromFile(m_buildDirectory + QLatin1String("/CMakeCache.txt")); m_generatorComboBox->show(); QList kitList = ProjectExplorer::KitManager::kits(); int defaultIndex = 0; foreach (ProjectExplorer::Kit *k, kitList) { QList infos = GeneratorInfo::generatorInfosFor(k, hasNinjaGenerator ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja, preferNinja, hasCodeBlocksGenerator); if (k == ProjectExplorer::KitManager::defaultKit()) defaultIndex = m_generatorComboBox->count(); foreach (const GeneratorInfo &info, infos) if (cachedGenerator.isEmpty() || info.generator() == cachedGenerator) m_generatorComboBox->addItem(info.displayName(), qVariantFromValue(info)); } m_generatorComboBox->setCurrentIndex(defaultIndex); } 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; } QList infos = GeneratorInfo::generatorInfosFor(m_cmakeWizard->kit(), ninja, preferNinja, true); foreach (const GeneratorInfo &info, infos) m_generatorComboBox->addItem(info.displayName(), qVariantFromValue(info)); } } bool CMakeRunPage::validatePage() { int index = m_generatorComboBox->currentIndex(); if (index == -1) return false; GeneratorInfo generatorInfo = m_generatorComboBox->itemData(index).value(); m_cmakeWizard->setKit(generatorInfo.kit()); m_cmakeWizard->setUseNinja(generatorInfo.isNinja()); return QWizardPage::validatePage(); } void CMakeRunPage::runCMake() { m_haveCbpFile = false; Utils::Environment env = m_cmakeWizard->environment(); int index = m_generatorComboBox->currentIndex(); if (index == -1) { m_output->appendPlainText(tr("No generator selected.")); return; } GeneratorInfo generatorInfo = m_generatorComboBox->itemData(index).value(); m_cmakeWizard->setKit(generatorInfo.kit()); m_cmakeWizard->setUseNinja(generatorInfo.isNinja()); // 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); m_runCMake->setEnabled(false); m_argumentsLineEdit->setEnabled(false); m_generatorComboBox->setEnabled(false); m_output->clear(); CMakeManager *cmakeManager = m_cmakeWizard->cmakeManager(); if (m_cmakeWizard->cmakeManager()->isCMakeExecutableValid()) { m_cmakeProcess = new Utils::QtcProcess(); connect(m_cmakeProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(cmakeReadyReadStandardOutput())); connect(m_cmakeProcess, SIGNAL(readyReadStandardError()), this, SLOT(cmakeReadyReadStandardError())); connect(m_cmakeProcess, SIGNAL(finished(int)), this, SLOT(cmakeFinished())); cmakeManager->createXmlFile( m_cmakeProcess, m_argumentsLineEdit->text(), m_cmakeWizard->sourceDirectory(), m_buildDirectory, env, QString::fromLatin1(generatorInfo.generatorArgument())); } else { m_runCMake->setEnabled(true); m_argumentsLineEdit->setEnabled(true); m_generatorComboBox->setEnabled(true); m_output->appendPlainText(tr("No valid CMake executable specified.")); } } 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()); cursor.movePosition(QTextCursor::End); QTextCharFormat tf; QFont font = m_output->font(); tf.setFont(font); tf.setForeground(m_output->palette().color(QPalette::Text)); cursor.insertText(QString::fromLocal8Bit(m_cmakeProcess->readAllStandardOutput()), tf); } void CMakeRunPage::cmakeReadyReadStandardError() { 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))); cursor.insertText(QString::fromLocal8Bit(m_cmakeProcess->readAllStandardError()), tf); } void CMakeRunPage::cmakeFinished() { m_runCMake->setEnabled(true); m_argumentsLineEdit->setEnabled(true); m_generatorComboBox->setEnabled(true); if (m_cmakeProcess->exitCode() != 0) { m_exitCodeLabel->setVisible(true); m_exitCodeLabel->setText(tr("CMake exited with errors. Please check CMake output.")); static_cast(m_argumentsLineEdit->completer())->removeHistoryItem(0); m_haveCbpFile = false; } else { m_exitCodeLabel->setVisible(false); m_haveCbpFile = true; } m_cmakeProcess->deleteLater(); m_cmakeProcess = 0; m_cmakeWizard->setArguments(m_argumentsLineEdit->text()); emit completeChanged(); } void CMakeRunPage::cleanupPage() { m_output->clear(); m_haveCbpFile = false; m_exitCodeLabel->setVisible(false); emit completeChanged(); } bool CMakeRunPage::isComplete() const { int index = m_generatorComboBox->currentIndex(); return index != -1 && m_haveCbpFile; } qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/argumentslineedit.cpp0000644000015301777760000000427012323167666031526 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "argumentslineedit.h" #include namespace CMakeProjectManager { ArgumentsLineEdit::ArgumentsLineEdit(QWidget *parent) : Utils::BaseValidatingLineEdit(parent) { } bool ArgumentsLineEdit::validate(const QString &value, QString *errorMessage) const { Utils::QtcProcess::SplitError err = Utils::QtcProcess::SplitOk; Utils::QtcProcess::splitArgs(value,false,&err); if(err != Utils::QtcProcess::SplitOk) { if(err == Utils::QtcProcess::BadQuoting) *errorMessage = tr("Command contains quoting errors"); else if(err == Utils::QtcProcess::FoundMeta) *errorMessage = tr("Command contains complex shell constructs"); return false; } return true; } } // namespace CMakeProjectManager qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakekitinformation.h0000644000015301777760000000650612323167666031512 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Canonical Ltd. ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEPROJECTMANAGER_CMAKEKITINFORMATION_H #define CMAKEPROJECTMANAGER_CMAKEKITINFORMATION_H #include "cmakeprojectmanager_global.h" #include #include #include QT_BEGIN_NAMESPACE class QLabel; class QPushButton; QT_END_NAMESPACE namespace CMakeProjectManager { class ICMakeTool; class CMAKEPROJECTMANAGER_EXPORT CMakeKitInformationWidget : public ProjectExplorer::KitConfigWidget { Q_OBJECT public: CMakeKitInformationWidget(ProjectExplorer::Kit *kit, const ProjectExplorer::KitInformation *ki); ~CMakeKitInformationWidget(); QString displayName() const; QString toolTip() const; void makeReadOnly(); void refresh(); bool visibleInKit(); QWidget *mainWidget() const; QWidget *buttonWidget() const; private: QLabel *m_label; QPushButton *m_button; }; class CMAKEPROJECTMANAGER_EXPORT CMakeKitInformation : public ProjectExplorer::KitInformation { Q_OBJECT public: CMakeKitInformation(); QVariant defaultValue(ProjectExplorer::Kit *) const; QList validate(const ProjectExplorer::Kit *) const; ItemList toUserOutput(const ProjectExplorer::Kit *) const; ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *) const; static Core::Id id(); static bool hasSpecialCMakeTool(const ProjectExplorer::Kit *kit); static ICMakeTool* cmakeTool(const ProjectExplorer::Kit *kit); static Core::Id cmakeToolId(const ProjectExplorer::Kit *kit); static void setCMakeTool(ProjectExplorer::Kit *kit, const Core::Id &toolId); }; class CMAKEPROJECTMANAGER_EXPORT CMakeKitMatcher : public ProjectExplorer::KitMatcher { public: explicit CMakeKitMatcher() { } bool matches(const ProjectExplorer::Kit *k) const; }; } // namespace CMakeProjectManager #endif // CMAKEPROJECTMANAGER_CMAKEKITINFORMATION_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeprojectplugin.h0000644000015301777760000000415612323167666031341 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEPROJECTPLUGIN_H #define CMAKEPROJECTPLUGIN_H #include #include namespace CMakeProjectManager { namespace Internal { class CMakeProjectPlugin : public ExtensionSystem::IPlugin { Q_OBJECT Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "CMakeProjectManager.json") public: CMakeProjectPlugin(); ~CMakeProjectPlugin(); bool initialize(const QStringList &arguments, QString *errorMessage); void extensionsInitialized(); private slots: #ifdef WITH_TESTS void testCMakeParser_data(); void testCMakeParser(); #endif }; } // namespace Internal } // namespace CMakeProject #endif // CMAKEPROJECTPLUGIN_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeappwizard.cpp0000644000015301777760000002046212323167666031006 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Canonical Ltd. ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmakeappwizard.h" #include "cmakekitinformation.h" #include "cmakeprojectmanager.h" #include "cmakeproject.h" #include "cmaketoolmanager.h" #include #include #include #include #include #include #include #include #include #include #include #include #include namespace CMakeProjectManager { using namespace Internal; CMakeAppWizard::CMakeAppWizard() { } QWizard *CMakeAppWizard::createWizardDialog (QWidget *parent, const Core::WizardDialogParameters &wizardDialogParameters) const { QTC_ASSERT(!parameters().isNull(), return 0); CMakeAppWizardDialog *projectDialog = new CMakeAppWizardDialog(parent, wizardDialogParameters); int firstPage = 1; if(!CMakeToolManager::defaultCMakeTool()->isValid()) { projectDialog->addChooseCMakePage(firstPage); firstPage++; } projectDialog->addTargetSetupPage(firstPage); initProjectWizardDialog(projectDialog, wizardDialogParameters.defaultPath(), wizardDialogParameters.extensionPages()); projectDialog->setIntroDescription(tr("This wizard generates a Application project using CMake.")); return projectDialog; } bool CMakeAppWizard::postGenerateFiles(const QWizard *w, const Core::GeneratedFiles &l, QString *errorMessage) { const CMakeAppWizardDialog *dialog = qobject_cast(w); // Generate user settings foreach (const Core::GeneratedFile &file, l) if (file.attributes() & Core::GeneratedFile::OpenProjectAttribute) { dialog->writeUserFile(file.path()); break; } // Post-Generate: Open the projects/editors return ProjectExplorer::CustomProjectWizard::postGenerateOpen(l ,errorMessage); } void CMakeAppWizard::registerSelf() { ProjectExplorer::CustomWizard::registerFactory(QLatin1String("cmakeapp-project")); } CMakeAppWizardDialog::CMakeAppWizardDialog(QWidget *parent, const Core::WizardDialogParameters ¶meters) : ProjectExplorer::BaseProjectWizardDialog(parent,parameters) , m_targetSetupPage(0) , m_cmakePage(0) { init(); } CMakeAppWizardDialog::~CMakeAppWizardDialog() { if (m_targetSetupPage && !m_targetSetupPage->parent()) delete m_targetSetupPage; if (m_cmakePage && !m_cmakePage->parent()) delete m_cmakePage; } bool CMakeAppWizardDialog::writeUserFile(const QString &cmakeFileName) const { if (!m_targetSetupPage) return false; CMakeManager *manager = ExtensionSystem::PluginManager::getObject(); Q_ASSERT(manager); CMakeProject *pro = new CMakeProject(manager, cmakeFileName); bool success = m_targetSetupPage->setupProject(pro); if (success) pro->saveSettings(); delete pro; return success; } void CMakeAppWizardDialog::init() { connect(this, SIGNAL(projectParametersChanged(QString,QString)), this, SLOT(generateProfileName(QString,QString))); } int CMakeAppWizardDialog::addTargetSetupPage(int id) { m_targetSetupPage = new ProjectExplorer::TargetSetupPage; const QString platform = selectedPlatform(); //prefer Qt Desktop or Platform Kit Core::FeatureSet features = Core::FeatureSet(QtSupport::Constants::FEATURE_DESKTOP); if (platform.isEmpty()) m_targetSetupPage->setPreferredKitMatcher(new QtSupport::QtVersionKitMatcher(features)); else m_targetSetupPage->setPreferredKitMatcher(new QtSupport::QtPlatformKitMatcher(platform)); //make sure only CMake compatible Kits are shown m_targetSetupPage->setRequiredKitMatcher(new CMakeKitMatcher()); resize(900, 450); if (id >= 0) setPage(id, m_targetSetupPage); else id = addPage(m_targetSetupPage); wizardProgress()->item(id)->setTitle(tr("Kits")); return id; } int CMakeAppWizardDialog::addChooseCMakePage(int id) { m_cmakePage = new ChooseCMakePage; if (id >= 0) setPage(id, m_cmakePage); else id = addPage(m_cmakePage); wizardProgress()->item(id)->setTitle(tr("CMake")); return id; } QList CMakeAppWizardDialog::selectedKits() const { if(m_targetSetupPage) return m_targetSetupPage->selectedKits(); return QList(); } void CMakeAppWizardDialog::generateProfileName(const QString &name, const QString &path) { if (!m_targetSetupPage) return; const QString proFile = QDir::cleanPath(path + QLatin1Char('/') + name + QLatin1Char('/') + QLatin1String("CMakeLists.txt")); m_targetSetupPage->setProjectPath(proFile); } ChooseCMakePage::ChooseCMakePage(QWidget *parent) : QWizardPage(parent) { 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); fl->addRow(tr("CMake Executable:"), m_cmakeExecutable); connect(m_cmakeExecutable, SIGNAL(editingFinished()), this, SLOT(cmakeExecutableChanged())); connect(m_cmakeExecutable, SIGNAL(browsingFinished()), this, SLOT(cmakeExecutableChanged())); setTitle(tr("Choose CMake Executable")); updateErrorText(); } void ChooseCMakePage::updateErrorText() { CMakeTool* cmake = CMakeToolManager::defaultCMakeTool(); QString cmakeExecutable = CMakeToolManager::defaultCMakeTool()->cmakeExecutable(); if (cmake->isValid()) { m_cmakeLabel->setText(tr("Used CMake: %0.").arg(cmakeExecutable)); } else { QString text = tr("Specify the path to the CMake executable. No CMake executable was found in the path."); if (!cmakeExecutable.isEmpty()) { text += QLatin1Char(' '); QFileInfo fi(cmakeExecutable); if (!fi.exists()) text += tr("The CMake executable (%1) does not exist.").arg(cmakeExecutable); else if (!fi.isExecutable()) text += tr("The path %1 is not an executable.").arg(cmakeExecutable); else text += tr("The path %1 is not a valid CMake executable.").arg(cmakeExecutable); } m_cmakeLabel->setText(text); } } void ChooseCMakePage::cmakeExecutableChanged() { CMakeToolManager::setUserCmakePath(m_cmakeExecutable->path()); updateErrorText(); emit completeChanged(); } bool ChooseCMakePage::isComplete() const { return CMakeToolManager::defaultCMakeTool()->isValid(); } ChooseCMakeWizard::ChooseCMakeWizard() { addPage(new ChooseCMakePage(this)); setWindowTitle(tr("Choose CMake Wizard")); } } // namespace CMakeProjectManager qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakerunconfiguration.cpp0000644000015301777760000003565312323167666032411 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmakerunconfiguration.h" #include "cmakebuildconfiguration.h" #include "cmakeproject.h" #include "cmakeprojectconstants.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace CMakeProjectManager; using namespace CMakeProjectManager::Internal; namespace { const char CMAKE_RC_PREFIX[] = "CMakeProjectManager.CMakeRunConfiguration."; const char USER_WORKING_DIRECTORY_KEY[] = "CMakeProjectManager.CMakeRunConfiguration.UserWorkingDirectory"; const char USE_TERMINAL_KEY[] = "CMakeProjectManager.CMakeRunConfiguration.UseTerminal"; const char TITLE_KEY[] = "CMakeProjectManager.CMakeRunConfiguation.Title"; const char ARGUMENTS_KEY[] = "CMakeProjectManager.CMakeRunConfiguration.Arguments"; } // namespace CMakeRunConfiguration::CMakeRunConfiguration(ProjectExplorer::Target *parent, Core::Id id, const QString &target, const QString &workingDirectory, const QString &title) : ProjectExplorer::LocalApplicationRunConfiguration(parent, id), m_runMode(Gui), m_buildTarget(target), m_workingDirectory(workingDirectory), m_title(title), m_enabled(true) { addExtraAspect(new ProjectExplorer::LocalEnvironmentAspect(this)); ctor(); } CMakeRunConfiguration::CMakeRunConfiguration(ProjectExplorer::Target *parent, CMakeRunConfiguration *source) : ProjectExplorer::LocalApplicationRunConfiguration(parent, source), m_runMode(source->m_runMode), m_buildTarget(source->m_buildTarget), m_workingDirectory(source->m_workingDirectory), m_userWorkingDirectory(source->m_userWorkingDirectory), m_title(source->m_title), m_arguments(source->m_arguments), m_enabled(source->m_enabled) { ctor(); } CMakeRunConfiguration::~CMakeRunConfiguration() { } void CMakeRunConfiguration::ctor() { setDefaultDisplayName(defaultDisplayName()); } QString CMakeRunConfiguration::executable() const { return m_buildTarget; } ProjectExplorer::LocalApplicationRunConfiguration::RunMode CMakeRunConfiguration::runMode() const { return m_runMode; } void CMakeRunConfiguration::setRunMode(RunMode runMode) { m_runMode = runMode; } QString CMakeRunConfiguration::workingDirectory() const { ProjectExplorer::EnvironmentAspect *aspect = extraAspect(); QTC_ASSERT(aspect, return QString()); return QDir::cleanPath(aspect->environment().expandVariables( Utils::expandMacros(baseWorkingDirectory(), macroExpander()))); } QString CMakeRunConfiguration::baseWorkingDirectory() const { if (!m_userWorkingDirectory.isEmpty()) return m_userWorkingDirectory; return m_workingDirectory; } QString CMakeRunConfiguration::commandLineArguments() const { return Utils::QtcProcess::expandMacros(m_arguments, macroExpander()); } QString CMakeRunConfiguration::title() const { return m_title; } void CMakeRunConfiguration::setExecutable(const QString &executable) { m_buildTarget = executable; } void CMakeRunConfiguration::setBaseWorkingDirectory(const QString &wd) { const QString &oldWorkingDirectory = workingDirectory(); m_workingDirectory = wd; const QString &newWorkingDirectory = workingDirectory(); if (oldWorkingDirectory != newWorkingDirectory) emit baseWorkingDirectoryChanged(newWorkingDirectory); } void CMakeRunConfiguration::setUserWorkingDirectory(const QString &wd) { const QString & oldWorkingDirectory = workingDirectory(); m_userWorkingDirectory = wd; const QString &newWorkingDirectory = workingDirectory(); if (oldWorkingDirectory != newWorkingDirectory) emit baseWorkingDirectoryChanged(newWorkingDirectory); } QVariantMap CMakeRunConfiguration::toMap() const { QVariantMap map(ProjectExplorer::LocalApplicationRunConfiguration::toMap()); map.insert(QLatin1String(USER_WORKING_DIRECTORY_KEY), m_userWorkingDirectory); map.insert(QLatin1String(USE_TERMINAL_KEY), m_runMode == Console); map.insert(QLatin1String(TITLE_KEY), m_title); map.insert(QLatin1String(ARGUMENTS_KEY), m_arguments); return map; } bool CMakeRunConfiguration::fromMap(const QVariantMap &map) { m_userWorkingDirectory = map.value(QLatin1String(USER_WORKING_DIRECTORY_KEY)).toString(); m_runMode = map.value(QLatin1String(USE_TERMINAL_KEY)).toBool() ? Console : Gui; m_title = map.value(QLatin1String(TITLE_KEY)).toString(); m_arguments = map.value(QLatin1String(ARGUMENTS_KEY)).toString(); return RunConfiguration::fromMap(map); } QString CMakeRunConfiguration::defaultDisplayName() const { if (m_title.isEmpty()) return tr("Run CMake kit"); QString result = m_title; if (!m_enabled) { result += QLatin1Char(' '); result += tr("(disabled)"); } return result; } QWidget *CMakeRunConfiguration::createConfigurationWidget() { return new CMakeRunConfigurationWidget(this); } void CMakeRunConfiguration::setCommandLineArguments(const QString &newText) { m_arguments = newText; } QString CMakeRunConfiguration::dumperLibrary() const { return QtSupport::QtKitInformation::dumperLibrary(target()->kit()); } QStringList CMakeRunConfiguration::dumperLibraryLocations() const { return QtSupport::QtKitInformation::dumperLibraryLocations(target()->kit()); } void CMakeRunConfiguration::setEnabled(bool b) { if (m_enabled == b) return; m_enabled = b; emit enabledChanged(); setDefaultDisplayName(defaultDisplayName()); } bool CMakeRunConfiguration::isEnabled() const { return m_enabled; } QString CMakeRunConfiguration::disabledReason() const { if (!m_enabled) return tr("The executable is not built by the current build configuration"); return QString(); } // Configuration widget CMakeRunConfigurationWidget::CMakeRunConfigurationWidget(CMakeRunConfiguration *cmakeRunConfiguration, QWidget *parent) : QWidget(parent), m_ignoreChange(false), m_cmakeRunConfiguration(cmakeRunConfiguration) { QFormLayout *fl = new QFormLayout(); fl->setMargin(0); fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); QLineEdit *argumentsLineEdit = new QLineEdit(); argumentsLineEdit->setText(cmakeRunConfiguration->commandLineArguments()); connect(argumentsLineEdit, SIGNAL(textChanged(QString)), this, SLOT(setArguments(QString))); fl->addRow(tr("Arguments:"), argumentsLineEdit); m_workingDirectoryEdit = new Utils::PathChooser(); m_workingDirectoryEdit->setExpectedKind(Utils::PathChooser::Directory); m_workingDirectoryEdit->setBaseDirectory(m_cmakeRunConfiguration->target()->project()->projectDirectory()); m_workingDirectoryEdit->setPath(m_cmakeRunConfiguration->baseWorkingDirectory()); ProjectExplorer::EnvironmentAspect *aspect = m_cmakeRunConfiguration->extraAspect(); if (aspect) { connect(aspect, SIGNAL(environmentChanged()), this, SLOT(environmentWasChanged())); environmentWasChanged(); } m_workingDirectoryEdit->setPromptDialogTitle(tr("Select Working Directory")); QToolButton *resetButton = new QToolButton(); resetButton->setToolTip(tr("Reset to default")); resetButton->setIcon(QIcon(QLatin1String(Core::Constants::ICON_RESET))); QHBoxLayout *boxlayout = new QHBoxLayout(); boxlayout->addWidget(m_workingDirectoryEdit); boxlayout->addWidget(resetButton); fl->addRow(tr("Working directory:"), boxlayout); QCheckBox *runInTerminal = new QCheckBox; fl->addRow(tr("Run in Terminal"), runInTerminal); m_detailsContainer = new Utils::DetailsWidget(this); m_detailsContainer->setState(Utils::DetailsWidget::NoSummary); QWidget *m_details = new QWidget(m_detailsContainer); m_detailsContainer->setWidget(m_details); m_details->setLayout(fl); QVBoxLayout *vbx = new QVBoxLayout(this); vbx->setMargin(0); vbx->addWidget(m_detailsContainer); connect(m_workingDirectoryEdit, SIGNAL(changed(QString)), this, SLOT(setWorkingDirectory())); connect(resetButton, SIGNAL(clicked()), this, SLOT(resetWorkingDirectory())); connect(runInTerminal, SIGNAL(toggled(bool)), this, SLOT(runInTerminalToggled(bool))); connect(m_cmakeRunConfiguration, SIGNAL(baseWorkingDirectoryChanged(QString)), this, SLOT(workingDirectoryChanged(QString))); setEnabled(m_cmakeRunConfiguration->isEnabled()); } void CMakeRunConfigurationWidget::setWorkingDirectory() { if (m_ignoreChange) return; m_ignoreChange = true; m_cmakeRunConfiguration->setUserWorkingDirectory(m_workingDirectoryEdit->rawPath()); m_ignoreChange = false; } void CMakeRunConfigurationWidget::workingDirectoryChanged(const QString &workingDirectory) { if (!m_ignoreChange) { m_ignoreChange = true; m_workingDirectoryEdit->setPath(workingDirectory); m_ignoreChange = false; } } void CMakeRunConfigurationWidget::resetWorkingDirectory() { // This emits a signal connected to workingDirectoryChanged() // that sets the m_workingDirectoryEdit m_cmakeRunConfiguration->setUserWorkingDirectory(QString()); } void CMakeRunConfigurationWidget::runInTerminalToggled(bool toggled) { m_cmakeRunConfiguration->setRunMode(toggled ? ProjectExplorer::LocalApplicationRunConfiguration::Console : ProjectExplorer::LocalApplicationRunConfiguration::Gui); } void CMakeRunConfigurationWidget::environmentWasChanged() { ProjectExplorer::EnvironmentAspect *aspect = m_cmakeRunConfiguration->extraAspect(); QTC_ASSERT(aspect, return); m_workingDirectoryEdit->setEnvironment(aspect->environment()); } void CMakeRunConfigurationWidget::setArguments(const QString &args) { m_cmakeRunConfiguration->setCommandLineArguments(args); } // Factory CMakeRunConfigurationFactory::CMakeRunConfigurationFactory(QObject *parent) : ProjectExplorer::IRunConfigurationFactory(parent) { setObjectName(QLatin1String("CMakeRunConfigurationFactory")); } CMakeRunConfigurationFactory::~CMakeRunConfigurationFactory() { } // used to show the list of possible additons to a project, returns a list of ids QList CMakeRunConfigurationFactory::availableCreationIds(ProjectExplorer::Target *parent) const { if (!canHandle(parent)) return QList(); CMakeProject *project = static_cast(parent->project()); QList allIds; foreach (const QString &buildTarget, project->buildTargetTitles(true)) allIds << idFromBuildTarget(buildTarget); return allIds; } // used to translate the ids to names to display to the user QString CMakeRunConfigurationFactory::displayNameForId(const Core::Id id) const { return buildTargetFromId(id); } bool CMakeRunConfigurationFactory::canHandle(ProjectExplorer::Target *parent) const { if (!parent->project()->supportsKit(parent->kit())) return false; return qobject_cast(parent->project()); } bool CMakeRunConfigurationFactory::canCreate(ProjectExplorer::Target *parent, const Core::Id id) const { if (!canHandle(parent)) return false; CMakeProject *project = static_cast(parent->project()); return project->hasBuildTarget(buildTargetFromId(id)); } ProjectExplorer::RunConfiguration *CMakeRunConfigurationFactory::doCreate(ProjectExplorer::Target *parent, const Core::Id id) { CMakeProject *project = static_cast(parent->project()); const QString title(buildTargetFromId(id)); const CMakeBuildTarget &ct = project->buildTargetForTitle(title); return new CMakeRunConfiguration(parent, id, ct.executable, ct.workingDirectory, ct.title); } bool CMakeRunConfigurationFactory::canClone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration *source) const { if (!canHandle(parent)) return false; return source->id().name().startsWith(CMAKE_RC_PREFIX); } ProjectExplorer::RunConfiguration *CMakeRunConfigurationFactory::clone(ProjectExplorer::Target *parent, ProjectExplorer::RunConfiguration * source) { if (!canClone(parent, source)) return 0; CMakeRunConfiguration *crc(static_cast(source)); return new CMakeRunConfiguration(parent, crc); } bool CMakeRunConfigurationFactory::canRestore(ProjectExplorer::Target *parent, const QVariantMap &map) const { if (!qobject_cast(parent->project())) return false; return ProjectExplorer::idFromMap(map).name().startsWith(CMAKE_RC_PREFIX); } ProjectExplorer::RunConfiguration *CMakeRunConfigurationFactory::doRestore(ProjectExplorer::Target *parent, const QVariantMap &map) { return new CMakeRunConfiguration(parent, ProjectExplorer::idFromMap(map), QString(), QString(), QString()); } QString CMakeRunConfigurationFactory::buildTargetFromId(Core::Id id) { return id.suffixAfter(CMAKE_RC_PREFIX); } Core::Id CMakeRunConfigurationFactory::idFromBuildTarget(const QString &target) { return Core::Id(CMAKE_RC_PREFIX).withSuffix(target); } qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakelocatorfilter.h0000644000015301777760000000414512323167666031323 0ustar pbusernogroup00000000000000/************************************************************************** ** ** Copyright (C) 2014 Kläralvdalens Datakonsult AB, a KDAB Group company. ** Contact: Kläralvdalens Datakonsult AB (info@kdab.com) ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKELOCATORFILTER_H #define CMAKELOCATORFILTER_H #include #include namespace CMakeProjectManager { namespace Internal { class CMakeLocatorFilter : public Locator::ILocatorFilter { Q_OBJECT public: CMakeLocatorFilter(); ~CMakeLocatorFilter(); QList matchesFor(QFutureInterface &future, const QString &entry); void accept(Locator::FilterEntry selection) const; void refresh(QFutureInterface &future); private slots: void slotProjectListUpdated(); }; } // namespace Internal } // namespace CMakeProjectManager #endif // CMAKELOCATORFILTER_H ././@LongLink0000000000000000000000000000014600000000000011216 Lustar 00000000000000qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/CMakeProjectManager.mimetypes.xmlqtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/CMakeProjectManager.mimetypes.xm0000644000015301777760000000046112323167666033460 0ustar pbusernogroup00000000000000 CMake Project file qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakebuildconfiguration.cpp0000644000015301777760000003670712323167675032705 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmakebuildconfiguration.h" #include "cmakebuildinfo.h" #include "cmakeproject.h" #include "cmakeprojectconstants.h" #include "cmaketoolmanager.h" #include "generatorinfo.h" #include #include #include #include #include #include #include #include #include #include using namespace CMakeProjectManager; using namespace Internal; namespace { const char USE_NINJA_KEY[] = "CMakeProjectManager.CMakeBuildConfiguration.UseNinja"; const char USER_ARGS_KEY[] = "CMakeProjectManager.CMakeBuildConfiguration.UserArguments"; } // namespace CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent) : BuildConfiguration(parent, Core::Id(Constants::CMAKE_BC_ID)), m_useNinja(false) { init(parent); } CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent, CMakeBuildConfiguration *source) : BuildConfiguration(parent, source), m_msvcVersion(source->m_msvcVersion), m_useNinja(false) { Q_ASSERT(parent); cloneSteps(source); connect(this,SIGNAL(argumentsChanged(QStringList)),this,SLOT(runCMake())); connect(this,SIGNAL(buildDirectoryChanged()),this,SLOT(runCMake())); connect(this,SIGNAL(useNinjaChanged(bool)),this,SLOT(cleanAndRunCMake())); } QVariantMap CMakeBuildConfiguration::toMap() const { QVariantMap map(ProjectExplorer::BuildConfiguration::toMap()); map.insert(QLatin1String(USE_NINJA_KEY), m_useNinja); if(m_arguments.size()) map.insert(QLatin1String(USER_ARGS_KEY),Utils::QtcProcess::joinArgs(m_arguments)); return map; } bool CMakeBuildConfiguration::fromMap(const QVariantMap &map) { if (!BuildConfiguration::fromMap(map)) return false; CMakeProject* project = static_cast(this->target()->project()); m_useNinja = map.value(QLatin1String(USE_NINJA_KEY), false).toBool(); if(map.contains(QLatin1String(USER_ARGS_KEY))) m_arguments = Utils::QtcProcess::splitArgs(map.value(QLatin1String(USER_ARGS_KEY)).toString()); /* * If this evaluates to true, it means there was a in source build before and * was cleaned out by the user. Instead of querying the user for some build * directory we just use the default one, the user can always change this if * he does not like it */ if(this->buildDirectory() == Utils::FileName::fromString(project->projectDirectory()) && !project->hasInSourceBuild()) { this->setBuildDirectory(Utils::FileName::fromString( CMakeProject::shadowBuildDirectory(project->projectFilePath() ,this->target()->kit() ,this->displayName()))); } return true; } void CMakeBuildConfiguration::setBuildDirectory(const Utils::FileName &directory) { if (directory == buildDirectory()) return; BuildConfiguration::setBuildDirectory(directory); } CMakeBuildConfiguration::CMakeBuildConfiguration(ProjectExplorer::Target *parent, const Core::Id &id) : BuildConfiguration(parent,id), m_useNinja(false) { init(parent); } void CMakeBuildConfiguration::cleanAndRunCMake() { QDir dir(buildDirectory().toString()); dir.removeRecursively(); runCMake(); } void CMakeBuildConfiguration::runCMake() { ICMakeTool* cmake = CMakeToolManager::cmakeToolForKit(target()->kit()); cmake->runCMake(target()); connect(cmake,SIGNAL(cmakeFinished(ProjectExplorer::Target*)),this,SLOT(parseCMakeLists(ProjectExplorer::Target*)),Qt::UniqueConnection); } void CMakeBuildConfiguration::init(ProjectExplorer::Target *parent) { CMakeProject *project = static_cast(parent->project()); setBuildDirectory(Utils::FileName::fromString(project->shadowBuildDirectory(project->projectFilePath(), parent->kit(), displayName()))); connect(this,SIGNAL(argumentsChanged(QStringList)),this,SLOT(runCMake())); connect(this,SIGNAL(buildDirectoryChanged()),this,SLOT(runCMake())); connect(this,SIGNAL(useNinjaChanged(bool)),this,SLOT(cleanAndRunCMake())); } bool CMakeBuildConfiguration::useNinja() const { return m_useNinja; } void CMakeBuildConfiguration::setUseNinja(bool useNninja) { if (m_useNinja != useNninja) { m_useNinja = useNninja; emit useNinjaChanged(m_useNinja); } } QStringList CMakeBuildConfiguration::arguments() const { return m_arguments; } void CMakeBuildConfiguration::setArguments(const QStringList &args) { m_arguments = args; emit argumentsChanged(m_arguments); } QByteArray CMakeBuildConfiguration::generator() const { return cachedGeneratorFromFile(buildDirectory().toString() + QLatin1String("/CMakeCache.txt")); } CMakeBuildConfiguration::~CMakeBuildConfiguration() { } ProjectExplorer::NamedWidget *CMakeBuildConfiguration::createConfigWidget() { return new CMakeBuildSettingsWidget(this); } QByteArray CMakeBuildConfiguration::cachedGeneratorFromFile(const QString &cache) { QFile fi(cache); if (fi.exists()) { // Cache exists, then read it... if (fi.open(QIODevice::ReadOnly | QIODevice::Text)) { while (!fi.atEnd()) { QByteArray line = fi.readLine(); if (line.startsWith("CMAKE_GENERATOR:INTERNAL=")) { int splitpos = line.indexOf('='); if (splitpos != -1) { QByteArray cachedGenerator = line.mid(splitpos + 1).trimmed(); if (!cachedGenerator.isEmpty()) return cachedGenerator; } } } } } return QByteArray(); } /*! \class CMakeBuildConfigurationFactory */ CMakeBuildConfigurationFactory::CMakeBuildConfigurationFactory(QObject *parent) : ProjectExplorer::IBuildConfigurationFactory(parent) { } CMakeBuildConfigurationFactory::~CMakeBuildConfigurationFactory() { } int CMakeBuildConfigurationFactory::priority(const ProjectExplorer::Target *parent) const { return canHandle(parent) ? 0 : -1; } QList CMakeBuildConfigurationFactory::availableBuilds(const ProjectExplorer::Target *parent) const { QList result; CMakeBuildInfo *info = createBuildInfo(parent->kit(), parent->project()->projectDirectory()); info->buildDirectory = Utils::FileName::fromString(CMakeProject::shadowBuildDirectory(parent->project()->projectFilePath(), parent->kit(), info->displayName)); result << info; return result; } int CMakeBuildConfigurationFactory::priority(const ProjectExplorer::Kit *k, const QString &projectPath) const { return (k && Core::MimeDatabase::findByFile(QFileInfo(projectPath)) .matchesType(QLatin1String(Constants::CMAKEMIMETYPE))) ? 0 : -1; } QList CMakeBuildConfigurationFactory::availableSetups(const ProjectExplorer::Kit *k, const QString &projectPath) const { QList result; CMakeBuildInfo *info = createBuildInfo(k, ProjectExplorer::Project::projectDirectory(projectPath)); //: The name of the build configuration created by default for a cmake project. info->displayName = tr("Default"); info->buildDirectory = Utils::FileName::fromString(CMakeProject::shadowBuildDirectory(projectPath,k, info->displayName)); result << info; return result; } ProjectExplorer::BuildConfiguration *CMakeBuildConfigurationFactory::create(ProjectExplorer::Target *parent, const ProjectExplorer::BuildInfo *info) const { QTC_ASSERT(info->factory() == this, return 0); QTC_ASSERT(info->kitId == parent->kit()->id(), return 0); QTC_ASSERT(!info->displayName.isEmpty(), return 0); CMakeBuildInfo copy(*static_cast(info)); CMakeProject *project = static_cast(parent->project()); if (copy.buildDirectory.isEmpty()) copy.buildDirectory = Utils::FileName::fromString(project->shadowBuildDirectory(project->projectFilePath(), parent->kit(), copy.displayName)); CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(parent); bc->setDisplayName(copy.displayName); bc->setDefaultDisplayName(copy.displayName); ProjectExplorer::BuildStepList *buildSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); ProjectExplorer::BuildStepList *cleanSteps = bc->stepList(ProjectExplorer::Constants::BUILDSTEPS_CLEAN); MakeStep *makeStep = new MakeStep(buildSteps); buildSteps->insertStep(0, makeStep); MakeStep *cleanMakeStep = new MakeStep(cleanSteps); cleanSteps->insertStep(0, cleanMakeStep); cleanMakeStep->setAdditionalArguments(QLatin1String("clean")); cleanMakeStep->setClean(true); bc->setBuildDirectory(Utils::FileName::fromString(copy.buildDirectory.toString())); bc->setUseNinja(copy.useNinja); // Default to all if (project->hasBuildTarget(QLatin1String("all"))) makeStep->setBuildTarget(QLatin1String("all"), true); return bc; } bool CMakeBuildConfigurationFactory::canClone(const ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source) const { if (!canHandle(parent)) return false; return source->id() == Constants::CMAKE_BC_ID; } CMakeBuildConfiguration *CMakeBuildConfigurationFactory::clone(ProjectExplorer::Target *parent, ProjectExplorer::BuildConfiguration *source) { if (!canClone(parent, source)) return 0; CMakeBuildConfiguration *old = static_cast(source); return new CMakeBuildConfiguration(parent, old); } bool CMakeBuildConfigurationFactory::canRestore(const ProjectExplorer::Target *parent, const QVariantMap &map) const { if (!canHandle(parent)) return false; return ProjectExplorer::idFromMap(map) == Constants::CMAKE_BC_ID; } CMakeBuildConfiguration *CMakeBuildConfigurationFactory::restore(ProjectExplorer::Target *parent, const QVariantMap &map) { if (!canRestore(parent, map)) return 0; CMakeBuildConfiguration *bc = new CMakeBuildConfiguration(parent); if (bc->fromMap(map)) return bc; delete bc; return 0; } bool CMakeBuildConfigurationFactory::canHandle(const ProjectExplorer::Target *t) const { QTC_ASSERT(t, return false); if (!t->project()->supportsKit(t->kit())) return false; return qobject_cast(t->project()); } CMakeBuildInfo *CMakeBuildConfigurationFactory::createBuildInfo(const ProjectExplorer::Kit *k, const QString &sourceDir) const { //this is safe, because the kit will not be changed and the generator not used outside this function ProjectExplorer::Kit* otherK = const_cast(k); CMakeManager *manager = ExtensionSystem::PluginManager::getObject(); Q_ASSERT(manager); ICMakeTool* cmake = CMakeToolManager::cmakeToolForKit(k); if(!cmake) return 0; //there should always be a generator when we reach this stage QList generators = GeneratorInfo::generatorInfosFor(otherK ,GeneratorInfo::OfferNinja ,manager->preferNinja() ,cmake->hasCodeBlocksMsvcGenerator()); CMakeBuildInfo *info = new CMakeBuildInfo(this); info->typeName = tr("Build"); info->kitId = k->id(); info->environment = Utils::Environment::systemEnvironment(); k->addToEnvironment(info->environment); info->sourceDirectory = sourceDir; info->supportsShadowBuild = !CMakeProject::hasInSourceBuild(info->sourceDirectory); //if the first generator is ninja, that is the preferred one info->useNinja = (generators.size() > 0) ? generators.first().isNinja() : false; return info; } ProjectExplorer::BuildConfiguration::BuildType CMakeBuildConfiguration::buildType() const { QString cmakeBuildType; QFile cmakeCache(buildDirectory().toString() + QLatin1String("/CMakeCache.txt")); if (cmakeCache.open(QIODevice::ReadOnly)) { while (!cmakeCache.atEnd()) { QByteArray line = cmakeCache.readLine(); if (line.startsWith("CMAKE_BUILD_TYPE")) { if (int pos = line.indexOf('=')) cmakeBuildType = QString::fromLocal8Bit(line.mid(pos + 1).trimmed()); break; } } cmakeCache.close(); } // Cover all common CMake build types if (cmakeBuildType.compare(QLatin1String("Release"), Qt::CaseInsensitive) == 0 || cmakeBuildType.compare(QLatin1String("MinSizeRel"), Qt::CaseInsensitive) == 0) { return Release; } else if (cmakeBuildType.compare(QLatin1String("Debug"), Qt::CaseInsensitive) == 0 || cmakeBuildType.compare(QLatin1String("DebugFull"), Qt::CaseInsensitive) == 0 || cmakeBuildType.compare(QLatin1String("RelWithDebInfo"), Qt::CaseInsensitive) == 0) { return Debug; } return Unknown; } qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakeprojectnodes.h0000644000015301777760000000521012323167666031143 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEPROJECTNODE_H #define CMAKEPROJECTNODE_H #include namespace CMakeProjectManager { namespace Internal { class CMakeProjectNode : public ProjectExplorer::ProjectNode { Q_OBJECT friend class CMakeProject; public: CMakeProjectNode(const QString &fileName); virtual bool hasBuildTargets() const; virtual QList supportedActions(Node *node) const; virtual bool canAddSubProject(const QString &proFilePath) const; virtual bool addSubProjects(const QStringList &proFilePaths); virtual bool removeSubProjects(const QStringList &proFilePaths); virtual bool addFiles( const QStringList &filePaths, QStringList *notAdded = 0); virtual bool removeFiles(const QStringList &filePaths, QStringList *notRemoved = 0); virtual bool deleteFiles(const QStringList &filePaths); virtual bool renameFile(const QString &filePath, const QString &newFilePath); virtual QList runConfigurationsFor(Node *node); }; } // namespace Internal } // namespace CMakeProjectManager #endif // CMAKEPROJECTNODE_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakehighlighter.h0000644000015301777760000000432712323167666030752 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEHIGHLIGHTER_H #define CMAKEHIGHLIGHTER_H #include namespace CMakeProjectManager { namespace Internal { /* This is a simple syntax highlighter for CMake files. * It highlights variables, commands, strings and comments. * Multi-line strings and variables inside strings are also recognized. */ class CMakeHighlighter : public TextEditor::SyntaxHighlighter { Q_OBJECT public: enum CMakeFormats { CMakeVariableFormat, CMakeFunctionFormat, CMakeCommentFormat, CMakeStringFormat, CMakeVisualWhiteSpaceFormat }; CMakeHighlighter(QTextDocument *document = 0); virtual void highlightBlock(const QString &text); }; } // namespace Internal } // namespace CMakeProjectManager #endif // PROFILEHIGHLIGHTER_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakehighlighterfactory.h0000644000015301777760000000357712323167666032350 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEHIGHLIGHTERFACTORY_H #define CMAKEHIGHLIGHTERFACTORY_H #include namespace CMakeProjectManager { namespace Internal { class CMakeHighlighterFactory : public TextEditor::IHighlighterFactory { Q_OBJECT public: CMakeHighlighterFactory(); virtual TextEditor::SyntaxHighlighter *createHighlighter() const; }; } // namespace Internal } // namespace CMakeProjectManager #endif // CMAKEHIGHLIGHTERFACTORY_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakehighlighterfactory.cpp0000644000015301777760000000356012323167666032673 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmakehighlighterfactory.h" #include "cmakeprojectconstants.h" #include "cmakehighlighter.h" using namespace CMakeProjectManager::Internal; CMakeHighlighterFactory::CMakeHighlighterFactory() { setId(CMakeProjectManager::Constants::CMAKE_EDITOR_ID); addMimeType(CMakeProjectManager::Constants::CMAKEMIMETYPE); } TextEditor::SyntaxHighlighter *CMakeHighlighterFactory::createHighlighter() const { return new CMakeHighlighter; } qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/argumentslineedit.h0000644000015301777760000000373512323167666031200 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKEPROJECTMANAGER_ARGUMENTSLINEEDIT_H #define CMAKEPROJECTMANAGER_ARGUMENTSLINEEDIT_H #include "cmakeprojectmanager_global.h" #include namespace CMakeProjectManager { class CMAKEPROJECTMANAGER_EXPORT ArgumentsLineEdit : public Utils::BaseValidatingLineEdit { Q_OBJECT public: explicit ArgumentsLineEdit(QWidget* parent = 0); protected: virtual bool validate(const QString &value, QString *errorMessage) const; }; } // namespace CMakeProjectManager #endif // CMAKEPROJECTMANAGER_ARGUMENTSLINEEDIT_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmakesettingspage.cpp0000644000015301777760000001142612323167666031502 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #include "cmakesettingspage.h" #include "cmaketoolmanager.h" #include #include #include #include #include namespace CMakeProjectManager { namespace Internal { ///// // CMakeSettingsPage //// CMakeSettingsPage::CMakeSettingsPage() : m_pathchooser(0), m_preferNinja(0) { setId("Z.CMake"); setDisplayName(tr("CMake")); setCategory(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY); setDisplayCategory(QCoreApplication::translate("ProjectExplorer", ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_TR_CATEGORY)); setCategoryIcon(QLatin1String(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY_ICON)); } bool CMakeSettingsPage::isCMakeExecutableValid() const { return CMakeToolManager::defaultCMakeTool()->isValid(); } CMakeSettingsPage::~CMakeSettingsPage() { } QString CMakeSettingsPage::findCmakeExecutable() const { return Utils::Environment::systemEnvironment().searchInPath(QLatin1String("cmake")); } QWidget *CMakeSettingsPage::createPage(QWidget *parent) { QWidget *outerWidget = new QWidget(parent); QFormLayout *formLayout = new QFormLayout(outerWidget); formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); m_pathchooser = new Utils::PathChooser; m_pathchooser->setExpectedKind(Utils::PathChooser::ExistingCommand); formLayout->addRow(tr("Executable:"), m_pathchooser); formLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding)); m_pathchooser->setPath(CMakeToolManager::userCMakePath()); m_preferNinja = new QCheckBox(tr("Prefer Ninja generator (CMake 2.8.9 or higher required)")); m_preferNinja->setChecked(preferNinja()); formLayout->addRow(m_preferNinja); return outerWidget; } void CMakeSettingsPage::saveSettings() const { QSettings *settings = Core::ICore::settings(); settings->beginGroup(QLatin1String("CMakeSettings")); settings->setValue(QLatin1String("cmakeExecutable"), CMakeToolManager::userCMakePath()); settings->setValue(QLatin1String("preferNinja"), m_preferNinja->isChecked()); settings->endGroup(); } void CMakeSettingsPage::apply() { if (!m_pathchooser) // page was never shown return; if (CMakeToolManager::userCMakePath() != m_pathchooser->path()) CMakeToolManager::setUserCmakePath(m_pathchooser->path()); saveSettings(); } void CMakeSettingsPage::finish() { } bool CMakeSettingsPage::hasCodeBlocksMsvcGenerator() const { return CMakeToolManager::defaultCMakeTool()->hasCodeBlocksMsvcGenerator(); } bool CMakeSettingsPage::hasCodeBlocksNinjaGenerator() const { return CMakeToolManager::defaultCMakeTool()->hasCodeBlocksNinjaGenerator(); } bool CMakeSettingsPage::preferNinja() const { QSettings *settings = Core::ICore::settings(); settings->beginGroup(QLatin1String("CMakeSettings")); const bool r = settings->value(QLatin1String("preferNinja"), false).toBool(); settings->endGroup(); return r; } TextEditor::Keywords CMakeSettingsPage::keywords() { ICMakeTool* defTool = CMakeToolManager::defaultCMakeTool(); if(defTool->isValid()) return defTool->keywords(); return TextEditor::Keywords(QStringList(), QStringList(), QMap()); } } // namespace Internal } // namespace CMakeProjectManager qtcreator-plugin-cmake-3.0.1+14.04.20140415/src/cmakeprojectmanager/cmaketool.h0000644000015301777760000001074212323167675027427 0ustar pbusernogroup00000000000000/**************************************************************************** ** ** Copyright (C) 2014 Canonical Ltd. ** Contact: http://www.qt-project.org/legal ** ** This file is part of Qt Creator. ** ** 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. ** ** GNU Lesser General Public License Usage ** 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 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. ** ****************************************************************************/ #ifndef CMAKETOOL_H #define CMAKETOOL_H #include "cmakeprojectmanager_global.h" #include #include #include #include #include #include #include #include #include namespace Utils { class QtcProcess; } namespace CMakeProjectManager { class CMAKEPROJECTMANAGER_EXPORT ICMakeTool: public QObject { Q_OBJECT public: ICMakeTool(QObject * parent); virtual ~ICMakeTool(); virtual void cancel() = 0; virtual QString displayName () = 0; virtual bool isValid() const = 0; virtual bool hasCodeBlocksMsvcGenerator() const = 0; virtual bool hasCodeBlocksNinjaGenerator() const = 0; virtual TextEditor::Keywords keywords() = 0; virtual void runCMake (ProjectExplorer::Target* target) = 0; virtual void addToEnvironment(Utils::Environment &env) const; Core::Id id() const { return m_id; } signals: void cmakeFinished (ProjectExplorer::Target* target); protected: void setId(Core::Id id) { m_id = id; } private: Core::Id m_id; }; class CMAKEPROJECTMANAGER_EXPORT ICMakeToolFactory : public QObject { Q_OBJECT public: virtual bool canCreate (const Core::Id& id) const = 0; virtual ICMakeTool* create (const Core::Id& id) = 0; }; class CMAKEPROJECTMANAGER_EXPORT CMakeTool : public ICMakeTool { Q_OBJECT public: explicit CMakeTool(QObject *parent = 0); virtual ~CMakeTool(); enum State { Invalid, RunningBasic, RunningFunctionList, RunningFunctionDetails, RunningPropertyList, RunningVariableList, RunningDone, RunningProject }; bool isValid() const; void setCMakeExecutable(const QString &executable); QString cmakeExecutable() const; bool hasCodeBlocksMsvcGenerator() const; bool hasCodeBlocksNinjaGenerator() const; TextEditor::Keywords keywords(); virtual void runCMake (ProjectExplorer::Target *target ); virtual QString displayName (); public slots: void cancel(); protected: void startNextRun (); private slots: void finished(int exitCode); void onProcessReadyRead(); private: void flushOutput(); void finishStep(); void createProcessIfNotExists(); bool startProcess(const QStringList &args, Utils::Environment env = Utils::Environment::systemEnvironment()); void parseFunctionOutput(const QByteArray &output); void parseFunctionDetailsOutput(const QByteArray &output); void parseVariableOutput(const QByteArray &output); void parseDone(); QString formatFunctionDetails(const QString &command, const QString &args); State m_state; Utils::QtcProcess *m_process; bool m_hasCodeBlocksMsvcGenerator; bool m_hasCodeBlocksNinjaGenerator; QString m_executable; QMap m_functionArgs; QStringList m_variables; QStringList m_functions; QQueue< QPointer > m_pendingRuns; QPointer m_currentRun; QFutureInterface *m_futureInterface; }; } #endif // CMAKETOOL_H qtcreator-plugin-cmake-3.0.1+14.04.20140415/qtcreator-plugin-cmake.pro0000644000015301777760000000006712323167666025606 0ustar pbusernogroup00000000000000TEMPLATE = subdirs SUBDIRS = src/cmakeprojectmanager qtcreator-plugin-cmake-3.0.1+14.04.20140415/share/0000755000015301777760000000000012323170262021567 5ustar pbusernogroup00000000000000qtcreator-plugin-cmake-3.0.1+14.04.20140415/share/qtcreator/0000755000015301777760000000000012323170262023573 5ustar pbusernogroup00000000000000qtcreator-plugin-cmake-3.0.1+14.04.20140415/share/qtcreator/templates/0000755000015301777760000000000012323170262025571 5ustar pbusernogroup00000000000000qtcreator-plugin-cmake-3.0.1+14.04.20140415/share/qtcreator/templates/wizards/0000755000015301777760000000000012323170262027254 5ustar pbusernogroup00000000000000qtcreator-plugin-cmake-3.0.1+14.04.20140415/share/qtcreator/templates/wizards/plaincppapp/0000755000015301777760000000000012323170262031563 5ustar pbusernogroup00000000000000qtcreator-plugin-cmake-3.0.1+14.04.20140415/share/qtcreator/templates/wizards/plaincppapp/cmake/0000755000015301777760000000000012323170262032643 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015400000000000011215 Lustar 00000000000000qtcreator-plugin-cmake-3.0.1+14.04.20140415/share/qtcreator/templates/wizards/plaincppapp/cmake/console.pngqtcreator-plugin-cmake-3.0.1+14.04.20140415/share/qtcreator/templates/wizards/plaincppapp/cmake/cons0000644000015301777760000000106712323167666033552 0ustar pbusernogroup00000000000000PNG  IHDR szzbKGD pHYs  tIME 0*tEXtCommentCreated with The GIMPd%nIDATx헽jAϬCػŰ [Vjk #/N+!RX``b1ŸC |ܹ3anE@*\4}VyO& `p)-i9?PJ!b-s,R|=S#AL|ơk:ua6 D,+3ķ-wQ~)ka>RJ console.png Creates a plain C++ project using CMake, not using the Qt library. Plain C++ Project (Ubuntu CMake Build); Non-Qt Project ././@LongLink0000000000000000000000000000015100000000000011212 Lustar 00000000000000qtcreator-plugin-cmake-3.0.1+14.04.20140415/share/qtcreator/templates/wizards/plaincppapp/cmake/main.cppqtcreator-plugin-cmake-3.0.1+14.04.20140415/share/qtcreator/templates/wizards/plaincppapp/cmake/main0000644000015301777760000000015412323167666033530 0ustar pbusernogroup00000000000000#include using namespace std; int main() { cout << "Hello World!" << endl; return 0; } ././@LongLink0000000000000000000000000000015700000000000011220 Lustar 00000000000000qtcreator-plugin-cmake-3.0.1+14.04.20140415/share/qtcreator/templates/wizards/plaincppapp/cmake/CMakeLists.txtqtcreator-plugin-cmake-3.0.1+14.04.20140415/share/qtcreator/templates/wizards/plaincppapp/cmake/CMak0000644000015301777760000000021012323167666033410 0ustar pbusernogroup00000000000000project(%ProjectName%) cmake_minimum_required(VERSION 2.8) aux_source_directory(. SRC_LIST) add_executable(${PROJECT_NAME} ${SRC_LIST}) qtcreator-plugin-cmake-3.0.1+14.04.20140415/share/qtcreator/templates/wizards/plaincapp/0000755000015301777760000000000012323170262031223 5ustar pbusernogroup00000000000000qtcreator-plugin-cmake-3.0.1+14.04.20140415/share/qtcreator/templates/wizards/plaincapp/cmake/0000755000015301777760000000000012323170262032303 5ustar pbusernogroup00000000000000././@LongLink0000000000000000000000000000015200000000000011213 Lustar 00000000000000qtcreator-plugin-cmake-3.0.1+14.04.20140415/share/qtcreator/templates/wizards/plaincapp/cmake/console.pngqtcreator-plugin-cmake-3.0.1+14.04.20140415/share/qtcreator/templates/wizards/plaincapp/cmake/consol0000644000015301777760000000106712323167666033545 0ustar pbusernogroup00000000000000PNG  IHDR szzbKGD pHYs  tIME 0*tEXtCommentCreated with The GIMPd%nIDATx헽jAϬCػŰ [Vjk #/N+!RX``b1ŸC |ܹ3anE@*\4}VyO& `p)-i9?PJ!b-s,R|=S#AL|ơk:ua6 D,+3ķ-wQ~)ka>RJ console.png Creates a plain C project using CMake, not using the Qt library. Plain C Project (Ubuntu CMake Build); Non-Qt Project qtcreator-plugin-cmake-3.0.1+14.04.20140415/share/qtcreator/templates/wizards/plaincapp/cmake/main.c0000644000015301777760000000012312323167666033405 0ustar pbusernogroup00000000000000#include int main(void) { printf("Hello World!\n"); return 0; } ././@LongLink0000000000000000000000000000015500000000000011216 Lustar 00000000000000qtcreator-plugin-cmake-3.0.1+14.04.20140415/share/qtcreator/templates/wizards/plaincapp/cmake/CMakeLists.txtqtcreator-plugin-cmake-3.0.1+14.04.20140415/share/qtcreator/templates/wizards/plaincapp/cmake/CMakeL0000644000015301777760000000021012323167666033331 0ustar pbusernogroup00000000000000project(%ProjectName%) cmake_minimum_required(VERSION 2.8) aux_source_directory(. SRC_LIST) add_executable(${PROJECT_NAME} ${SRC_LIST})