0

When I use cmake on my qt project, it now (since qt6?) adds a lot of new targets related to the main targets, for example:

HT_Simple (the normal target)
HT_Simple_autogen
HT_Simple_automoc_json_extraction
HT_Simple_other_files
HT_Simple_qmltyperegistration

It is even worse when I compile a qml module:

SQView.program
SQView.program_init
SQView_program
SQView_program_autogen
SQView_program_automoc_json_extraction
SQView_program_other_files
SQView_program_qmlcache
SQView_program_qmllint
SQView_program_qmltyperegistration
SQView_program_resources_1
SQView_program_resources_2
SQView_program_tooling

Are these targets useful for the user, except maybe the _qmllint ones?
I would like to get rid of them , or at least group them together, because the VS Solution Explorer becomes unreadable.

Thanks to this SO question, I managed to group all the _autogen targets together, but I don't know how to group or get rid of the other supererogatory targets. The _autogen targets problem was supposed to be a bug in CMake-3.9, I don't know about our situation now.

I am using CMake-3.22.1, Visual Studio 2019 v.16.11.8 (same problem with MinGW), and Qt-6.2.2.
Thank you for your help!

PJ127
  • 986
  • 13
  • 23
  • 1
    I think all the targets are needed, generally Qt uses more additional build tools when compiling, like generating C++ classes from .ui files, creating magic code to make signal/slot work for QObjects, or copying resources. It's all probably done as CMake targets now. – Kaldrr Jan 13 '22 at 08:39
  • 2
    Those targets are used internally by the build system. I suggest to create an issue at https://bugreports.qt.io/. It might be possible to set the FOLDER property on such targets to hide them inside a dedicated folder in the solution explorer. – jobor Jan 13 '22 at 09:44
  • You may be able to retrieve the targets via the [`BUILDSYSTEM_TARGETS` directory property](https://cmake.org/cmake/help/latest/prop_dir/BUILDSYSTEM_TARGETS.html), iterate through the list and set the [`FOLDER` target property](https://cmake.org/cmake/help/latest/prop_tgt/FOLDER.html) for all targets you didn't create yourself to hide the undesireable targets. Usually `add_custom_command` would be used to generate the files, but I guess because of the possiblity of adding sources via generator expression, functionality like, `AUTOMOC`, ect. must rely on custom **targets**... – fabian Jan 13 '22 at 19:27

0 Answers0