There are several projects that are automatically generated when using cmake.

The two that I have come across recently are the XXX_qmlimportscan and 
XXX_other_files (where XXX is the project they were created for), there are 
likely others, but I'm early in my investigation.

The reason I haven't seen these earlier, is I have been using cmake + Qt since 
Qt3 days, and I have a ton of technical debt in my homegrown cmake Modules for 
working with Qt.  I'm only now using some of the new Qt built in functions for 
things like UI, rcc, qrc etc etc.

I understand the need for these, as they largely replace modules I had to solve 
with similar functionality.

The problem is, when using an IDE (you would never notice this using a 
ninja/makefile style build), the projects show up as top level folders, and 
make the library layout look weird.

I have a couple of variants of the same solutions to this, all using cmake 
target property "FOLDER"


  1.  Use a cmake cached variable for QT_AUTOPROJECT_FOLDER  with a default 
setting of QtAutoProjects (or similar) that would set all generated projects 
inside that folder in IDEs.  This is similar to the CMakePredefinedTargets 
folder that is used for top level cmake targets (INSTALL, PACKAGE and OTHERS)

The when the Qt cmake functions create a new project, setting the target 
property as such:
set_target_properties( ${PROJECT_NAME} PROPERTIES  FOLDER 
${QT_AUTOPROJECT_FOLDER} )

Which would create a root level folder and place all the auto projects it 
underneath it.

  2.  Since the generated projects all contain the PROJECT they were created 
for, simply doing the following after each project is created
set_target_properties( ${PROJECT_NAME} PROPERTIES  FOLDER 
${PARENT_PROJECT_NAME} )

Which would simply create a folder under the project with the same name as the 
before

  1.  The third simply combines the two
set_target_properties( ${PROJECT_NAME} PROPERTIES  FOLDER 
${PARENT_PROJECT_NAME}/${QT_AUTOPROJECT_FOLDER}  )


The FOLDER property has no effect on cmake generators that do not support them, 
they do not create a "scope" of project names, its simply using folders in the 
IDE (I use this in Visual Studio and have also used it in VS Code, Xcode and 
others), so there should be no change to the normal build flow, nor any command 
line flow at all.



Thoughts?

I figured I would file an issue with a solution when I have it working.

Scott


-- 
Development mailing list
[email protected]
https://lists.qt-project.org/listinfo/development

Reply via email to