MantisBT - CMake
View Issue Details
0014331CMakeCMakepublic2013-08-01 14:412014-02-10 10:44
d3x0r 
Brad King 
highminoralways
closedfixed 
windowswindows7
CMake 2.8.11.2 
CMake 2.8.12CMake 2.8.12 
0014331: Generating projects for visual studio (2010,2012, others?) creates corrupt projects if path includes '&'
This simple make file creates corrupt .vcxproj files (files that visual studio refuses to load).

-----------
cmake_minimum_required(VERSION 2.8)

FILE( WRITE test.c "int main(){ return 0;} " )
include_directories( "a & b" )
add_executable( test test.c )
------------

the project file is expected to be XML, so it parses first using those rules, and '&' should be emitted as '&' instead.
use visual studio generator on the attached CMakeLists.txt, then load the .sln produced. None of the projects will load.
No tags attached.
txt CMakeLists.txt (146) 2013-08-01 14:41
https://public.kitware.com/Bug/file/4833/CMakeLists.txt
Issue History
2013-08-01 14:41d3x0rNew Issue
2013-08-01 14:41d3x0rFile Added: CMakeLists.txt
2013-08-01 14:58Brad KingNote Added: 0033643
2013-08-01 15:27Brad KingNote Added: 0033644
2013-08-01 15:27Brad KingAssigned To => Brad King
2013-08-01 15:27Brad KingStatusnew => resolved
2013-08-01 15:27Brad KingResolutionopen => fixed
2013-08-01 15:27Brad KingFixed in Version => CMake 2.8.12
2013-08-01 15:27Brad KingTarget Version => CMake 2.8.12
2013-08-01 15:27Brad KingDescription Updatedbug_revision_view_page.php?rev_id=1223#r1223
2014-02-10 10:44Robert MaynardNote Added: 0035067
2014-02-10 10:44Robert MaynardStatusresolved => closed

Notes
(0033643)
Brad King   
2013-08-01 14:58   
Try this patch (untested):
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx

index 1130704..937509e 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1389,7 +1389,7 @@ OutputIncludes(std::vector<std::string> const & includes)
   for(std::vector<std::string>::const_iterator i =  includes.begin();
       i != includes.end(); ++i)
     {
-    *this->BuildFileStream << *i << ";";
+    *this->BuildFileStream << cmVS10EscapeXML(*i) << ";";
     }
   this->WriteString("%(AdditionalIncludeDirectories)"
                     "</AdditionalIncludeDirectories>\n", 0);
(0033644)
Brad King   
2013-08-01 15:27   
I tested and applied the patch from 0014331:0033643:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e7bcdf85 [^]
(0035067)
Robert Maynard   
2014-02-10 10:44   
Closing resolved issues that have not been updated in more than 4 months.