MantisBT - CMake
View Issue Details
0013571CMakeCMakepublic2012-10-04 11:492013-04-17 08:54
rlandert 
David Cole 
normalminoralways
closedfixed 
Windows
CMake 2.8.9 
CMake 2.8.11CMake 2.8.11 
0013571: Empty FOLDERs in Visual Studio Solutions shown from external targets
In the Visual Studio Solutions of targets which are defined in subfolders, all Visual Studio FOLDERS (target property) from previously defined targets are shown, even if these targets are not contained in the solution.

Example (see attachment):

In the toplevel directory there is a project definition for project test, which includes the two subdirectories test1 and test2 via:
 * add_subdirectory(test1)
 * add_subdirectory(test2)

Inside these folders the projects test1 and test2 are defined, which generate the executables test1.exe and test2.exe.

For these targets the Visual Studio Folders are defined in the according CMakeLists.txt files via:
 * set_property(TARGET test1 PROPERTY FOLDER "test1Dir")
 * set_property(TARGET test2 PROPERTY FOLDER "test2Dir")

In the global solution file test.sln both targets are shown in the correct folders:
 * test1Dir/test1
 * test2Dir/test2

In the solution files for the subprojects, the (empty) folder for the other target is shown although it is not part of the solution. E.g. in solution test1.sln the empty folder test2Dir is shown.

Tested with CMake 2.8.9 and Visual Studio 2008.
1. Unpack attached file
2. Generate Visual Studio Solutions with CMake
3. Open test.sln -> targets test1 and test2 are correctly shown in subfolder test1Dir and test2Dir
4. Open test1/test1.sln -> empty folder test2Dir is shown
5. Open test2/test2.sln -> empty folder test1Dir is shown
The reason seems to be that the variable VisualStudioFolders in the file cmGlobalVisualStudio7Generator.cxx is not cleared between the generation of the different Solution files.

My solution was to call VisualStudioFolders.clear() at the beginning of the method cmGlobalVisualStudio7Generator::WriteTargetsToSolution, although i'm not sure whether this is the correct place for this. The patch can be found in the attached file.
No tags attached.
zip CMake_FolderIssue.zip (1,822) 2012-10-04 11:49
https://public.kitware.com/Bug/file/4514/CMake_FolderIssue.zip
Issue History
2012-10-04 11:49rlandertNew Issue
2012-10-04 11:49rlandertFile Added: CMake_FolderIssue.zip
2012-10-24 15:02David ColeAssigned To => David Cole
2012-10-24 15:02David ColeStatusnew => assigned
2012-10-24 15:03David ColeTarget Version => CMake 2.8.11
2012-10-24 15:04David ColeNote Added: 0031307
2012-10-24 15:16David ColeNote Edited: 0031307bug_revision_view_page.php?bugnote_id=31307#r865
2012-11-01 17:57David ColeNote Added: 0031379
2012-11-01 17:57David ColeStatusassigned => resolved
2012-11-01 17:57David ColeFixed in Version => CMake 2.8.11
2012-11-01 17:57David ColeResolutionopen => fixed
2013-04-17 08:54Robert MaynardNote Added: 0032870
2013-04-17 08:54Robert MaynardStatusresolved => closed

Notes
(0031307)
David Cole   
2012-10-24 15:04   
(edited on: 2012-10-24 15:16)
I've pushed a fix for this issue to the CMake stage repo in the topic branch "fix-13571-avoid-empty-sln-folders"

As soon as 2.8.10 is final, I'll merge it to 'next' for dashboard testing, and then after that, it will get merged to 'master' and be available as soon as we start building the 2.8.11 release.

Thanks for the bug report! (And the patch!)

(0031379)
David Cole   
2012-11-01 17:57   
Fix pushed to 'next':

  http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d7de641 [^]

You can use a nightly build of CMake if you need the fix before the 2.8.11 release.
(0032870)
Robert Maynard   
2013-04-17 08:54   
Closing resolved issues that have not been updated in more than 4 months.