This question is more or less a warmup of this question:
how to get cmake to add files to msvcs solution tree
It never got a valid answer so I want to repose it slightly different:
Is it possible to use the cmake solution folders that where introduced with cmake 2.8.3 to add files directly to the vs solution? I want to do the cmake equivalent of VS->Solution->Add->Existing Item. So my file will appear in a folder that belongs to the solution and not to a project.
I found examples how the solution folders can be used to group targets into folders with code like this:
set_property( GLOBAL PROPERTY USE_FOLDERS ON)
set_property(TARGET ${TARGET_NAME} PROPERTY FOLDER "Test")
So can I add a file instead of a target to the folder?
With the upcoming cmake version 4.0.0 (currently available as release candidate 4.0.0-rc5) it is going to be possible to add arbitrary files to the Solution in VS. This is done through the newly added VS_SOLUTION_ITEMS Property, see here: VS_SOLUTION_ITEMS
This is a directory property, so it has to be applied on the same directory as your initial project()
call is made in.
Usage example:
set_directory_properties(PROPERTIES
VS_SOLUTION_ITEMS
./conanfile.py
./cmake/marcos.cmake
# etc..
)