[Qt-creator] Missing files in CMake project. Or adding special source files.

Tobias Hunger Tobias.Hunger at qt.io
Thu May 9 12:13:08 CEST 2019

Hi Toralf,

On Thu, 2019-05-09 at 09:58 +0200, Toralf Lund wrote:
> I'm using qt-creator with a CMake project that, among other things, 
> contain some source files of somewhat uncommon types. One example is 
> "protobuf" message definitions, which use CMake functions listed in 
> https://cmake.org/cmake/help/v3.14/module/FindProtobuf.html, but there 
> are a few others, too.

Creator asks CMake for the files that are part of the current configuration and
then proceeds to manually add header files.

So I see two ways forward to improve the situation, but both require code:

1) CMake can be improved to more accurately report which files it will work on

2) Creator will just add any file to the project tree that cmake does not

The second one will probably work better in general.


>  I there anything I 
> can do to make the CMake project manager recognise "special" files that 
> are listed in the CMake config?

You could list them as sources. CMake tends to ignore most file types, so they
are safe to add as sources, but cmake will still report them.

>  Also, how about making manual additions 
> to the file list? The "obvious" functionality appears to be disabled for 
> CMake projects...

Like adding files into an existing CMake project?

IMHO functionality like that needs to be implemented in CMake itself. That is
the only place that can keep this functionality in a good working condition.
Trying to parse CMake syntax in creator is way too error prone for me to feel
comfortable doing.

Having said so: In theory Creator should have backtrace information, which
enables it to open a CMakeLists.txt file that is probably not entirely off. But
that information got removed from CMake server-mode again, so it is not
available right now. Maybe we will get it back when we move to CMake's latest
and greatest IDE integration based on files.

Best Regards,

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, Mika Harjuaho. Sitz der
Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB 144331 B

More information about the Qt-creator mailing list