Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake 3.9 now creates "autogen" projects in Visual Studio?

We're using CMake, Qt, and Visual Studio. Many of our projects are configured to run automoc, via passing AUTOMOC ON to add_library.

We recently updated to CMake 3.9.1, and Visual Studio now shows an additional project for every automoc'd library. For example, we now have a "Core" project and a "Core_autogen" project in our solution.

(this occurs in both VS2015 and VS2017, and both Qt 5.8 and 5.9.1)

This has a few annoying consequences:

  • Nearly double the number of projects, adding a lot of visual clutter.
  • Automoc no longer runs when building an individual project through the UI, which can lead to subtle bugs when debugging build issues for a specific project.

Does anyone know if there's a way to restore the previous CMake behavior for autogen?

Or barring that, some way to at least reduce the visual clutter of the autogen projects?

like image 410
Alex Goldberg Avatar asked Aug 18 '17 19:08

Alex Goldberg


3 Answers

According to the CMake v3.9 Documentation, you could use AUTOGEN_BUILD_DIR to move the generated files to a different folder.

By default CMake uses <dir>/<target-name>_autogen where:

<dir> is CMAKE_CURRENT_BINARY_DIR and <target-name> is NAME

Or from the AUTOMOC property you could use:

The global property AUTOGEN_TARGETS_FOLDER can be used to group the automoc targets together in an IDE, e.g. in MSVS.

The global property AUTOGEN_SOURCE_GROUP can be used to group files generated by AUTOMOC together in an IDE, e.g. in MSVS.

Hope this helps.

like image 55
Isaac Gómez Avatar answered Nov 12 '22 15:11

Isaac Gómez


This collects all autogen projects in one folder:

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER AutoMoc)

enter image description here

like image 30
Vertexwahn Avatar answered Nov 12 '22 16:11

Vertexwahn


This is a regression and supposed to be fixed in CMake 3.10. The CMake bug report is here: https://gitlab.kitware.com/cmake/cmake/issues/17205

like image 3
Sebastian Holtermann Avatar answered Nov 12 '22 16:11

Sebastian Holtermann