📜 ⬆️ ⬇️

CMakeProjectManager2: a bit of convenience when working with CMake in Qt Creator

Good afternoon,

CMakeProjectManager2 is a fork of the original Qt Creator plugin to support the CMake build system. The sluggish history of this project has been going on since 2011 (my first blog post: htrd.su/wiki/zhurnal/2011-03-24_14.49_qt_creator_i_cmake_-_prodolzhenie , second update from 2012: htrd.su/wiki/zhurnal/2012/ 10/17 / cmakeprojectmanager2 _-_ poslednie_izmenenija ). Since then, nothing new has been added. Compatibility with the latest versions of Qt Creator was provided, the repository moved to GitHub (as an experiment).

But yesterday and today several more changes were added, which was the reason to mention the project on Habré.

So, the initial changes have added not so much functionality, namely:

At the same time, the idea of ​​adding support for parsing CMakeFiles.txt to the plugin, bypassing launching CMake and generating the .cbp file, came to the fore. But (looking ahead), this idea remained an idea: a parser and a tokenizer were written separately based on CMake source code, but the developments have sunk into oblivion along with the next screw collapse. Before integration into the plugin has not reached.
')
The second package of changes was added in 2012, included the following features and fixes:

Starting from this version, you can quite comfortably use CMake if the list of files is based on globing, i.e. if the list is given by mask, like this:
# UTILS file(GLOB_RECURSE UTIL_SOURCES "../util/*.cpp") file(GLOB_RECURSE UTIL_HEADERS "../util/*.h" "../util/*.hpp") 

When you add a file through Qt Creator, the cache is automatically updated and the file is seen in the tree, the build system and the C ++ parser.

Since then, the code base has only been synchronized with the upstream (in fact, there are no major changes relative to it). For the first version, an attempt was made to submit a merge request, but was hacked away because of the display of all the files, instead of those that are somehow written in CMakeLists.txt. After this attempt ceased. Those who want to push through part or all of the changes - well!

But it so happened that there was a need for cross-compiling CMake projects from the depths of Qt Creator. This is not difficult to do, it is enough to issue a Toolchain file ( more info) and pass it through a special parameter to the cmake process. It is inconvenient only to register the parameters by hand.

So there were changes which appeared today in a repository:

Yes, there are not many changes, but I think this is not important. It is important that it became a little more convenient and easier.

In fact, these parameters are used to set the parameters for CMake in a more friendly form: -DCMAKE_BUILD_TYPE = and -DCMAKE_TOOLCHAIN_FILE, respectively.

About tulchan a little more. Initially planned three ways to set it:

For now, the Qt Creator Kit-based option is turned off ( issue # 4 ).

Plus, there is a nuance: according to the CMake documentation, a change of the toolchain is possible only on a new configuration or on a full cleaning of the current one (delete CMakeFiles and CMakeCache.txt), therefore, if changes of the toolchain are noticed, a full reconfiguration is made without using a cache. I plan to add a dialog with a warning ( issue # 1 ).

It should be noted that the user input of parameters is saved, moreover, it is determined that if the parameter is already set, then the user input will be used.

Well, the picture, what it looks like:


If it seems useful to someone, I will be glad. Especially I will be glad to pull requests with fixing bugs and implementing new features. The reports are also good, but according to the development trend of the project you can understand: there is not much time for it, so the reaction can be from “slow” to “ooooochen slow”.

UPD / 2015-07-18 /: Made the PPA for Ubuntu 14.04 / Mint 17.x with QtC from git [master] and CMakeProjectManager2: launchpad.net/~adrozdoff/+archive/ubuntu/qtcreator-git

Source: https://habr.com/ru/post/248517/


All Articles