1

The story

I'm trying to load a C++ project with Visual Studio, and as I used CMake, I used it to generate a .sln file.

My sources files are regrouped in separate folders, but the solution explorer listed them all in a "Source files" folder. Thanks to this question, I solved this first problem.

But then I realized that only .cpp files were listed, so I added new virtual directories one by one to make the folder architecture as it was on my folder list in include side.

But then again I tried to create a new file in a virtual folder, and realized that it didn't move at all at the right place in real.


The question

So now, I just want to forget this "virtual directories" system, and make the solution explorer to be nothing more than a folder tree as it is in real, just like a windows explorer.
Is there any way to do that after an initialization of .sln file with CMake?


UPDATE:

I'm not wishing to use a CMake command because It does not resolve creation problems, nor anything that would pass through the actual solution explorer because each time that I edit a CMakeFiles.txt file, the solution reload reset the solution explorer and I loose every manual include previously done.

Community
  • 1
  • 1
Aracthor
  • 5,757
  • 6
  • 31
  • 59
  • I do not believe Visual Studio has a directory view like some other ides. I add the headers and other files to my CMake targets so that they show up in solution explorer. – drescherjm Sep 15 '15 at 12:55
  • 1
    See also CMake's [`source_group`](http://www.cmake.org/cmake/help/v3.3/command/source_group.html) command. – Angew is no longer proud of SO Sep 15 '15 at 13:04
  • @Angew Already done, check the linker question. But it does not resolve the problem if I add a new directory or a new file in the solution explorer: I have to add it again manually on the real directory. – Aracthor Sep 15 '15 at 13:08
  • 1
    Yes, that's true. As @drescherjm pointed out, the Solution Explorer is not capable of being switched to Filesystem mode. – Angew is no longer proud of SO Sep 15 '15 at 13:14
  • @Aracthor: Which settings exactly do you lose if you re-run cmake? The inter-project dependencies which are saved to the sln? User specific settings are saved to the single .user.vc*proj files anyway which aren't touched by cmake. If you want to add other projects manually to the sln, there is another way. Create your own solution which includes the projects generated by cmake. This way, cmake recreates the project but the sln stays the same – Gombat Sep 15 '15 at 13:15
  • @Gombat I loose every file that I manually added to solution. So manual integration is not an option. – Aracthor Sep 15 '15 at 13:17
  • 1
    But using source_group and some `file(GLOB...)` which adds all existing files to the project won't let you lose any file. You can add sources and headers to the cmake target automatically without specifying them individually. – Gombat Sep 15 '15 at 13:23
  • 1
    @Angew It does have the "Show All Files" button, which will show the actual filesystem directory structure. OP, does that solve your problem? The main issue with that view is that the root is in the directory where the `.vcxproj` file resides, and you can't go up from there; there's a solution for that too, using an NTFS symbolic link to the root of your actual source tree - I use it in several projects. – bogdan Sep 15 '15 at 13:39
  • @bogdan Thanks for the correction. I don't recall seeing that button until you mentioned it. Although after pressing the button I quickly reverted back. On a Qt / CMake solution there are way too many other files that I want hidden and I am already quite comfortable with the structure I have exposed in the solution folders that I created in my CMake scripts. This does look like a solution for the OP however. – drescherjm Sep 15 '15 at 16:41

0 Answers0