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

Eike Ziller Eike.Ziller at qt.io
Fri May 10 09:40:38 CEST 2019



> On 10. May 2019, at 09:26, Toralf Lund <toralf.lund at pgs.com> wrote:
> 
> On 09/05/2019 16:10, Tobias Hunger 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:-)
> 
> The problem with that is that the CMake project is shared with a lot of people that user other IDEs, or no IDE at all. So I don't know if I can/should add extra stuff just because it's needed by Qt Creator...
> 
>>>  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.
> 
> Well, I guess it sets up custom commands. But it's a function that's supplied with CMake; not something we invented.
> 
> 
>>  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.
> 
> Ctrl-K doesn't do anything in my configuration. What is it supposed to be bound to? I may have adjusted keyboard shortcuts at some stage...

You can check the shortcut on Tools > Locate... , or in Options > Environment > Keyboard, filter for “locate”.
On macOS it “of course” is cmd+k by default, if you happen to use that.

> But, I do use the locator. I generally open files via the "File in Any Project" option, which allows me to find any file *by typing only the simple filename* - which makes life a lot easier. That requires the file to be included in the project/listed in project views, though, which is really the main reason why I want extra files there. I notice that there is "File on Filesystem", too, but it looks like I have to type in the full path to the file there, which means it's not really of much value (as you might as well use the normal Open function.)

File on Filesystem is relative to the “current document”, so usually you do not have to manually type in the full path. But you have to navigate to the correct directory manually, yes. That would be better with a filter that includes all files in the complete file system tree under the project... (https://bugreports.qt.io/browse/QTCREATORBUG-19122)

> 
> - Toralf
> 
>> 
>> Best Regards,
>> Tobias
>> 
> 
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> https://lists.qt-project.org/listinfo/qt-creator

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