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

Toralf Lund toralf.lund at pgs.com
Fri May 10 09:36:53 CEST 2019


On 10/05/2019 08:36, Eike Ziller wrote:
>
>> On 9. May 2019, at 16:10, Tobias Hunger <Tobias.Hunger at qt.io> wrote:
>>
>> Hi Toralf,
>>
>> On Thu, 2019-05-09 at 13:15 +0200, Toralf Lund wrote:
>>>>> 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.
>> target_sources(FooTarget PRIVATE ${PROTO_INPUT}) or something along those lines.
>>
>> This is of course provided that ${PROTO_INPUT} does not contain files that cmake
>> will mistake for real sources and actually try to build:-)
>>
>>> Our "protobuf" files
>>> are mentioned already in that CMakeLists have statements like
>>>
>>>     set(PROTO_INPUT MonitoringHeader.proto MessageHeader.proto
>>>     MetaHeader.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?
>> I would expect that function to set up some custom commands. Those will take
>> inputs and put their results into the sources. I would not be surprised if those
>> showed up in the project tree (maybe filtered away since the files are probably
>> marked as generated, check the funnel icon).
>>
>> The inputs on the other hand will probably not show up.
>>
>>>>>   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.
>> The idea behind Projects mode is to show the view the build system has of your
>> project. I think having such a view is valuable and having too many unrelated
>> files listed in it will reduce that value. Some exceptions are fine (e.g. header
>> files which often were completely missing when using cmake) of course, but I do
>> not want to make the tree to configurable.
>>
>> If you want a more filesystem based view on your sources, then just use the
>> filesystem view instead.
>>
>> If you want to navigate your sources, then check out the locator. Just hit ctrl-
>> K and start typing the file name, which is way faster than using the project
>> tree.
> Regarding locator you can also make all files from a custom directory tree available in Qt Creator. Click the magnifier icon > Configure (or open Options > Environment > Locator), Add...

That might help a bit. It would be better if you could link this to the 
open projects, though, so you didn't have edit the paths to what you are 
working in an extra place.

>
> There is also a suggestion to make the custom locator filters a bit more flexible https://urldefense.proofpoint.com/v2/url?u=https-3A__bugreports.qt.io_browse_QTCREATORBUG-2D21470&d=DwIGaQ&c=KV_I7O14pmwRcmAVyJ1eg4Jwb8Y2JAxuL5YgMGHpjcQ&r=Q0oqxzgUp3xCCIiJDwS-RbNDndQ-KZDhj8wwveNoqU4&m=ZUhRfaeds4IAVcgF7OUF-kOqpTO0uiHL0D9W3E7Tco8&s=uoJiqGaP3XQl2fcTtzFvcOZuy3SLGv4tBWQXORVmTE4&e= , possibly adding the root of the current project by default https://urldefense.proofpoint.com/v2/url?u=https-3A__bugreports.qt.io_browse_QTCREATORBUG-2D19122&d=DwIGaQ&c=KV_I7O14pmwRcmAVyJ1eg4Jwb8Y2JAxuL5YgMGHpjcQ&r=Q0oqxzgUp3xCCIiJDwS-RbNDndQ-KZDhj8wwveNoqU4&m=ZUhRfaeds4IAVcgF7OUF-kOqpTO0uiHL0D9W3E7Tco8&s=Y6twNzgzenSp9uI3Sv51fE0UgivfCdAmlC6rXH7INu4&e= , which both probably would be nice to have :)

Oh. Right. The 2nd one actually request what I'm looking for, I think.

>
> Otherwise the “f“ locator filter might be of some usefulness too.

The problem with this is that it requires more of a complete path to the 
file, as far as I can tell...

Actually, it may be a bit faster than using normal Open and the file 
selector in cases where you know exactly what you're looking for, but 
the "project" search is a lot more convenient.

- Toralf

>



More information about the Qt-creator mailing list