Visual Studio 2019 - Cmake Automatic script changes via add item

Erik Helecz 1 Reputation point
2022-03-18T11:46:30.86+00:00

Hello.

I have a small problem regarding visual studio's "Add item" which is supposed to create new files and automatically add them to the cmake files.

To better explain what I have in mind, I will create a screenshot:
184583-image.png

After clicking through the wizard, you will get a prompt where visual studio asks where to add the files. Unfortunately it only offers two options, where both of them are wrong.
My cmake has a large number of source groups and each one is then appended in a single set called "ALL FILES", which is then passed to the add_executable.

Visual studio does NOT seem to recognize the other variables created by the set only the ALL_FILES variable, which is directly then used in the add_excutable.
Visual studio discards all other sets unless they are directly used in the add_executable or add_library. Adding them to another set will discard them in the menu.

A temporary fix would be adding the sets to the add_executable directly, like so:

184558-image.png

The issue now is that visual studio doesn't display the variable names and I have absolutely no idea which set is which, unless I manually click through them.

This generally makes the entire automatic cmake changes feature clumsy and very impractical to use.
A short example how Clion handles the very same feature:
184568-image.png

I would really like to migrate my projects to visual studio because of superior features, but this detail is currently putting me off.

My question is: Is there a way to configure visual studio so it achieves a similar behavior as Clion? If not, is this going to be a planned feature?

Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.