Adding "--run" functionality?

The motivation for this feature comes from a scenario like the following. Let’s say you have thousands of targets, but there is one or a small number of targets that would be considered the “main” target (e.g. a GUI app). All the others could be things like test executables, etc. When an IDE first loads the project, it may want to create something like a run configuration for executable targets. One choice is to create such a run configuration for every executable, but for this scenario, that would result in thousands of such things and that can be unwieldy. An example of this behavior can be seen with the Xcode generator when you set CMAKE_XCODE_GENERATE_SCHEME to true. An alternative is to create no such run configurations automatically and rely on the user manually creating any that they want. Both have their disadvantages.

The functionality discussed in this thread is about finding a balance between those two extremes. The project is in the best position to nominate those targets that can be considered its “main” ones. What’s lacking at the moment is a way to annotate that in CMake. Qt Creator elected to re-use the FOLDER property as a pragmatic choice, but CMake should ideally support a way to represent this as a dedicated feature. If we did that, then it could be populated in the file API replies and all IDEs could make use of it. That would be the ideal outcome rather than making projects add an IDE-specific target property.

5 Likes

I filed https://gitlab.kitware.com/cmake/cmake/-/issues/24129

1 Like