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

Eike Ziller Eike.Ziller at qt.io
Fri May 10 08:36:04 CEST 2019



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

There is also a suggestion to make the custom locator filters a bit more flexible https://bugreports.qt.io/browse/QTCREATORBUG-21470 , possibly adding the root of the current project by default https://bugreports.qt.io/browse/QTCREATORBUG-19122 , which both probably would be nice to have :)

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

-- 
Eike Ziller
Principal Software Engineer

The Qt Company GmbH
Rudower Chaussee 13
D-12489 Berlin
eike.ziller at qt.io
http://qt.io
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