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:
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?
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.
This collects all autogen projects in one folder:
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER AutoMoc)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With