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

Toralf Lund toralf.lund at pgs.com
Thu May 9 13:15:52 CEST 2019

On 09/05/2019 12:13, Tobias Hunger wrote:
> 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://urldefense.proofpoint.com/v2/url?u=https-3A__cmake.org_cmake_help_v3.14_module_FindProtobuf.html&d=DwIGaQ&c=KV_I7O14pmwRcmAVyJ1eg4Jwb8Y2JAxuL5YgMGHpjcQ&r=Q0oqxzgUp3xCCIiJDwS-RbNDndQ-KZDhj8wwveNoqU4&m=d69YKs4tyxCFijICIy5JKAHYnefRPj3-sf0d7kOfmDw&s=uGtEifvL0P4vFlyxErMRUpC03tYGJnad9mpzepw0es4&e=, 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.

OK. Do you know any way to check e.g. from the command line what exactly 
CMake will report back?

> 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
> handle.
> The second one will probably work better in general.


> <snip>
>>   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.

It's not clear to me what exactly you mean by that. Our "protobuf" files 
are mentioned already in that CMakeLists have statements like

    set(PROTO_INPUT MonitoringHeader.proto MessageHeader.proto

    protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_INPUT})

Doesn't that mean they are already listed as sources? Or are you 
referring to some other CMake mechanism?

>>   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?

No necessary. I'm also thinking about files that aren't being built or 
used as sources for build, but are kept with the project for some 
reason. One example might be documentation or config files that you want 
to include in software packages generated independently of cmake. The 
CMake project won't need to know about these, but it's convenient if Qt 
Creator is ready to edit them, so as to speak.

> 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.

Yeah, I fully agree with that.

> 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.


- Toralf

> Best Regards,
> Tobias

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20190509/39a88b52/attachment.html>

More information about the Qt-creator mailing list