[Qt-creator] Generating QtCreator cmake project for given CMakeLists.txt from command line

Hunger Tobias Tobias.Hunger at theqtcompany.com
Thu Mar 31 12:16:10 CEST 2016


Hi Nikolaus,

On Thu, Mar 31, 2016 at 9:59 AM, Nikolaus Demmel <nikolaus at nikolaus-demmel.de> wrote:
> Hi Tobias,
>
> thanks for trying it out.
>
> I think I made the wrong impression of what feature I am actually asking. It should be much simpler. :-)

I agree, it should be simpler.

> The catkin_tools workflow is currently supported quite well with qtcreator, given that catkin_tools creates more-or-less standard cmake build directories, one for each ROS package. So go ahead in your new ROS workspace after calling `catkin build`, open the CMakeLists.txt of one of the ROS packages in QtCreator as a project, then select one configuration and point the build directory to <ros-ws>/build/<ros-pkg-name>. Now you can call make from within QtCreator, rerun cmake, have code completion, click on warnings to get to the source location, use the debugger, etc. That is all great.

You actually should not even need to rerun cmake, provided you set up catkin to use the "-GCodeBlocks - Unix Makefiles" generator we need for Qt Creator. 

> The step that is inconvenient, which I was asking about in this thread, is the fact that for each ROS package, you have to manually select the correct build directory and Kit when opening the project. Since there can be many ROS packages in a workspace (>100), it gets cumbersome. That’s why I am looking for a way to generate the project file (CMakeLists.txt.user) from command line without user interaction. I want to be able to specify the build directory(s), and also the configuration(s)/Kit(s). For the latter it would be great if there was a “environment Kit”, which selects compiler/qmake/cmake in the same way that cmake would on the command line (in fact cmake has already been run from the initial `catkin build` call, so QtCreator could just ask cmake what compiler it configured, which would maybe be a sort of “cmake Kit”, where you let cmake run in the current environment determine the compiler).

My original idea was to use the default build directory setting (Tools>Options>Build & Run>General IIRC) and adapt that for catkin use. Opening the source directory should then automatically pick up the right build directory. I am not sure this is an option anymore, considering that there are way more directories in $WS/build than there are in $WS/src. I need to check how that mapping from $WS/src/something/other/CMakeLists.txt to $WS/build/somedirectory works to check if that is an option. If"somedirectory" is just the CMake project name, then that should be easily doable already. Considering that such a simplistic mapping would fail in fun ways when you end up with two projects in $WS/src/* sharing the same project name (but in a different filesystem location), I do not think that is what catkin actually does:-)

You would still need to set up the kits yourself then (we need the information there for the code model).

For Qt Creator 4.1 I would like to have a "import existing build" functionality (as we have for qmake-based projects), which will pick a kit based on an existing build directory (and create a new kit if none matches). That requires quite a bit of refactoring of the qmake import functionality so that I can re-use (part of) the code from there. That is why this did not make the cut for Qt Creator 4.0: It was just too late to start a big refactoring when I got round to implement that.

> Of course one could also think about integrating catkin_tools itself better into QtCreator (which is I think what you were talking about), but that is a completely different story and to me catkin_tools is so great from the command line, that I am happy continue using it there in conjunction with editing code in an IDE.

Oh, OK:-)

Best Regards,
Tobias

--
Tobias Hunger, Senior Software Engineer | The Qt Company

The Qt Company GmbH, Rudower Chaussee 13, D-12489 Berlin
Geschäftsführer: Mika Pälsi, Juha Varelius, Tuula Haataja Sitz der Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B


More information about the Qt-creator mailing list