cmVisualStudio10TargetGenerator.cxx 107 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmVisualStudio10TargetGenerator.h"
  11. #include "cmGlobalVisualStudio10Generator.h"
  12. #include "cmGeneratorTarget.h"
  13. #include "cmTarget.h"
  14. #include "cmComputeLinkInformation.h"
  15. #include "cmGeneratedFileStream.h"
  16. #include "cmMakefile.h"
  17. #include "cmSourceFile.h"
  18. #include "cmVisualStudioGeneratorOptions.h"
  19. #include "cmLocalVisualStudio7Generator.h"
  20. #include "cmCustomCommandGenerator.h"
  21. #include "cmVS10CLFlagTable.h"
  22. #include "cmVS10RCFlagTable.h"
  23. #include "cmVS10LinkFlagTable.h"
  24. #include "cmVS10LibFlagTable.h"
  25. #include "cmVS10MASMFlagTable.h"
  26. #include "cmVS11CLFlagTable.h"
  27. #include "cmVS11RCFlagTable.h"
  28. #include "cmVS11LinkFlagTable.h"
  29. #include "cmVS11LibFlagTable.h"
  30. #include "cmVS11MASMFlagTable.h"
  31. #include "cmVS12CLFlagTable.h"
  32. #include "cmVS12RCFlagTable.h"
  33. #include "cmVS12LinkFlagTable.h"
  34. #include "cmVS12LibFlagTable.h"
  35. #include "cmVS12MASMFlagTable.h"
  36. #include "cmVS14CLFlagTable.h"
  37. #include "cmVS14RCFlagTable.h"
  38. #include "cmVS14LinkFlagTable.h"
  39. #include "cmVS14LibFlagTable.h"
  40. #include "cmVS14MASMFlagTable.h"
  41. #include <cmsys/auto_ptr.hxx>
  42. cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetClFlagTable() const
  43. {
  44. if(this->MSTools)
  45. {
  46. cmLocalVisualStudioGenerator::VSVersion
  47. v = this->LocalGenerator->GetVersion();
  48. if(v >= cmLocalVisualStudioGenerator::VS14)
  49. { return cmVS14CLFlagTable; }
  50. else if(v >= cmLocalVisualStudioGenerator::VS12)
  51. { return cmVS12CLFlagTable; }
  52. else if(v == cmLocalVisualStudioGenerator::VS11)
  53. { return cmVS11CLFlagTable; }
  54. else
  55. { return cmVS10CLFlagTable; }
  56. }
  57. return 0;
  58. }
  59. cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetRcFlagTable() const
  60. {
  61. if(this->MSTools)
  62. {
  63. cmLocalVisualStudioGenerator::VSVersion
  64. v = this->LocalGenerator->GetVersion();
  65. if(v >= cmLocalVisualStudioGenerator::VS14)
  66. { return cmVS14RCFlagTable; }
  67. else if(v >= cmLocalVisualStudioGenerator::VS12)
  68. { return cmVS12RCFlagTable; }
  69. else if(v == cmLocalVisualStudioGenerator::VS11)
  70. { return cmVS11RCFlagTable; }
  71. else
  72. { return cmVS10RCFlagTable; }
  73. }
  74. return 0;
  75. }
  76. cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLibFlagTable() const
  77. {
  78. if(this->MSTools)
  79. {
  80. cmLocalVisualStudioGenerator::VSVersion
  81. v = this->LocalGenerator->GetVersion();
  82. if(v >= cmLocalVisualStudioGenerator::VS14)
  83. { return cmVS14LibFlagTable; }
  84. else if(v >= cmLocalVisualStudioGenerator::VS12)
  85. { return cmVS12LibFlagTable; }
  86. else if(v == cmLocalVisualStudioGenerator::VS11)
  87. { return cmVS11LibFlagTable; }
  88. else
  89. { return cmVS10LibFlagTable; }
  90. }
  91. return 0;
  92. }
  93. cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetLinkFlagTable() const
  94. {
  95. if(this->MSTools)
  96. {
  97. cmLocalVisualStudioGenerator::VSVersion
  98. v = this->LocalGenerator->GetVersion();
  99. if(v >= cmLocalVisualStudioGenerator::VS14)
  100. { return cmVS14LinkFlagTable; }
  101. else if(v >= cmLocalVisualStudioGenerator::VS12)
  102. { return cmVS12LinkFlagTable; }
  103. else if(v == cmLocalVisualStudioGenerator::VS11)
  104. { return cmVS11LinkFlagTable; }
  105. else
  106. { return cmVS10LinkFlagTable; }
  107. }
  108. return 0;
  109. }
  110. cmIDEFlagTable const* cmVisualStudio10TargetGenerator::GetMasmFlagTable() const
  111. {
  112. if(this->MSTools)
  113. {
  114. cmLocalVisualStudioGenerator::VSVersion
  115. v = this->LocalGenerator->GetVersion();
  116. if(v >= cmLocalVisualStudioGenerator::VS14)
  117. { return cmVS14MASMFlagTable; }
  118. else if(v >= cmLocalVisualStudioGenerator::VS12)
  119. { return cmVS12MASMFlagTable; }
  120. else if(v == cmLocalVisualStudioGenerator::VS11)
  121. { return cmVS11MASMFlagTable; }
  122. else
  123. { return cmVS10MASMFlagTable; }
  124. }
  125. return 0;
  126. }
  127. static std::string cmVS10EscapeXML(std::string arg)
  128. {
  129. cmSystemTools::ReplaceString(arg, "&", "&amp;");
  130. cmSystemTools::ReplaceString(arg, "<", "&lt;");
  131. cmSystemTools::ReplaceString(arg, ">", "&gt;");
  132. return arg;
  133. }
  134. static std::string cmVS10EscapeComment(std::string comment)
  135. {
  136. // MSBuild takes the CDATA of a <Message></Message> element and just
  137. // does "echo $CDATA" with no escapes. We must encode the string.
  138. // http://technet.microsoft.com/en-us/library/cc772462%28WS.10%29.aspx
  139. std::string echoable;
  140. for(std::string::iterator c = comment.begin(); c != comment.end(); ++c)
  141. {
  142. switch (*c)
  143. {
  144. case '\r': break;
  145. case '\n': echoable += '\t'; break;
  146. case '"': /* no break */
  147. case '|': /* no break */
  148. case '&': /* no break */
  149. case '<': /* no break */
  150. case '>': /* no break */
  151. case '^': echoable += '^'; /* no break */
  152. default: echoable += *c; break;
  153. }
  154. }
  155. return echoable;
  156. }
  157. cmVisualStudio10TargetGenerator::
  158. cmVisualStudio10TargetGenerator(cmTarget* target,
  159. cmGlobalVisualStudio10Generator* gg)
  160. {
  161. this->GlobalGenerator = gg;
  162. this->Target = target;
  163. this->GeneratorTarget = gg->GetGeneratorTarget(target);
  164. this->Makefile = target->GetMakefile();
  165. this->LocalGenerator =
  166. (cmLocalVisualStudio7Generator*)
  167. this->Makefile->GetLocalGenerator();
  168. this->Name = this->Target->GetName();
  169. this->GlobalGenerator->CreateGUID(this->Name.c_str());
  170. this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str());
  171. this->Platform = gg->GetPlatformName();
  172. this->NsightTegra = gg->IsNsightTegra();
  173. for(int i =
  174. sscanf(gg->GetNsightTegraVersion().c_str(), "%u.%u.%u.%u",
  175. &this->NsightTegraVersion[0], &this->NsightTegraVersion[1],
  176. &this->NsightTegraVersion[2], &this->NsightTegraVersion[3]);
  177. i < 4; ++i)
  178. {
  179. this->NsightTegraVersion[i] = 0;
  180. }
  181. this->MSTools = !this->NsightTegra;
  182. this->TargetCompileAsWinRT = false;
  183. this->BuildFileStream = 0;
  184. this->IsMissingFiles = false;
  185. this->DefaultArtifactDir =
  186. this->Makefile->GetStartOutputDirectory() + std::string("/") +
  187. this->LocalGenerator->GetTargetDirectory(*this->Target);
  188. }
  189. cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator()
  190. {
  191. for(OptionsMap::iterator i = this->ClOptions.begin();
  192. i != this->ClOptions.end(); ++i)
  193. {
  194. delete i->second;
  195. }
  196. for(OptionsMap::iterator i = this->LinkOptions.begin();
  197. i != this->LinkOptions.end(); ++i)
  198. {
  199. delete i->second;
  200. }
  201. if(!this->BuildFileStream)
  202. {
  203. return;
  204. }
  205. if (this->BuildFileStream->Close())
  206. {
  207. this->GlobalGenerator
  208. ->FileReplacedDuringGenerate(this->PathToVcxproj);
  209. }
  210. delete this->BuildFileStream;
  211. }
  212. void cmVisualStudio10TargetGenerator::WritePlatformConfigTag(
  213. const char* tag,
  214. const std::string& config,
  215. int indentLevel,
  216. const char* attribute,
  217. const char* end,
  218. std::ostream* stream)
  219. {
  220. if(!stream)
  221. {
  222. stream = this->BuildFileStream;
  223. }
  224. stream->fill(' ');
  225. stream->width(indentLevel*2 );
  226. (*stream ) << "";
  227. (*stream ) << "<" << tag
  228. << " Condition=\"'$(Configuration)|$(Platform)'=='";
  229. (*stream ) << config << "|" << this->Platform << "'\"";
  230. if(attribute)
  231. {
  232. (*stream ) << attribute;
  233. }
  234. // close the tag
  235. (*stream ) << ">";
  236. if(end)
  237. {
  238. (*stream ) << end;
  239. }
  240. }
  241. void cmVisualStudio10TargetGenerator::WriteString(const char* line,
  242. int indentLevel)
  243. {
  244. this->BuildFileStream->fill(' ');
  245. this->BuildFileStream->width(indentLevel*2 );
  246. // write an empty string to get the fill level indent to print
  247. (*this->BuildFileStream ) << "";
  248. (*this->BuildFileStream ) << line;
  249. }
  250. #define VS10_USER_PROPS "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props"
  251. void cmVisualStudio10TargetGenerator::Generate()
  252. {
  253. // do not generate external ms projects
  254. if(this->Target->GetType() == cmTarget::INTERFACE_LIBRARY
  255. || this->Target->GetProperty("EXTERNAL_MSPROJECT"))
  256. {
  257. return;
  258. }
  259. // Tell the global generator the name of the project file
  260. this->Target->SetProperty("GENERATOR_FILE_NAME",this->Name.c_str());
  261. this->Target->SetProperty("GENERATOR_FILE_NAME_EXT",
  262. ".vcxproj");
  263. if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY)
  264. {
  265. if(!this->ComputeClOptions())
  266. {
  267. return;
  268. }
  269. if(!this->ComputeRcOptions())
  270. {
  271. return;
  272. }
  273. if(!this->ComputeMasmOptions())
  274. {
  275. return;
  276. }
  277. if(!this->ComputeLinkOptions())
  278. {
  279. return;
  280. }
  281. }
  282. cmMakefile* mf = this->Target->GetMakefile();
  283. std::string path = mf->GetStartOutputDirectory();
  284. path += "/";
  285. path += this->Name;
  286. path += ".vcxproj";
  287. this->BuildFileStream =
  288. new cmGeneratedFileStream(path.c_str());
  289. this->PathToVcxproj = path;
  290. this->BuildFileStream->SetCopyIfDifferent(true);
  291. // Write the encoding header into the file
  292. char magic[] = {char(0xEF), char(0xBB), char(0xBF)};
  293. this->BuildFileStream->write(magic, 3);
  294. //get the tools version to use
  295. const std::string toolsVer(this->GlobalGenerator->GetToolsVersion());
  296. std::string project_defaults=
  297. "<?xml version=\"1.0\" encoding=\"" +
  298. this->GlobalGenerator->Encoding() + "\"?>\n";
  299. project_defaults.append("<Project DefaultTargets=\"Build\" ToolsVersion=\"");
  300. project_defaults.append(toolsVer +"\" ");
  301. project_defaults.append(
  302. "xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n");
  303. this->WriteString(project_defaults.c_str(),0);
  304. if(this->NsightTegra)
  305. {
  306. this->WriteString("<PropertyGroup Label=\"NsightTegraProject\">\n", 1);
  307. if(this->NsightTegraVersion[0] >= 2)
  308. {
  309. // Nsight Tegra 2.0 uses project revision 9.
  310. this->WriteString("<NsightTegraProjectRevisionNumber>"
  311. "9"
  312. "</NsightTegraProjectRevisionNumber>\n", 2);
  313. // Tell newer versions to upgrade silently when loading.
  314. this->WriteString("<NsightTegraUpgradeOnceWithoutPrompt>"
  315. "true"
  316. "</NsightTegraUpgradeOnceWithoutPrompt>\n", 2);
  317. }
  318. else
  319. {
  320. // Require Nsight Tegra 1.6 for JCompile support.
  321. this->WriteString("<NsightTegraProjectRevisionNumber>"
  322. "7"
  323. "</NsightTegraProjectRevisionNumber>\n", 2);
  324. }
  325. this->WriteString("</PropertyGroup>\n", 1);
  326. }
  327. this->WriteProjectConfigurations();
  328. this->WriteString("<PropertyGroup Label=\"Globals\">\n", 1);
  329. this->WriteString("<ProjectGUID>", 2);
  330. (*this->BuildFileStream) << "{" << this->GUID << "}</ProjectGUID>\n";
  331. if(this->MSTools && this->Target->GetType() <= cmTarget::GLOBAL_TARGET)
  332. {
  333. this->WriteApplicationTypeSettings();
  334. this->VerifyNecessaryFiles();
  335. }
  336. const char* vsProjectTypes =
  337. this->Target->GetProperty("VS_GLOBAL_PROJECT_TYPES");
  338. if(vsProjectTypes)
  339. {
  340. this->WriteString("<ProjectTypes>", 2);
  341. (*this->BuildFileStream) << cmVS10EscapeXML(vsProjectTypes) <<
  342. "</ProjectTypes>\n";
  343. }
  344. const char* vsProjectName = this->Target->GetProperty("VS_SCC_PROJECTNAME");
  345. const char* vsLocalPath = this->Target->GetProperty("VS_SCC_LOCALPATH");
  346. const char* vsProvider = this->Target->GetProperty("VS_SCC_PROVIDER");
  347. if( vsProjectName && vsLocalPath && vsProvider )
  348. {
  349. this->WriteString("<SccProjectName>", 2);
  350. (*this->BuildFileStream) << cmVS10EscapeXML(vsProjectName) <<
  351. "</SccProjectName>\n";
  352. this->WriteString("<SccLocalPath>", 2);
  353. (*this->BuildFileStream) << cmVS10EscapeXML(vsLocalPath) <<
  354. "</SccLocalPath>\n";
  355. this->WriteString("<SccProvider>", 2);
  356. (*this->BuildFileStream) << cmVS10EscapeXML(vsProvider) <<
  357. "</SccProvider>\n";
  358. const char* vsAuxPath = this->Target->GetProperty("VS_SCC_AUXPATH");
  359. if( vsAuxPath )
  360. {
  361. this->WriteString("<SccAuxPath>", 2);
  362. (*this->BuildFileStream) << cmVS10EscapeXML(vsAuxPath) <<
  363. "</SccAuxPath>\n";
  364. }
  365. }
  366. if(this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT"))
  367. {
  368. this->WriteString("<WinMDAssembly>true</WinMDAssembly>\n", 2);
  369. }
  370. const char* vsGlobalKeyword =
  371. this->Target->GetProperty("VS_GLOBAL_KEYWORD");
  372. if(!vsGlobalKeyword)
  373. {
  374. this->WriteString("<Keyword>Win32Proj</Keyword>\n", 2);
  375. }
  376. else
  377. {
  378. this->WriteString("<Keyword>", 2);
  379. (*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalKeyword) <<
  380. "</Keyword>\n";
  381. }
  382. const char* vsGlobalRootNamespace =
  383. this->Target->GetProperty("VS_GLOBAL_ROOTNAMESPACE");
  384. if(vsGlobalRootNamespace)
  385. {
  386. this->WriteString("<RootNamespace>", 2);
  387. (*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalRootNamespace) <<
  388. "</RootNamespace>\n";
  389. }
  390. this->WriteString("<Platform>", 2);
  391. (*this->BuildFileStream) << cmVS10EscapeXML(this->Platform)
  392. << "</Platform>\n";
  393. const char* projLabel = this->Target->GetProperty("PROJECT_LABEL");
  394. if(!projLabel)
  395. {
  396. projLabel = this->Name.c_str();
  397. }
  398. this->WriteString("<ProjectName>", 2);
  399. (*this->BuildFileStream) << cmVS10EscapeXML(projLabel) << "</ProjectName>\n";
  400. if(const char* targetFrameworkVersion = this->Target->GetProperty(
  401. "VS_DOTNET_TARGET_FRAMEWORK_VERSION"))
  402. {
  403. this->WriteString("<TargetFrameworkVersion>", 2);
  404. (*this->BuildFileStream) << cmVS10EscapeXML(targetFrameworkVersion)
  405. << "</TargetFrameworkVersion>\n";
  406. }
  407. this->WriteString("</PropertyGroup>\n", 1);
  408. this->WriteString("<Import Project="
  409. "\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n",
  410. 1);
  411. this->WriteProjectConfigurationValues();
  412. this->WriteString(
  413. "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n", 1);
  414. this->WriteString("<ImportGroup Label=\"ExtensionSettings\">\n", 1);
  415. if (this->GlobalGenerator->IsMasmEnabled())
  416. {
  417. this->WriteString("<Import Project=\"$(VCTargetsPath)\\"
  418. "BuildCustomizations\\masm.props\" />\n", 2);
  419. }
  420. this->WriteString("</ImportGroup>\n", 1);
  421. this->WriteString("<ImportGroup Label=\"PropertySheets\">\n", 1);
  422. this->WriteString("<Import Project=\"" VS10_USER_PROPS "\""
  423. " Condition=\"exists('" VS10_USER_PROPS "')\""
  424. " Label=\"LocalAppDataPlatform\" />\n", 2);
  425. this->WriteString("</ImportGroup>\n", 1);
  426. this->WriteString("<PropertyGroup Label=\"UserMacros\" />\n", 1);
  427. this->WriteWinRTPackageCertificateKeyFile();
  428. this->WritePathAndIncrementalLinkOptions();
  429. this->WriteItemDefinitionGroups();
  430. this->WriteCustomCommands();
  431. this->WriteAllSources();
  432. this->WriteDotNetReferences();
  433. this->WriteEmbeddedResourceGroup();
  434. this->WriteWinRTReferences();
  435. this->WriteProjectReferences();
  436. this->WriteString(
  437. "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\""
  438. " />\n", 1);
  439. this->WriteTargetSpecificReferences();
  440. this->WriteString("<ImportGroup Label=\"ExtensionTargets\">\n", 1);
  441. if (this->GlobalGenerator->IsMasmEnabled())
  442. {
  443. this->WriteString("<Import Project=\"$(VCTargetsPath)\\"
  444. "BuildCustomizations\\masm.targets\" />\n", 2);
  445. }
  446. this->WriteString("</ImportGroup>\n", 1);
  447. this->WriteString("</Project>", 0);
  448. // The groups are stored in a separate file for VS 10
  449. this->WriteGroups();
  450. }
  451. void cmVisualStudio10TargetGenerator::WriteDotNetReferences()
  452. {
  453. std::vector<std::string> references;
  454. if(const char* vsDotNetReferences =
  455. this->Target->GetProperty("VS_DOTNET_REFERENCES"))
  456. {
  457. cmSystemTools::ExpandListArgument(vsDotNetReferences, references);
  458. }
  459. if(!references.empty())
  460. {
  461. this->WriteString("<ItemGroup>\n", 1);
  462. for(std::vector<std::string>::iterator ri = references.begin();
  463. ri != references.end(); ++ri)
  464. {
  465. this->WriteString("<Reference Include=\"", 2);
  466. (*this->BuildFileStream) << cmVS10EscapeXML(*ri) << "\">\n";
  467. this->WriteString("<CopyLocalSatelliteAssemblies>true"
  468. "</CopyLocalSatelliteAssemblies>\n", 3);
  469. this->WriteString("<ReferenceOutputAssembly>true"
  470. "</ReferenceOutputAssembly>\n", 3);
  471. this->WriteString("</Reference>\n", 2);
  472. }
  473. this->WriteString("</ItemGroup>\n", 1);
  474. }
  475. }
  476. void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
  477. {
  478. std::vector<cmSourceFile const*> resxObjs;
  479. this->GeneratorTarget->GetResxSources(resxObjs, "");
  480. if(!resxObjs.empty())
  481. {
  482. this->WriteString("<ItemGroup>\n", 1);
  483. for(std::vector<cmSourceFile const*>::const_iterator oi = resxObjs.begin();
  484. oi != resxObjs.end(); ++oi)
  485. {
  486. std::string obj = (*oi)->GetFullPath();
  487. this->WriteString("<EmbeddedResource Include=\"", 2);
  488. this->ConvertToWindowsSlash(obj);
  489. (*this->BuildFileStream ) << obj << "\">\n";
  490. this->WriteString("<DependentUpon>", 3);
  491. std::string hFileName = obj.substr(0, obj.find_last_of(".")) + ".h";
  492. (*this->BuildFileStream ) << hFileName;
  493. this->WriteString("</DependentUpon>\n", 3);
  494. std::vector<std::string> const * configs =
  495. this->GlobalGenerator->GetConfigurations();
  496. for(std::vector<std::string>::const_iterator i = configs->begin();
  497. i != configs->end(); ++i)
  498. {
  499. this->WritePlatformConfigTag("LogicalName", i->c_str(), 3);
  500. if(this->Target->GetProperty("VS_GLOBAL_ROOTNAMESPACE"))
  501. {
  502. (*this->BuildFileStream ) << "$(RootNamespace).";
  503. }
  504. (*this->BuildFileStream ) << "%(Filename)";
  505. (*this->BuildFileStream ) << ".resources";
  506. (*this->BuildFileStream ) << "</LogicalName>\n";
  507. }
  508. this->WriteString("</EmbeddedResource>\n", 2);
  509. }
  510. this->WriteString("</ItemGroup>\n", 1);
  511. }
  512. }
  513. void cmVisualStudio10TargetGenerator::WriteTargetSpecificReferences()
  514. {
  515. if(this->MSTools)
  516. {
  517. if(this->GlobalGenerator->TargetsWindowsPhone() &&
  518. this->GlobalGenerator->GetSystemVersion() == "8.0")
  519. {
  520. this->WriteString(
  521. "<Import Project=\""
  522. "$(MSBuildExtensionsPath)\\Microsoft\\WindowsPhone\\v"
  523. "$(TargetPlatformVersion)\\Microsoft.Cpp.WindowsPhone."
  524. "$(TargetPlatformVersion).targets\" />\n", 1);
  525. }
  526. }
  527. }
  528. void cmVisualStudio10TargetGenerator::WriteWinRTReferences()
  529. {
  530. std::vector<std::string> references;
  531. if(const char* vsWinRTReferences =
  532. this->Target->GetProperty("VS_WINRT_REFERENCES"))
  533. {
  534. cmSystemTools::ExpandListArgument(vsWinRTReferences, references);
  535. }
  536. if(this->GlobalGenerator->TargetsWindowsPhone() &&
  537. this->GlobalGenerator->GetSystemVersion() == "8.0" &&
  538. references.empty())
  539. {
  540. references.push_back("platform.winmd");
  541. }
  542. if(!references.empty())
  543. {
  544. this->WriteString("<ItemGroup>\n", 1);
  545. for(std::vector<std::string>::iterator ri = references.begin();
  546. ri != references.end(); ++ri)
  547. {
  548. this->WriteString("<Reference Include=\"", 2);
  549. (*this->BuildFileStream) << cmVS10EscapeXML(*ri) << "\">\n";
  550. this->WriteString("<IsWinMDFile>true</IsWinMDFile>\n", 3);
  551. this->WriteString("</Reference>\n", 2);
  552. }
  553. this->WriteString("</ItemGroup>\n", 1);
  554. }
  555. }
  556. // ConfigurationType Application, Utility StaticLibrary DynamicLibrary
  557. void cmVisualStudio10TargetGenerator::WriteProjectConfigurations()
  558. {
  559. this->WriteString("<ItemGroup Label=\"ProjectConfigurations\">\n", 1);
  560. std::vector<std::string> *configs =
  561. static_cast<cmGlobalVisualStudio7Generator *>
  562. (this->GlobalGenerator)->GetConfigurations();
  563. for(std::vector<std::string>::iterator i = configs->begin();
  564. i != configs->end(); ++i)
  565. {
  566. this->WriteString("<ProjectConfiguration Include=\"", 2);
  567. (*this->BuildFileStream ) << *i << "|" << this->Platform << "\">\n";
  568. this->WriteString("<Configuration>", 3);
  569. (*this->BuildFileStream ) << *i << "</Configuration>\n";
  570. this->WriteString("<Platform>", 3);
  571. (*this->BuildFileStream) << cmVS10EscapeXML(this->Platform)
  572. << "</Platform>\n";
  573. this->WriteString("</ProjectConfiguration>\n", 2);
  574. }
  575. this->WriteString("</ItemGroup>\n", 1);
  576. }
  577. void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
  578. {
  579. std::vector<std::string> *configs =
  580. static_cast<cmGlobalVisualStudio7Generator *>
  581. (this->GlobalGenerator)->GetConfigurations();
  582. for(std::vector<std::string>::iterator i = configs->begin();
  583. i != configs->end(); ++i)
  584. {
  585. this->WritePlatformConfigTag("PropertyGroup",
  586. i->c_str(),
  587. 1, " Label=\"Configuration\"", "\n");
  588. std::string configType = "<ConfigurationType>";
  589. switch(this->Target->GetType())
  590. {
  591. case cmTarget::SHARED_LIBRARY:
  592. case cmTarget::MODULE_LIBRARY:
  593. configType += "DynamicLibrary";
  594. break;
  595. case cmTarget::OBJECT_LIBRARY:
  596. case cmTarget::STATIC_LIBRARY:
  597. configType += "StaticLibrary";
  598. break;
  599. case cmTarget::EXECUTABLE:
  600. if(this->NsightTegra &&
  601. !this->Target->GetPropertyAsBool("ANDROID_GUI"))
  602. {
  603. // Android executables are .so too.
  604. configType += "DynamicLibrary";
  605. }
  606. else
  607. {
  608. configType += "Application";
  609. }
  610. break;
  611. case cmTarget::UTILITY:
  612. case cmTarget::GLOBAL_TARGET:
  613. if(this->NsightTegra)
  614. {
  615. // Tegra-Android platform does not understand "Utility".
  616. configType += "StaticLibrary";
  617. }
  618. else
  619. {
  620. configType += "Utility";
  621. }
  622. break;
  623. case cmTarget::UNKNOWN_LIBRARY:
  624. case cmTarget::INTERFACE_LIBRARY:
  625. break;
  626. }
  627. configType += "</ConfigurationType>\n";
  628. this->WriteString(configType.c_str(), 2);
  629. if(this->MSTools)
  630. {
  631. this->WriteMSToolConfigurationValues(*i);
  632. }
  633. else if(this->NsightTegra)
  634. {
  635. this->WriteNsightTegraConfigurationValues(*i);
  636. }
  637. this->WriteString("</PropertyGroup>\n", 1);
  638. }
  639. }
  640. //----------------------------------------------------------------------------
  641. void cmVisualStudio10TargetGenerator
  642. ::WriteMSToolConfigurationValues(std::string const& config)
  643. {
  644. cmGlobalVisualStudio10Generator* gg =
  645. static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
  646. const char* mfcFlag =
  647. this->Target->GetMakefile()->GetDefinition("CMAKE_MFC_FLAG");
  648. std::string mfcFlagValue = mfcFlag ? mfcFlag : "0";
  649. std::string useOfMfcValue = "false";
  650. if(mfcFlagValue == "1")
  651. {
  652. useOfMfcValue = "Static";
  653. }
  654. else if(mfcFlagValue == "2")
  655. {
  656. useOfMfcValue = "Dynamic";
  657. }
  658. std::string mfcLine = "<UseOfMfc>";
  659. mfcLine += useOfMfcValue + "</UseOfMfc>\n";
  660. this->WriteString(mfcLine.c_str(), 2);
  661. if((this->Target->GetType() <= cmTarget::OBJECT_LIBRARY &&
  662. this->ClOptions[config]->UsingUnicode()) ||
  663. this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT") ||
  664. this->GlobalGenerator->TargetsWindowsPhone() ||
  665. this->GlobalGenerator->TargetsWindowsStore() ||
  666. this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS"))
  667. {
  668. this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2);
  669. }
  670. else if (this->Target->GetType() <= cmTarget::MODULE_LIBRARY &&
  671. this->ClOptions[config]->UsingSBCS())
  672. {
  673. this->WriteString("<CharacterSet>NotSet</CharacterSet>\n", 2);
  674. }
  675. else
  676. {
  677. this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2);
  678. }
  679. if(const char* toolset = gg->GetPlatformToolset())
  680. {
  681. std::string pts = "<PlatformToolset>";
  682. pts += toolset;
  683. pts += "</PlatformToolset>\n";
  684. this->WriteString(pts.c_str(), 2);
  685. }
  686. if(this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT") ||
  687. this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS"))
  688. {
  689. this->WriteString("<WindowsAppContainer>true"
  690. "</WindowsAppContainer>\n", 2);
  691. }
  692. }
  693. //----------------------------------------------------------------------------
  694. void cmVisualStudio10TargetGenerator
  695. ::WriteNsightTegraConfigurationValues(std::string const&)
  696. {
  697. cmGlobalVisualStudio10Generator* gg =
  698. static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
  699. const char* toolset = gg->GetPlatformToolset();
  700. std::string ntv = "<NdkToolchainVersion>";
  701. ntv += toolset? toolset : "Default";
  702. ntv += "</NdkToolchainVersion>\n";
  703. this->WriteString(ntv.c_str(), 2);
  704. if(const char* minApi = this->Target->GetProperty("ANDROID_API_MIN"))
  705. {
  706. this->WriteString("<AndroidMinAPI>", 2);
  707. (*this->BuildFileStream ) <<
  708. "android-" << cmVS10EscapeXML(minApi) << "</AndroidMinAPI>\n";
  709. }
  710. if(const char* api = this->Target->GetProperty("ANDROID_API"))
  711. {
  712. this->WriteString("<AndroidTargetAPI>", 2);
  713. (*this->BuildFileStream ) <<
  714. "android-" << cmVS10EscapeXML(api) << "</AndroidTargetAPI>\n";
  715. }
  716. }
  717. void cmVisualStudio10TargetGenerator::WriteCustomCommands()
  718. {
  719. this->SourcesVisited.clear();
  720. std::vector<cmSourceFile const*> customCommands;
  721. this->GeneratorTarget->GetCustomCommands(customCommands, "");
  722. for(std::vector<cmSourceFile const*>::const_iterator
  723. si = customCommands.begin();
  724. si != customCommands.end(); ++si)
  725. {
  726. this->WriteCustomCommand(*si);
  727. }
  728. }
  729. //----------------------------------------------------------------------------
  730. void cmVisualStudio10TargetGenerator
  731. ::WriteCustomCommand(cmSourceFile const* sf)
  732. {
  733. if(this->SourcesVisited.insert(sf).second)
  734. {
  735. if(std::vector<cmSourceFile*> const* depends =
  736. this->GeneratorTarget->GetSourceDepends(sf))
  737. {
  738. for(std::vector<cmSourceFile*>::const_iterator di = depends->begin();
  739. di != depends->end(); ++di)
  740. {
  741. this->WriteCustomCommand(*di);
  742. }
  743. }
  744. if(cmCustomCommand const* command = sf->GetCustomCommand())
  745. {
  746. this->WriteString("<ItemGroup>\n", 1);
  747. this->WriteCustomRule(sf, *command);
  748. this->WriteString("</ItemGroup>\n", 1);
  749. }
  750. }
  751. }
  752. void
  753. cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source,
  754. cmCustomCommand const &
  755. command)
  756. {
  757. std::string sourcePath = source->GetFullPath();
  758. // VS 10 will always rebuild a custom command attached to a .rule
  759. // file that doesn't exist so create the file explicitly.
  760. if (source->GetPropertyAsBool("__CMAKE_RULE"))
  761. {
  762. if(!cmSystemTools::FileExists(sourcePath.c_str()))
  763. {
  764. // Make sure the path exists for the file
  765. std::string path = cmSystemTools::GetFilenamePath(sourcePath);
  766. cmSystemTools::MakeDirectory(path.c_str());
  767. cmsys::ofstream fout(sourcePath.c_str());
  768. if(fout)
  769. {
  770. fout << "# generated from CMake\n";
  771. fout.flush();
  772. fout.close();
  773. }
  774. else
  775. {
  776. std::string error = "Could not create file: [";
  777. error += sourcePath;
  778. error += "] ";
  779. cmSystemTools::Error
  780. (error.c_str(), cmSystemTools::GetLastSystemError().c_str());
  781. }
  782. }
  783. }
  784. cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
  785. std::vector<std::string> *configs =
  786. static_cast<cmGlobalVisualStudio7Generator *>
  787. (this->GlobalGenerator)->GetConfigurations();
  788. this->WriteSource("CustomBuild", source, ">\n");
  789. for(std::vector<std::string>::iterator i = configs->begin();
  790. i != configs->end(); ++i)
  791. {
  792. cmCustomCommandGenerator ccg(command, *i, this->Makefile);
  793. std::string comment = lg->ConstructComment(ccg);
  794. comment = cmVS10EscapeComment(comment);
  795. std::string script =
  796. cmVS10EscapeXML(lg->ConstructScript(ccg));
  797. this->WritePlatformConfigTag("Message",i->c_str(), 3);
  798. (*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "</Message>\n";
  799. this->WritePlatformConfigTag("Command", i->c_str(), 3);
  800. (*this->BuildFileStream ) << script << "</Command>\n";
  801. this->WritePlatformConfigTag("AdditionalInputs", i->c_str(), 3);
  802. (*this->BuildFileStream ) << cmVS10EscapeXML(source->GetFullPath());
  803. for(std::vector<std::string>::const_iterator d =
  804. ccg.GetDepends().begin();
  805. d != ccg.GetDepends().end();
  806. ++d)
  807. {
  808. std::string dep;
  809. if(this->LocalGenerator->GetRealDependency(d->c_str(), i->c_str(), dep))
  810. {
  811. this->ConvertToWindowsSlash(dep);
  812. (*this->BuildFileStream ) << ";" << cmVS10EscapeXML(dep);
  813. }
  814. }
  815. (*this->BuildFileStream ) << ";%(AdditionalInputs)</AdditionalInputs>\n";
  816. this->WritePlatformConfigTag("Outputs", i->c_str(), 3);
  817. const char* sep = "";
  818. for(std::vector<std::string>::const_iterator o =
  819. ccg.GetOutputs().begin();
  820. o != ccg.GetOutputs().end();
  821. ++o)
  822. {
  823. std::string out = *o;
  824. this->ConvertToWindowsSlash(out);
  825. (*this->BuildFileStream ) << sep << cmVS10EscapeXML(out);
  826. sep = ";";
  827. }
  828. (*this->BuildFileStream ) << "</Outputs>\n";
  829. if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10)
  830. {
  831. // VS >= 11 let us turn off linking of custom command outputs.
  832. this->WritePlatformConfigTag("LinkObjects", i->c_str(), 3);
  833. (*this->BuildFileStream ) << "false</LinkObjects>\n";
  834. }
  835. }
  836. this->WriteString("</CustomBuild>\n", 2);
  837. }
  838. std::string
  839. cmVisualStudio10TargetGenerator::ConvertPath(std::string const& path,
  840. bool forceRelative)
  841. {
  842. return forceRelative
  843. ? cmSystemTools::RelativePath(
  844. this->Makefile->GetCurrentOutputDirectory(), path.c_str())
  845. : this->LocalGenerator->Convert(path.c_str(),
  846. cmLocalGenerator::START_OUTPUT,
  847. cmLocalGenerator::UNCHANGED,
  848. /* optional = */ true);
  849. }
  850. void cmVisualStudio10TargetGenerator::ConvertToWindowsSlash(std::string& s)
  851. {
  852. // first convert all of the slashes
  853. std::string::size_type pos = 0;
  854. while((pos = s.find('/', pos)) != std::string::npos)
  855. {
  856. s[pos] = '\\';
  857. pos++;
  858. }
  859. }
  860. void cmVisualStudio10TargetGenerator::WriteGroups()
  861. {
  862. // collect up group information
  863. std::vector<cmSourceGroup> sourceGroups =
  864. this->Makefile->GetSourceGroups();
  865. std::vector<cmSourceFile*> classes;
  866. if (!this->Target->GetConfigCommonSourceFiles(classes))
  867. {
  868. return;
  869. }
  870. std::set<cmSourceGroup*> groupsUsed;
  871. for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();
  872. s != classes.end(); s++)
  873. {
  874. cmSourceFile* sf = *s;
  875. std::string const& source = sf->GetFullPath();
  876. cmSourceGroup* sourceGroup =
  877. this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
  878. groupsUsed.insert(sourceGroup);
  879. }
  880. this->AddMissingSourceGroups(groupsUsed, sourceGroups);
  881. // Write out group file
  882. std::string path = this->Makefile->GetStartOutputDirectory();
  883. path += "/";
  884. path += this->Name;
  885. path += ".vcxproj.filters";
  886. cmGeneratedFileStream fout(path.c_str());
  887. fout.SetCopyIfDifferent(true);
  888. char magic[] = {char(0xEF), char(0xBB), char(0xBF)};
  889. fout.write(magic, 3);
  890. cmGeneratedFileStream* save = this->BuildFileStream;
  891. this->BuildFileStream = & fout;
  892. //get the tools version to use
  893. const std::string toolsVer(this->GlobalGenerator->GetToolsVersion());
  894. std::string project_defaults=
  895. "<?xml version=\"1.0\" encoding=\"" +
  896. this->GlobalGenerator->Encoding() + "\"?>\n";
  897. project_defaults.append("<Project ToolsVersion=\"");
  898. project_defaults.append(toolsVer +"\" ");
  899. project_defaults.append(
  900. "xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n");
  901. this->WriteString(project_defaults.c_str(),0);
  902. for(ToolSourceMap::const_iterator ti = this->Tools.begin();
  903. ti != this->Tools.end(); ++ti)
  904. {
  905. this->WriteGroupSources(ti->first.c_str(), ti->second, sourceGroups);
  906. }
  907. // Added files are images and the manifest.
  908. if (!this->AddedFiles.empty())
  909. {
  910. this->WriteString("<ItemGroup>\n", 1);
  911. for(std::vector<std::string>::const_iterator
  912. oi = this->AddedFiles.begin(); oi != this->AddedFiles.end(); ++oi)
  913. {
  914. std::string fileName = cmSystemTools::LowerCase(
  915. cmSystemTools::GetFilenameName(*oi));
  916. if (fileName == "wmappmanifest.xml")
  917. {
  918. this->WriteString("<XML Include=\"", 2);
  919. (*this->BuildFileStream) << *oi << "\">\n";
  920. this->WriteString("<Filter>Resource Files</Filter>\n", 3);
  921. this->WriteString("</XML>\n", 2);
  922. }
  923. else if(cmSystemTools::GetFilenameExtension(fileName) ==
  924. ".appxmanifest")
  925. {
  926. this->WriteString("<AppxManifest Include=\"", 2);
  927. (*this->BuildFileStream) << *oi << "\">\n";
  928. this->WriteString("<Filter>Resource Files</Filter>\n", 3);
  929. this->WriteString("</AppxManifest>\n", 2);
  930. }
  931. else if(cmSystemTools::GetFilenameExtension(fileName) ==
  932. ".pfx")
  933. {
  934. this->WriteString("<None Include=\"", 2);
  935. (*this->BuildFileStream) << *oi << "\">\n";
  936. this->WriteString("<Filter>Resource Files</Filter>\n", 3);
  937. this->WriteString("</None>\n", 2);
  938. }
  939. else
  940. {
  941. this->WriteString("<Image Include=\"", 2);
  942. (*this->BuildFileStream) << *oi << "\">\n";
  943. this->WriteString("<Filter>Resource Files</Filter>\n", 3);
  944. this->WriteString("</Image>\n", 2);
  945. }
  946. }
  947. this->WriteString("</ItemGroup>\n", 1);
  948. }
  949. std::vector<cmSourceFile const*> resxObjs;
  950. this->GeneratorTarget->GetResxSources(resxObjs, "");
  951. if(!resxObjs.empty())
  952. {
  953. this->WriteString("<ItemGroup>\n", 1);
  954. for(std::vector<cmSourceFile const*>::const_iterator oi = resxObjs.begin();
  955. oi != resxObjs.end(); ++oi)
  956. {
  957. std::string obj = (*oi)->GetFullPath();
  958. this->WriteString("<EmbeddedResource Include=\"", 2);
  959. this->ConvertToWindowsSlash(obj);
  960. (*this->BuildFileStream ) << cmVS10EscapeXML(obj) << "\">\n";
  961. this->WriteString("<Filter>Resource Files</Filter>\n", 3);
  962. this->WriteString("</EmbeddedResource>\n", 2);
  963. }
  964. this->WriteString("</ItemGroup>\n", 1);
  965. }
  966. // Add object library contents as external objects.
  967. std::vector<std::string> objs;
  968. this->GeneratorTarget->UseObjectLibraries(objs, "");
  969. if(!objs.empty())
  970. {
  971. this->WriteString("<ItemGroup>\n", 1);
  972. for(std::vector<std::string>::const_iterator
  973. oi = objs.begin(); oi != objs.end(); ++oi)
  974. {
  975. std::string obj = *oi;
  976. this->WriteString("<Object Include=\"", 2);
  977. this->ConvertToWindowsSlash(obj);
  978. (*this->BuildFileStream ) << cmVS10EscapeXML(obj) << "\">\n";
  979. this->WriteString("<Filter>Object Libraries</Filter>\n", 3);
  980. this->WriteString("</Object>\n", 2);
  981. }
  982. this->WriteString("</ItemGroup>\n", 1);
  983. }
  984. this->WriteString("<ItemGroup>\n", 1);
  985. for(std::set<cmSourceGroup*>::iterator g = groupsUsed.begin();
  986. g != groupsUsed.end(); ++g)
  987. {
  988. cmSourceGroup* sg = *g;
  989. const char* name = sg->GetFullName();
  990. if(strlen(name) != 0)
  991. {
  992. this->WriteString("<Filter Include=\"", 2);
  993. (*this->BuildFileStream) << name << "\">\n";
  994. std::string guidName = "SG_Filter_";
  995. guidName += name;
  996. this->GlobalGenerator->CreateGUID(guidName.c_str());
  997. this->WriteString("<UniqueIdentifier>", 3);
  998. std::string guid
  999. = this->GlobalGenerator->GetGUID(guidName.c_str());
  1000. (*this->BuildFileStream)
  1001. << "{"
  1002. << guid << "}"
  1003. << "</UniqueIdentifier>\n";
  1004. this->WriteString("</Filter>\n", 2);
  1005. }
  1006. }
  1007. if(!objs.empty())
  1008. {
  1009. this->WriteString("<Filter Include=\"Object Libraries\">\n", 2);
  1010. std::string guidName = "SG_Filter_Object Libraries";
  1011. this->GlobalGenerator->CreateGUID(guidName.c_str());
  1012. this->WriteString("<UniqueIdentifier>", 3);
  1013. std::string guid =
  1014. this->GlobalGenerator->GetGUID(guidName.c_str());
  1015. (*this->BuildFileStream) << "{" << guid << "}"
  1016. << "</UniqueIdentifier>\n";
  1017. this->WriteString("</Filter>\n", 2);
  1018. }
  1019. if(!resxObjs.empty() || !this->AddedFiles.empty())
  1020. {
  1021. this->WriteString("<Filter Include=\"Resource Files\">\n", 2);
  1022. std::string guidName = "SG_Filter_Resource Files";
  1023. this->GlobalGenerator->CreateGUID(guidName.c_str());
  1024. this->WriteString("<UniqueIdentifier>", 3);
  1025. std::string guid =
  1026. this->GlobalGenerator->GetGUID(guidName.c_str());
  1027. (*this->BuildFileStream) << "{" << guid << "}"
  1028. << "</UniqueIdentifier>\n";
  1029. this->WriteString("<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;", 3);
  1030. (*this->BuildFileStream) << "gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;";
  1031. (*this->BuildFileStream) << "mfcribbon-ms</Extensions>\n";
  1032. this->WriteString("</Filter>\n", 2);
  1033. }
  1034. this->WriteString("</ItemGroup>\n", 1);
  1035. this->WriteString("</Project>\n", 0);
  1036. // restore stream pointer
  1037. this->BuildFileStream = save;
  1038. if (fout.Close())
  1039. {
  1040. this->GlobalGenerator->FileReplacedDuringGenerate(path);
  1041. }
  1042. }
  1043. // Add to groupsUsed empty source groups that have non-empty children.
  1044. void
  1045. cmVisualStudio10TargetGenerator::AddMissingSourceGroups(
  1046. std::set<cmSourceGroup*>& groupsUsed,
  1047. const std::vector<cmSourceGroup>& allGroups
  1048. )
  1049. {
  1050. for(std::vector<cmSourceGroup>::const_iterator current = allGroups.begin();
  1051. current != allGroups.end(); ++current)
  1052. {
  1053. std::vector<cmSourceGroup> const& children = current->GetGroupChildren();
  1054. if(children.empty())
  1055. {
  1056. continue; // the group is really empty
  1057. }
  1058. this->AddMissingSourceGroups(groupsUsed, children);
  1059. cmSourceGroup* current_ptr = const_cast<cmSourceGroup*>(&(*current));
  1060. if(groupsUsed.find(current_ptr) != groupsUsed.end())
  1061. {
  1062. continue; // group has already been added to set
  1063. }
  1064. // check if it least one of the group's descendants is not empty
  1065. // (at least one child must already have been added)
  1066. std::vector<cmSourceGroup>::const_iterator child_it = children.begin();
  1067. while(child_it != children.end())
  1068. {
  1069. cmSourceGroup* child_ptr = const_cast<cmSourceGroup*>(&(*child_it));
  1070. if(groupsUsed.find(child_ptr) != groupsUsed.end())
  1071. {
  1072. break; // found a child that was already added => add current group too
  1073. }
  1074. child_it++;
  1075. }
  1076. if(child_it == children.end())
  1077. {
  1078. continue; // no descendants have source files => ignore this group
  1079. }
  1080. groupsUsed.insert(current_ptr);
  1081. }
  1082. }
  1083. void
  1084. cmVisualStudio10TargetGenerator::
  1085. WriteGroupSources(const char* name,
  1086. ToolSources const& sources,
  1087. std::vector<cmSourceGroup>& sourceGroups)
  1088. {
  1089. this->WriteString("<ItemGroup>\n", 1);
  1090. for(ToolSources::const_iterator s = sources.begin();
  1091. s != sources.end(); ++s)
  1092. {
  1093. cmSourceFile const* sf = s->SourceFile;
  1094. std::string const& source = sf->GetFullPath();
  1095. cmSourceGroup* sourceGroup =
  1096. this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
  1097. const char* filter = sourceGroup->GetFullName();
  1098. this->WriteString("<", 2);
  1099. std::string path = this->ConvertPath(source, s->RelativePath);
  1100. this->ConvertToWindowsSlash(path);
  1101. (*this->BuildFileStream) << name << " Include=\""
  1102. << cmVS10EscapeXML(path);
  1103. if(strlen(filter))
  1104. {
  1105. (*this->BuildFileStream) << "\">\n";
  1106. this->WriteString("<Filter>", 3);
  1107. (*this->BuildFileStream) << filter << "</Filter>\n";
  1108. this->WriteString("</", 2);
  1109. (*this->BuildFileStream) << name << ">\n";
  1110. }
  1111. else
  1112. {
  1113. (*this->BuildFileStream) << "\" />\n";
  1114. }
  1115. }
  1116. this->WriteString("</ItemGroup>\n", 1);
  1117. }
  1118. void cmVisualStudio10TargetGenerator::WriteHeaderSource(cmSourceFile const* sf)
  1119. {
  1120. if(this->IsResxHeader(sf->GetFullPath()))
  1121. {
  1122. this->WriteSource("ClInclude", sf, ">\n");
  1123. this->WriteString("<FileType>CppForm</FileType>\n", 3);
  1124. this->WriteString("</ClInclude>\n", 2);
  1125. }
  1126. else
  1127. {
  1128. this->WriteSource("ClInclude", sf);
  1129. }
  1130. }
  1131. void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
  1132. {
  1133. bool toolHasSettings = false;
  1134. std::string tool = "None";
  1135. std::string shaderType;
  1136. std::string shaderEntryPoint;
  1137. std::string shaderModel;
  1138. std::string shaderAdditionalFlags;
  1139. std::string ext = cmSystemTools::LowerCase(sf->GetExtension());
  1140. if(ext == "hlsl")
  1141. {
  1142. tool = "FXCompile";
  1143. // Figure out the type of shader compiler to use.
  1144. if(const char* st = sf->GetProperty("VS_SHADER_TYPE"))
  1145. {
  1146. shaderType = st;
  1147. toolHasSettings = true;
  1148. }
  1149. // Figure out which entry point to use if any
  1150. if (const char* se = sf->GetProperty("VS_SHADER_ENTRYPOINT"))
  1151. {
  1152. shaderEntryPoint = se;
  1153. toolHasSettings = true;
  1154. }
  1155. // Figure out which shader model to use if any
  1156. if (const char* sm = sf->GetProperty("VS_SHADER_MODEL"))
  1157. {
  1158. shaderModel = sm;
  1159. toolHasSettings = true;
  1160. }
  1161. // Figure out if there's any additional flags to use
  1162. if (const char* saf = sf->GetProperty("VS_SHADER_FLAGS"))
  1163. {
  1164. shaderAdditionalFlags = saf;
  1165. toolHasSettings = true;
  1166. }
  1167. }
  1168. else if(ext == "jpg" ||
  1169. ext == "png")
  1170. {
  1171. tool = "Image";
  1172. }
  1173. else if(ext == "xml")
  1174. {
  1175. tool = "XML";
  1176. }
  1177. if(this->NsightTegra)
  1178. {
  1179. // Nsight Tegra needs specific file types to check up-to-dateness.
  1180. std::string name =
  1181. cmSystemTools::LowerCase(sf->GetLocation().GetName());
  1182. if(name == "androidmanifest.xml" ||
  1183. name == "build.xml" ||
  1184. name == "proguard.cfg" ||
  1185. name == "proguard-project.txt" ||
  1186. ext == "properties")
  1187. {
  1188. tool = "AndroidBuild";
  1189. }
  1190. else if(ext == "java")
  1191. {
  1192. tool = "JCompile";
  1193. }
  1194. else if(ext == "asm" || ext == "s")
  1195. {
  1196. tool = "ClCompile";
  1197. }
  1198. }
  1199. std::string deployContent;
  1200. std::string deployLocation;
  1201. if(this->GlobalGenerator->TargetsWindowsPhone() ||
  1202. this->GlobalGenerator->TargetsWindowsStore())
  1203. {
  1204. const char* content = sf->GetProperty("VS_DEPLOYMENT_CONTENT");
  1205. if(content && *content)
  1206. {
  1207. toolHasSettings = true;
  1208. deployContent = content;
  1209. const char* location = sf->GetProperty("VS_DEPLOYMENT_LOCATION");
  1210. if(location && *location)
  1211. {
  1212. deployLocation = location;
  1213. }
  1214. }
  1215. }
  1216. if(toolHasSettings)
  1217. {
  1218. this->WriteSource(tool, sf, ">\n");
  1219. if(!deployContent.empty())
  1220. {
  1221. std::vector<std::string> const* configs =
  1222. this->GlobalGenerator->GetConfigurations();
  1223. cmGeneratorExpression ge;
  1224. cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
  1225. ge.Parse(deployContent);
  1226. // Deployment location cannot be set on a configuration basis
  1227. if(!deployLocation.empty())
  1228. {
  1229. this->WriteString("<Link>", 3);
  1230. (*this->BuildFileStream) << deployLocation
  1231. << "\\%(FileName)%(Extension)";
  1232. this->WriteString("</Link>\n", 0);
  1233. }
  1234. for(size_t i = 0; i != configs->size(); ++i)
  1235. {
  1236. if(0 == strcmp(cge->Evaluate(this->Makefile, (*configs)[i]), "1"))
  1237. {
  1238. this->WriteString("<DeploymentContent Condition=\""
  1239. "'$(Configuration)|$(Platform)'=='", 3);
  1240. (*this->BuildFileStream) << (*configs)[i] << "|"
  1241. << this->Platform << "'\">true";
  1242. this->WriteString("</DeploymentContent>\n", 0);
  1243. }
  1244. else
  1245. {
  1246. this->WriteString("<ExcludedFromBuild Condition=\""
  1247. "'$(Configuration)|$(Platform)'=='", 3);
  1248. (*this->BuildFileStream) << (*configs)[i] << "|"
  1249. << this->Platform << "'\">true";
  1250. this->WriteString("</ExcludedFromBuild>\n", 0);
  1251. }
  1252. }
  1253. }
  1254. if(!shaderType.empty())
  1255. {
  1256. this->WriteString("<ShaderType>", 3);
  1257. (*this->BuildFileStream) << cmVS10EscapeXML(shaderType)
  1258. << "</ShaderType>\n";
  1259. }
  1260. if(!shaderEntryPoint.empty())
  1261. {
  1262. this->WriteString("<EntryPointName>", 3);
  1263. (*this->BuildFileStream) << cmVS10EscapeXML(shaderEntryPoint)
  1264. << "</EntryPointName>\n";
  1265. }
  1266. if(!shaderModel.empty())
  1267. {
  1268. this->WriteString("<ShaderModel>", 3);
  1269. (*this->BuildFileStream) << cmVS10EscapeXML(shaderModel)
  1270. << "</ShaderModel>\n";
  1271. }
  1272. if(!shaderAdditionalFlags.empty())
  1273. {
  1274. this->WriteString("<AdditionalOptions>", 3);
  1275. (*this->BuildFileStream) << cmVS10EscapeXML(shaderAdditionalFlags)
  1276. << "</AdditionalOptions>\n";
  1277. }
  1278. this->WriteString("</", 2);
  1279. (*this->BuildFileStream) << tool << ">\n";
  1280. }
  1281. else
  1282. {
  1283. this->WriteSource(tool, sf);
  1284. }
  1285. }
  1286. void cmVisualStudio10TargetGenerator::WriteSource(
  1287. std::string const& tool, cmSourceFile const* sf, const char* end)
  1288. {
  1289. // Visual Studio tools append relative paths to the current dir, as in:
  1290. //
  1291. // c:\path\to\current\dir\..\..\..\relative\path\to\source.c
  1292. //
  1293. // and fail if this exceeds the maximum allowed path length. Our path
  1294. // conversion uses full paths when possible to allow deeper trees.
  1295. bool forceRelative = false;
  1296. std::string sourceFile = this->ConvertPath(sf->GetFullPath(), false);
  1297. if(this->LocalGenerator->GetVersion() == cmLocalVisualStudioGenerator::VS10
  1298. && cmSystemTools::FileIsFullPath(sourceFile.c_str()))
  1299. {
  1300. // Normal path conversion resulted in a full path. VS 10 (but not 11)
  1301. // refuses to show the property page in the IDE for a source file with a
  1302. // full path (not starting in a '.' or '/' AFAICT). CMake <= 2.8.4 used a
  1303. // relative path but to allow deeper build trees CMake 2.8.[5678] used a
  1304. // full path except for custom commands. Custom commands do not work
  1305. // without a relative path, but they do not seem to be involved in tools
  1306. // with the above behavior. For other sources we now use a relative path
  1307. // when the combined path will not be too long so property pages appear.
  1308. std::string sourceRel = this->ConvertPath(sf->GetFullPath(), true);
  1309. size_t const maxLen = 250;
  1310. if(sf->GetCustomCommand() ||
  1311. ((strlen(this->Makefile->GetCurrentOutputDirectory()) + 1 +
  1312. sourceRel.length()) <= maxLen))
  1313. {
  1314. forceRelative = true;
  1315. sourceFile = sourceRel;
  1316. }
  1317. else
  1318. {
  1319. this->GlobalGenerator->PathTooLong(this->Target, sf, sourceRel);
  1320. }
  1321. }
  1322. this->ConvertToWindowsSlash(sourceFile);
  1323. this->WriteString("<", 2);
  1324. (*this->BuildFileStream ) << tool << " Include=\""
  1325. << cmVS10EscapeXML(sourceFile) << "\""
  1326. << (end? end : " />\n");
  1327. ToolSource toolSource = {sf, forceRelative};
  1328. this->Tools[tool].push_back(toolSource);
  1329. }
  1330. void cmVisualStudio10TargetGenerator::WriteSources(
  1331. std::string const& tool, std::vector<cmSourceFile const*> const& sources)
  1332. {
  1333. for(std::vector<cmSourceFile const*>::const_iterator
  1334. si = sources.begin(); si != sources.end(); ++si)
  1335. {
  1336. this->WriteSource(tool, *si);
  1337. }
  1338. }
  1339. void cmVisualStudio10TargetGenerator::WriteAllSources()
  1340. {
  1341. if(this->Target->GetType() > cmTarget::UTILITY)
  1342. {
  1343. return;
  1344. }
  1345. this->WriteString("<ItemGroup>\n", 1);
  1346. std::vector<cmSourceFile const*> headerSources;
  1347. this->GeneratorTarget->GetHeaderSources(headerSources, "");
  1348. for(std::vector<cmSourceFile const*>::const_iterator
  1349. si = headerSources.begin(); si != headerSources.end(); ++si)
  1350. {
  1351. this->WriteHeaderSource(*si);
  1352. }
  1353. std::vector<cmSourceFile const*> idlSources;
  1354. this->GeneratorTarget->GetIDLSources(idlSources, "");
  1355. this->WriteSources("Midl", idlSources);
  1356. std::vector<cmSourceFile const*> objectSources;
  1357. this->GeneratorTarget->GetObjectSources(objectSources, "");
  1358. for(std::vector<cmSourceFile const*>::const_iterator
  1359. si = objectSources.begin();
  1360. si != objectSources.end(); ++si)
  1361. {
  1362. const std::string& lang = (*si)->GetLanguage();
  1363. std::string tool;
  1364. if (lang == "C"|| lang == "CXX")
  1365. {
  1366. tool = "ClCompile";
  1367. }
  1368. else if (lang == "ASM_MASM" &&
  1369. this->GlobalGenerator->IsMasmEnabled())
  1370. {
  1371. tool = "MASM";
  1372. }
  1373. else if (lang == "RC")
  1374. {
  1375. tool = "ResourceCompile";
  1376. }
  1377. if (!tool.empty())
  1378. {
  1379. this->WriteSource(tool, *si, " ");
  1380. if (this->OutputSourceSpecificFlags(*si))
  1381. {
  1382. this->WriteString("</", 2);
  1383. (*this->BuildFileStream ) << tool << ">\n";
  1384. }
  1385. else
  1386. {
  1387. (*this->BuildFileStream ) << " />\n";
  1388. }
  1389. }
  1390. else
  1391. {
  1392. this->WriteSource("None", *si);
  1393. }
  1394. }
  1395. std::vector<cmSourceFile const*> manifestSources;
  1396. this->GeneratorTarget->GetAppManifest(manifestSources, "");
  1397. this->WriteSources("AppxManifest", manifestSources);
  1398. std::vector<cmSourceFile const*> certificateSources;
  1399. this->GeneratorTarget->GetCertificates(certificateSources, "");
  1400. this->WriteSources("None", certificateSources);
  1401. std::vector<cmSourceFile const*> externalObjects;
  1402. this->GeneratorTarget->GetExternalObjects(externalObjects, "");
  1403. for(std::vector<cmSourceFile const*>::iterator
  1404. si = externalObjects.begin();
  1405. si != externalObjects.end(); )
  1406. {
  1407. if (!(*si)->GetObjectLibrary().empty())
  1408. {
  1409. si = externalObjects.erase(si);
  1410. }
  1411. else
  1412. {
  1413. ++si;
  1414. }
  1415. }
  1416. if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10)
  1417. {
  1418. // For VS >= 11 we use LinkObjects to avoid linking custom command
  1419. // outputs. Use Object for all external objects, generated or not.
  1420. this->WriteSources("Object", externalObjects);
  1421. }
  1422. else
  1423. {
  1424. // If an object file is generated in this target, then vs10 will use
  1425. // it in the build, and we have to list it as None instead of Object.
  1426. for(std::vector<cmSourceFile const*>::const_iterator
  1427. si = externalObjects.begin();
  1428. si != externalObjects.end(); ++si)
  1429. {
  1430. std::vector<cmSourceFile*> const* d =
  1431. this->GeneratorTarget->GetSourceDepends(*si);
  1432. this->WriteSource((d && !d->empty())? "None":"Object", *si);
  1433. }
  1434. }
  1435. std::vector<cmSourceFile const*> extraSources;
  1436. this->GeneratorTarget->GetExtraSources(extraSources, "");
  1437. for(std::vector<cmSourceFile const*>::const_iterator
  1438. si = extraSources.begin(); si != extraSources.end(); ++si)
  1439. {
  1440. this->WriteExtraSource(*si);
  1441. }
  1442. // Add object library contents as external objects.
  1443. std::vector<std::string> objs;
  1444. this->GeneratorTarget->UseObjectLibraries(objs, "");
  1445. for(std::vector<std::string>::const_iterator
  1446. oi = objs.begin(); oi != objs.end(); ++oi)
  1447. {
  1448. std::string obj = *oi;
  1449. this->WriteString("<Object Include=\"", 2);
  1450. this->ConvertToWindowsSlash(obj);
  1451. (*this->BuildFileStream ) << cmVS10EscapeXML(obj) << "\" />\n";
  1452. }
  1453. if (this->IsMissingFiles)
  1454. {
  1455. this->WriteMissingFiles();
  1456. }
  1457. this->WriteString("</ItemGroup>\n", 1);
  1458. }
  1459. bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
  1460. cmSourceFile const* source)
  1461. {
  1462. cmSourceFile const& sf = *source;
  1463. std::string objectName;
  1464. if(this->GeneratorTarget->HasExplicitObjectName(&sf))
  1465. {
  1466. objectName = this->GeneratorTarget->GetObjectName(&sf);
  1467. }
  1468. std::string flags;
  1469. std::string defines;
  1470. if(const char* cflags = sf.GetProperty("COMPILE_FLAGS"))
  1471. {
  1472. flags += cflags;
  1473. }
  1474. if(const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS"))
  1475. {
  1476. defines += cdefs;
  1477. }
  1478. std::string lang =
  1479. this->GlobalGenerator->GetLanguageFromExtension
  1480. (sf.GetExtension().c_str());
  1481. std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf);
  1482. const std::string& linkLanguage = this->Target->GetLinkerLanguage();
  1483. bool needForceLang = false;
  1484. // source file does not match its extension language
  1485. if(lang != sourceLang)
  1486. {
  1487. needForceLang = true;
  1488. lang = sourceLang;
  1489. }
  1490. // if the source file does not match the linker language
  1491. // then force c or c++
  1492. const char* compileAs = 0;
  1493. if(needForceLang || (linkLanguage != lang))
  1494. {
  1495. if(lang == "CXX")
  1496. {
  1497. // force a C++ file type
  1498. compileAs = "CompileAsCpp";
  1499. }
  1500. else if(lang == "C")
  1501. {
  1502. // force to c
  1503. compileAs = "CompileAsC";
  1504. }
  1505. }
  1506. bool noWinRT = this->TargetCompileAsWinRT && lang == "C";
  1507. bool hasFlags = false;
  1508. // for the first time we need a new line if there is something
  1509. // produced here.
  1510. const char* firstString = ">\n";
  1511. if(objectName.size())
  1512. {
  1513. (*this->BuildFileStream ) << firstString;
  1514. firstString = "";
  1515. hasFlags = true;
  1516. this->WriteString("<ObjectFileName>", 3);
  1517. (*this->BuildFileStream )
  1518. << "$(IntDir)/" << objectName << "</ObjectFileName>\n";
  1519. }
  1520. std::vector<std::string> *configs =
  1521. static_cast<cmGlobalVisualStudio7Generator *>
  1522. (this->GlobalGenerator)->GetConfigurations();
  1523. for( std::vector<std::string>::iterator config = configs->begin();
  1524. config != configs->end(); ++config)
  1525. {
  1526. std::string configUpper = cmSystemTools::UpperCase(*config);
  1527. std::string configDefines = defines;
  1528. std::string defPropName = "COMPILE_DEFINITIONS_";
  1529. defPropName += configUpper;
  1530. if(const char* ccdefs = sf.GetProperty(defPropName.c_str()))
  1531. {
  1532. if(configDefines.size())
  1533. {
  1534. configDefines += ";";
  1535. }
  1536. configDefines += ccdefs;
  1537. }
  1538. // if we have flags or defines for this config then
  1539. // use them
  1540. if(!flags.empty() || !configDefines.empty() || compileAs || noWinRT)
  1541. {
  1542. (*this->BuildFileStream ) << firstString;
  1543. firstString = ""; // only do firstString once
  1544. hasFlags = true;
  1545. cmVisualStudioGeneratorOptions
  1546. clOptions(this->LocalGenerator,
  1547. cmVisualStudioGeneratorOptions::Compiler,
  1548. this->GetClFlagTable(), 0, this);
  1549. if(compileAs)
  1550. {
  1551. clOptions.AddFlag("CompileAs", compileAs);
  1552. }
  1553. if(noWinRT)
  1554. {
  1555. clOptions.AddFlag("CompileAsWinRT", "false");
  1556. }
  1557. clOptions.Parse(flags.c_str());
  1558. if(clOptions.HasFlag("AdditionalIncludeDirectories"))
  1559. {
  1560. clOptions.AppendFlag("AdditionalIncludeDirectories",
  1561. "%(AdditionalIncludeDirectories)");
  1562. }
  1563. if(clOptions.HasFlag("DisableSpecificWarnings"))
  1564. {
  1565. clOptions.AppendFlag("DisableSpecificWarnings",
  1566. "%(DisableSpecificWarnings)");
  1567. }
  1568. clOptions.AddDefines(configDefines.c_str());
  1569. clOptions.SetConfiguration((*config).c_str());
  1570. clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
  1571. clOptions.OutputFlagMap(*this->BuildFileStream, " ");
  1572. clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream,
  1573. " ", "\n", lang);
  1574. }
  1575. }
  1576. return hasFlags;
  1577. }
  1578. void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
  1579. {
  1580. cmTarget::TargetType ttype = this->Target->GetType();
  1581. if(ttype > cmTarget::GLOBAL_TARGET)
  1582. {
  1583. return;
  1584. }
  1585. this->WriteString("<PropertyGroup>\n", 2);
  1586. this->WriteString("<_ProjectFileVersion>10.0.20506.1"
  1587. "</_ProjectFileVersion>\n", 3);
  1588. std::vector<std::string> *configs =
  1589. static_cast<cmGlobalVisualStudio7Generator *>
  1590. (this->GlobalGenerator)->GetConfigurations();
  1591. for(std::vector<std::string>::iterator config = configs->begin();
  1592. config != configs->end(); ++config)
  1593. {
  1594. if(ttype >= cmTarget::UTILITY)
  1595. {
  1596. this->WritePlatformConfigTag("IntDir", config->c_str(), 3);
  1597. *this->BuildFileStream
  1598. << "$(Platform)\\$(Configuration)\\$(ProjectName)\\"
  1599. << "</IntDir>\n";
  1600. }
  1601. else
  1602. {
  1603. std::string intermediateDir = this->LocalGenerator->
  1604. GetTargetDirectory(*this->Target);
  1605. intermediateDir += "/";
  1606. intermediateDir += *config;
  1607. intermediateDir += "/";
  1608. std::string outDir;
  1609. std::string targetNameFull;
  1610. if(ttype == cmTarget::OBJECT_LIBRARY)
  1611. {
  1612. outDir = intermediateDir;
  1613. targetNameFull = this->Target->GetName();
  1614. targetNameFull += ".lib";
  1615. }
  1616. else
  1617. {
  1618. outDir = this->Target->GetDirectory(config->c_str()) + "/";
  1619. targetNameFull = this->Target->GetFullName(config->c_str());
  1620. }
  1621. this->ConvertToWindowsSlash(intermediateDir);
  1622. this->ConvertToWindowsSlash(outDir);
  1623. this->WritePlatformConfigTag("OutDir", config->c_str(), 3);
  1624. *this->BuildFileStream << cmVS10EscapeXML(outDir)
  1625. << "</OutDir>\n";
  1626. this->WritePlatformConfigTag("IntDir", config->c_str(), 3);
  1627. *this->BuildFileStream << cmVS10EscapeXML(intermediateDir)
  1628. << "</IntDir>\n";
  1629. std::string name =
  1630. cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull);
  1631. this->WritePlatformConfigTag("TargetName", config->c_str(), 3);
  1632. *this->BuildFileStream << cmVS10EscapeXML(name) << "</TargetName>\n";
  1633. std::string ext =
  1634. cmSystemTools::GetFilenameLastExtension(targetNameFull);
  1635. if(ext.empty())
  1636. {
  1637. // An empty TargetExt causes a default extension to be used.
  1638. // A single "." appears to be treated as an empty extension.
  1639. ext = ".";
  1640. }
  1641. this->WritePlatformConfigTag("TargetExt", config->c_str(), 3);
  1642. *this->BuildFileStream << cmVS10EscapeXML(ext) << "</TargetExt>\n";
  1643. this->OutputLinkIncremental(*config);
  1644. }
  1645. }
  1646. this->WriteString("</PropertyGroup>\n", 2);
  1647. }
  1648. void
  1649. cmVisualStudio10TargetGenerator::
  1650. OutputLinkIncremental(std::string const& configName)
  1651. {
  1652. if(!this->MSTools)
  1653. {
  1654. return;
  1655. }
  1656. // static libraries and things greater than modules do not need
  1657. // to set this option
  1658. if(this->Target->GetType() == cmTarget::STATIC_LIBRARY
  1659. || this->Target->GetType() > cmTarget::MODULE_LIBRARY)
  1660. {
  1661. return;
  1662. }
  1663. Options& linkOptions = *(this->LinkOptions[configName]);
  1664. const char* incremental = linkOptions.GetFlag("LinkIncremental");
  1665. this->WritePlatformConfigTag("LinkIncremental", configName.c_str(), 3);
  1666. *this->BuildFileStream << (incremental?incremental:"true")
  1667. << "</LinkIncremental>\n";
  1668. linkOptions.RemoveFlag("LinkIncremental");
  1669. const char* manifest = linkOptions.GetFlag("GenerateManifest");
  1670. this->WritePlatformConfigTag("GenerateManifest", configName.c_str(), 3);
  1671. *this->BuildFileStream << (manifest?manifest:"true")
  1672. << "</GenerateManifest>\n";
  1673. linkOptions.RemoveFlag("GenerateManifest");
  1674. // Some link options belong here. Use them now and remove them so that
  1675. // WriteLinkOptions does not use them.
  1676. const char* flags[] = {
  1677. "LinkDelaySign",
  1678. "LinkKeyFile",
  1679. 0};
  1680. for(const char** f = flags; *f; ++f)
  1681. {
  1682. const char* flag = *f;
  1683. if(const char* value = linkOptions.GetFlag(flag))
  1684. {
  1685. this->WritePlatformConfigTag(flag, configName.c_str(), 3);
  1686. *this->BuildFileStream << value << "</" << flag << ">\n";
  1687. linkOptions.RemoveFlag(flag);
  1688. }
  1689. }
  1690. }
  1691. //----------------------------------------------------------------------------
  1692. bool cmVisualStudio10TargetGenerator::ComputeClOptions()
  1693. {
  1694. std::vector<std::string> const* configs =
  1695. this->GlobalGenerator->GetConfigurations();
  1696. for(std::vector<std::string>::const_iterator i = configs->begin();
  1697. i != configs->end(); ++i)
  1698. {
  1699. if(!this->ComputeClOptions(*i))
  1700. {
  1701. return false;
  1702. }
  1703. }
  1704. return true;
  1705. }
  1706. //----------------------------------------------------------------------------
  1707. bool cmVisualStudio10TargetGenerator::ComputeClOptions(
  1708. std::string const& configName)
  1709. {
  1710. // much of this was copied from here:
  1711. // copied from cmLocalVisualStudio7Generator.cxx 805
  1712. // TODO: Integrate code below with cmLocalVisualStudio7Generator.
  1713. cmsys::auto_ptr<Options> pOptions(
  1714. new Options(this->LocalGenerator, Options::Compiler,
  1715. this->GetClFlagTable()));
  1716. Options& clOptions = *pOptions;
  1717. std::string flags;
  1718. const std::string& linkLanguage =
  1719. this->Target->GetLinkerLanguage(configName.c_str());
  1720. if(linkLanguage.empty())
  1721. {
  1722. cmSystemTools::Error
  1723. ("CMake can not determine linker language for target: ",
  1724. this->Name.c_str());
  1725. return false;
  1726. }
  1727. if(linkLanguage == "C" || linkLanguage == "CXX"
  1728. || linkLanguage == "Fortran")
  1729. {
  1730. std::string baseFlagVar = "CMAKE_";
  1731. baseFlagVar += linkLanguage;
  1732. baseFlagVar += "_FLAGS";
  1733. flags = this->
  1734. Target->GetMakefile()->GetRequiredDefinition(baseFlagVar.c_str());
  1735. std::string flagVar = baseFlagVar + std::string("_") +
  1736. cmSystemTools::UpperCase(configName);
  1737. flags += " ";
  1738. flags += this->
  1739. Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str());
  1740. }
  1741. // set the correct language
  1742. if(linkLanguage == "C")
  1743. {
  1744. clOptions.AddFlag("CompileAs", "CompileAsC");
  1745. }
  1746. if(linkLanguage == "CXX")
  1747. {
  1748. clOptions.AddFlag("CompileAs", "CompileAsCpp");
  1749. }
  1750. this->LocalGenerator->AddCompileOptions(flags, this->Target,
  1751. linkLanguage, configName.c_str());
  1752. // Get preprocessor definitions for this directory.
  1753. std::string defineFlags = this->Target->GetMakefile()->GetDefineFlags();
  1754. if(this->MSTools)
  1755. {
  1756. clOptions.FixExceptionHandlingDefault();
  1757. clOptions.AddFlag("PrecompiledHeader", "NotUsing");
  1758. std::string asmLocation = configName + "/";
  1759. clOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str());
  1760. }
  1761. clOptions.Parse(flags.c_str());
  1762. clOptions.Parse(defineFlags.c_str());
  1763. std::vector<std::string> targetDefines;
  1764. this->Target->GetCompileDefinitions(targetDefines,
  1765. configName.c_str(), "CXX");
  1766. clOptions.AddDefines(targetDefines);
  1767. if(this->MSTools)
  1768. {
  1769. clOptions.SetVerboseMakefile(
  1770. this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
  1771. }
  1772. // Add a definition for the configuration name.
  1773. std::string configDefine = "CMAKE_INTDIR=\"";
  1774. configDefine += configName;
  1775. configDefine += "\"";
  1776. clOptions.AddDefine(configDefine);
  1777. if(const char* exportMacro = this->Target->GetExportMacro())
  1778. {
  1779. clOptions.AddDefine(exportMacro);
  1780. }
  1781. if (this->MSTools)
  1782. {
  1783. // If we have the VS_WINRT_COMPONENT set then force Compile as WinRT.
  1784. if (this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT"))
  1785. {
  1786. clOptions.AddFlag("CompileAsWinRT", "true");
  1787. // For WinRT components, add the _WINRT_DLL define to produce a lib
  1788. if (this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
  1789. this->Target->GetType() == cmTarget::MODULE_LIBRARY )
  1790. {
  1791. clOptions.AddDefine("_WINRT_DLL");
  1792. }
  1793. }
  1794. else if (this->GlobalGenerator->TargetsWindowsStore() ||
  1795. this->GlobalGenerator->TargetsWindowsPhone())
  1796. {
  1797. if (!clOptions.IsWinRt())
  1798. {
  1799. clOptions.AddFlag("CompileAsWinRT", "false");
  1800. }
  1801. }
  1802. if(const char* winRT = clOptions.GetFlag("CompileAsWinRT"))
  1803. {
  1804. if(cmSystemTools::IsOn(winRT))
  1805. {
  1806. this->TargetCompileAsWinRT = true;
  1807. }
  1808. }
  1809. }
  1810. this->ClOptions[configName] = pOptions.release();
  1811. return true;
  1812. }
  1813. //----------------------------------------------------------------------------
  1814. void cmVisualStudio10TargetGenerator::WriteClOptions(
  1815. std::string const& configName,
  1816. std::vector<std::string> const& includes)
  1817. {
  1818. Options& clOptions = *(this->ClOptions[configName]);
  1819. this->WriteString("<ClCompile>\n", 2);
  1820. clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
  1821. clOptions.AppendFlag("AdditionalIncludeDirectories", includes);
  1822. clOptions.AppendFlag("AdditionalIncludeDirectories",
  1823. "%(AdditionalIncludeDirectories)");
  1824. clOptions.OutputFlagMap(*this->BuildFileStream, " ");
  1825. clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
  1826. "\n", "CXX");
  1827. if(this->MSTools)
  1828. {
  1829. this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3);
  1830. // If not in debug mode, write the DebugInformationFormat field
  1831. // without value so PDBs don't get generated uselessly.
  1832. if(!clOptions.IsDebug())
  1833. {
  1834. this->WriteString("<DebugInformationFormat>"
  1835. "</DebugInformationFormat>\n", 3);
  1836. }
  1837. // Specify the compiler program database file if configured.
  1838. std::string pdb = this->Target->GetCompilePDBPath(configName.c_str());
  1839. if(!pdb.empty())
  1840. {
  1841. this->ConvertToWindowsSlash(pdb);
  1842. this->WriteString("<ProgramDataBaseFileName>", 3);
  1843. *this->BuildFileStream << cmVS10EscapeXML(pdb)
  1844. << "</ProgramDataBaseFileName>\n";
  1845. }
  1846. }
  1847. this->WriteString("</ClCompile>\n", 2);
  1848. }
  1849. //----------------------------------------------------------------------------
  1850. bool cmVisualStudio10TargetGenerator::ComputeRcOptions()
  1851. {
  1852. std::vector<std::string> const* configs =
  1853. this->GlobalGenerator->GetConfigurations();
  1854. for(std::vector<std::string>::const_iterator i = configs->begin();
  1855. i != configs->end(); ++i)
  1856. {
  1857. if(!this->ComputeRcOptions(*i))
  1858. {
  1859. return false;
  1860. }
  1861. }
  1862. return true;
  1863. }
  1864. //----------------------------------------------------------------------------
  1865. bool cmVisualStudio10TargetGenerator::ComputeRcOptions(
  1866. std::string const& configName)
  1867. {
  1868. cmsys::auto_ptr<Options> pOptions(
  1869. new Options(this->LocalGenerator, Options::ResourceCompiler,
  1870. this->GetRcFlagTable()));
  1871. Options& rcOptions = *pOptions;
  1872. std::string CONFIG = cmSystemTools::UpperCase(configName);
  1873. std::string rcConfigFlagsVar = std::string("CMAKE_RC_FLAGS_") + CONFIG;
  1874. std::string flags =
  1875. std::string(this->Makefile->GetSafeDefinition("CMAKE_RC_FLAGS")) +
  1876. std::string(" ") +
  1877. std::string(this->Makefile->GetSafeDefinition(rcConfigFlagsVar));
  1878. rcOptions.Parse(flags.c_str());
  1879. this->RcOptions[configName] = pOptions.release();
  1880. return true;
  1881. }
  1882. void cmVisualStudio10TargetGenerator::
  1883. WriteRCOptions(std::string const& configName,
  1884. std::vector<std::string> const & includes)
  1885. {
  1886. if(!this->MSTools)
  1887. {
  1888. return;
  1889. }
  1890. this->WriteString("<ResourceCompile>\n", 2);
  1891. // Preprocessor definitions and includes are shared with clOptions.
  1892. Options& clOptions = *(this->ClOptions[configName]);
  1893. clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
  1894. "\n", "RC");
  1895. Options& rcOptions = *(this->RcOptions[configName]);
  1896. rcOptions.AppendFlag("AdditionalIncludeDirectories", includes);
  1897. rcOptions.AppendFlag("AdditionalIncludeDirectories",
  1898. "%(AdditionalIncludeDirectories)");
  1899. rcOptions.OutputFlagMap(*this->BuildFileStream, " ");
  1900. rcOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
  1901. this->WriteString("</ResourceCompile>\n", 2);
  1902. }
  1903. //----------------------------------------------------------------------------
  1904. bool cmVisualStudio10TargetGenerator::ComputeMasmOptions()
  1905. {
  1906. if(!this->GlobalGenerator->IsMasmEnabled())
  1907. {
  1908. return true;
  1909. }
  1910. std::vector<std::string> const* configs =
  1911. this->GlobalGenerator->GetConfigurations();
  1912. for(std::vector<std::string>::const_iterator i = configs->begin();
  1913. i != configs->end(); ++i)
  1914. {
  1915. if(!this->ComputeMasmOptions(*i))
  1916. {
  1917. return false;
  1918. }
  1919. }
  1920. return true;
  1921. }
  1922. //----------------------------------------------------------------------------
  1923. bool cmVisualStudio10TargetGenerator::ComputeMasmOptions(
  1924. std::string const& configName)
  1925. {
  1926. cmsys::auto_ptr<Options> pOptions(
  1927. new Options(this->LocalGenerator, Options::MasmCompiler,
  1928. this->GetMasmFlagTable()));
  1929. Options& masmOptions = *pOptions;
  1930. std::string CONFIG = cmSystemTools::UpperCase(configName);
  1931. std::string configFlagsVar = std::string("CMAKE_ASM_MASM_FLAGS_") + CONFIG;
  1932. std::string flags =
  1933. std::string(this->Makefile->GetSafeDefinition("CMAKE_ASM_MASM_FLAGS")) +
  1934. std::string(" ") +
  1935. std::string(this->Makefile->GetSafeDefinition(configFlagsVar));
  1936. masmOptions.Parse(flags.c_str());
  1937. this->MasmOptions[configName] = pOptions.release();
  1938. return true;
  1939. }
  1940. void cmVisualStudio10TargetGenerator::
  1941. WriteMasmOptions(std::string const& configName,
  1942. std::vector<std::string> const& includes)
  1943. {
  1944. if(!this->MSTools || !this->GlobalGenerator->IsMasmEnabled())
  1945. {
  1946. return;
  1947. }
  1948. this->WriteString("<MASM>\n", 2);
  1949. // Preprocessor definitions and includes are shared with clOptions.
  1950. Options& clOptions = *(this->ClOptions[configName]);
  1951. clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
  1952. "\n", "ASM_MASM");
  1953. Options& masmOptions = *(this->MasmOptions[configName]);
  1954. masmOptions.AppendFlag("IncludePaths", includes);
  1955. masmOptions.AppendFlag("IncludePaths", "%(IncludePaths)");
  1956. masmOptions.OutputFlagMap(*this->BuildFileStream, " ");
  1957. masmOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
  1958. this->WriteString("</MASM>\n", 2);
  1959. }
  1960. void
  1961. cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config)
  1962. {
  1963. if(this->Target->GetType() != cmTarget::STATIC_LIBRARY &&
  1964. this->Target->GetType() != cmTarget::OBJECT_LIBRARY)
  1965. {
  1966. return;
  1967. }
  1968. std::string libflags;
  1969. this->LocalGenerator->GetStaticLibraryFlags(libflags,
  1970. cmSystemTools::UpperCase(config), this->Target);
  1971. if(!libflags.empty())
  1972. {
  1973. this->WriteString("<Lib>\n", 2);
  1974. cmVisualStudioGeneratorOptions
  1975. libOptions(this->LocalGenerator,
  1976. cmVisualStudioGeneratorOptions::Linker,
  1977. this->GetLibFlagTable(), 0, this);
  1978. libOptions.Parse(libflags.c_str());
  1979. libOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
  1980. libOptions.OutputFlagMap(*this->BuildFileStream, " ");
  1981. this->WriteString("</Lib>\n", 2);
  1982. }
  1983. // We cannot generate metadata for static libraries. WindowsPhone
  1984. // and WindowsStore tools look at GenerateWindowsMetadata in the
  1985. // Link tool options even for static libraries.
  1986. if(this->GlobalGenerator->TargetsWindowsPhone() ||
  1987. this->GlobalGenerator->TargetsWindowsStore())
  1988. {
  1989. this->WriteString("<Link>\n", 2);
  1990. this->WriteString("<GenerateWindowsMetadata>false"
  1991. "</GenerateWindowsMetadata>\n", 3);
  1992. this->WriteString("</Link>\n", 2);
  1993. }
  1994. }
  1995. //----------------------------------------------------------------------------
  1996. void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
  1997. std::string const&)
  1998. {
  1999. // Look through the sources for AndroidManifest.xml and use
  2000. // its location as the root source directory.
  2001. std::string rootDir = this->Makefile->GetCurrentDirectory();
  2002. {
  2003. std::vector<cmSourceFile const*> extraSources;
  2004. this->GeneratorTarget->GetExtraSources(extraSources, "");
  2005. for(std::vector<cmSourceFile const*>::const_iterator si =
  2006. extraSources.begin(); si != extraSources.end(); ++si)
  2007. {
  2008. if("androidmanifest.xml" == cmSystemTools::LowerCase(
  2009. (*si)->GetLocation().GetName()))
  2010. {
  2011. rootDir = (*si)->GetLocation().GetDirectory();
  2012. break;
  2013. }
  2014. }
  2015. }
  2016. // Tell MSBuild to launch Ant.
  2017. {
  2018. std::string antBuildPath = rootDir;
  2019. this->WriteString("<AntBuild>\n", 2);
  2020. this->WriteString("<AntBuildPath>", 3);
  2021. this->ConvertToWindowsSlash(antBuildPath);
  2022. (*this->BuildFileStream) <<
  2023. cmVS10EscapeXML(antBuildPath) << "</AntBuildPath>\n";
  2024. }
  2025. {
  2026. std::string manifest_xml = rootDir + "/AndroidManifest.xml";
  2027. this->ConvertToWindowsSlash(manifest_xml);
  2028. this->WriteString("<AndroidManifestLocation>", 3);
  2029. (*this->BuildFileStream) <<
  2030. cmVS10EscapeXML(manifest_xml) << "</AndroidManifestLocation>\n";
  2031. }
  2032. this->WriteString("</AntBuild>\n", 2);
  2033. }
  2034. //----------------------------------------------------------------------------
  2035. bool cmVisualStudio10TargetGenerator::ComputeLinkOptions()
  2036. {
  2037. if(this->Target->GetType() == cmTarget::EXECUTABLE ||
  2038. this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
  2039. this->Target->GetType() == cmTarget::MODULE_LIBRARY)
  2040. {
  2041. std::vector<std::string> const* configs =
  2042. this->GlobalGenerator->GetConfigurations();
  2043. for(std::vector<std::string>::const_iterator i = configs->begin();
  2044. i != configs->end(); ++i)
  2045. {
  2046. if(!this->ComputeLinkOptions(*i))
  2047. {
  2048. return false;
  2049. }
  2050. }
  2051. }
  2052. return true;
  2053. }
  2054. //----------------------------------------------------------------------------
  2055. bool
  2056. cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
  2057. {
  2058. cmsys::auto_ptr<Options> pOptions(
  2059. new Options(this->LocalGenerator, Options::Linker,
  2060. this->GetLinkFlagTable(), 0, this));
  2061. Options& linkOptions = *pOptions;
  2062. const std::string& linkLanguage =
  2063. this->Target->GetLinkerLanguage(config.c_str());
  2064. if(linkLanguage.empty())
  2065. {
  2066. cmSystemTools::Error
  2067. ("CMake can not determine linker language for target: ",
  2068. this->Name.c_str());
  2069. return false;
  2070. }
  2071. std::string CONFIG = cmSystemTools::UpperCase(config);
  2072. const char* linkType = "SHARED";
  2073. if(this->Target->GetType() == cmTarget::MODULE_LIBRARY)
  2074. {
  2075. linkType = "MODULE";
  2076. }
  2077. if(this->Target->GetType() == cmTarget::EXECUTABLE)
  2078. {
  2079. linkType = "EXE";
  2080. }
  2081. std::string flags;
  2082. std::string linkFlagVarBase = "CMAKE_";
  2083. linkFlagVarBase += linkType;
  2084. linkFlagVarBase += "_LINKER_FLAGS";
  2085. flags += " ";
  2086. flags += this->
  2087. Target->GetMakefile()->GetRequiredDefinition(linkFlagVarBase.c_str());
  2088. std::string linkFlagVar = linkFlagVarBase + "_" + CONFIG;
  2089. flags += " ";
  2090. flags += this->
  2091. Target->GetMakefile()->GetRequiredDefinition(linkFlagVar.c_str());
  2092. const char* targetLinkFlags = this->Target->GetProperty("LINK_FLAGS");
  2093. if(targetLinkFlags)
  2094. {
  2095. flags += " ";
  2096. flags += targetLinkFlags;
  2097. }
  2098. std::string flagsProp = "LINK_FLAGS_";
  2099. flagsProp += CONFIG;
  2100. if(const char* flagsConfig = this->Target->GetProperty(flagsProp.c_str()))
  2101. {
  2102. flags += " ";
  2103. flags += flagsConfig;
  2104. }
  2105. std::string standardLibsVar = "CMAKE_";
  2106. standardLibsVar += linkLanguage;
  2107. standardLibsVar += "_STANDARD_LIBRARIES";
  2108. std::string
  2109. libs = this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
  2110. // Remove trailing spaces from libs
  2111. std::string::size_type pos = libs.size()-1;
  2112. if(libs.size() != 0)
  2113. {
  2114. while(libs[pos] == ' ')
  2115. {
  2116. pos--;
  2117. }
  2118. }
  2119. if(pos != libs.size()-1)
  2120. {
  2121. libs = libs.substr(0, pos+1);
  2122. }
  2123. // Replace spaces in libs with ;
  2124. cmSystemTools::ReplaceString(libs, " ", ";");
  2125. std::vector<std::string> libVec;
  2126. cmSystemTools::ExpandListArgument(libs, libVec);
  2127. cmComputeLinkInformation* pcli =
  2128. this->Target->GetLinkInformation(config.c_str());
  2129. if(!pcli)
  2130. {
  2131. cmSystemTools::Error
  2132. ("CMake can not compute cmComputeLinkInformation for target: ",
  2133. this->Name.c_str());
  2134. return false;
  2135. }
  2136. // add the libraries for the target to libs string
  2137. cmComputeLinkInformation& cli = *pcli;
  2138. this->AddLibraries(cli, libVec);
  2139. linkOptions.AddFlag("AdditionalDependencies", libVec);
  2140. std::vector<std::string> const& ldirs = cli.GetDirectories();
  2141. std::vector<std::string> linkDirs;
  2142. for(std::vector<std::string>::const_iterator d = ldirs.begin();
  2143. d != ldirs.end(); ++d)
  2144. {
  2145. // first just full path
  2146. linkDirs.push_back(*d);
  2147. // next path with configuration type Debug, Release, etc
  2148. linkDirs.push_back(*d + "/$(Configuration)");
  2149. }
  2150. linkDirs.push_back("%(AdditionalLibraryDirectories)");
  2151. linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs);
  2152. std::string targetName;
  2153. std::string targetNameSO;
  2154. std::string targetNameFull;
  2155. std::string targetNameImport;
  2156. std::string targetNamePDB;
  2157. if(this->Target->GetType() == cmTarget::EXECUTABLE)
  2158. {
  2159. this->Target->GetExecutableNames(targetName, targetNameFull,
  2160. targetNameImport, targetNamePDB,
  2161. config.c_str());
  2162. }
  2163. else
  2164. {
  2165. this->Target->GetLibraryNames(targetName, targetNameSO, targetNameFull,
  2166. targetNameImport, targetNamePDB,
  2167. config.c_str());
  2168. }
  2169. if(this->MSTools)
  2170. {
  2171. linkOptions.AddFlag("Version", "");
  2172. if ( this->Target->GetPropertyAsBool("WIN32_EXECUTABLE") )
  2173. {
  2174. if (this->GlobalGenerator->TargetsWindowsCE())
  2175. {
  2176. linkOptions.AddFlag("SubSystem", "WindowsCE");
  2177. if (this->Target->GetType() == cmTarget::EXECUTABLE)
  2178. {
  2179. if (this->ClOptions[config]->UsingUnicode())
  2180. {
  2181. linkOptions.AddFlag("EntryPointSymbol", "wWinMainCRTStartup");
  2182. }
  2183. else
  2184. {
  2185. linkOptions.AddFlag("EntryPointSymbol", "WinMainCRTStartup");
  2186. }
  2187. }
  2188. }
  2189. else
  2190. {
  2191. linkOptions.AddFlag("SubSystem", "Windows");
  2192. }
  2193. }
  2194. else
  2195. {
  2196. if (this->GlobalGenerator->TargetsWindowsCE())
  2197. {
  2198. linkOptions.AddFlag("SubSystem", "WindowsCE");
  2199. if (this->Target->GetType() == cmTarget::EXECUTABLE)
  2200. {
  2201. if (this->ClOptions[config]->UsingUnicode())
  2202. {
  2203. linkOptions.AddFlag("EntryPointSymbol", "mainWCRTStartup");
  2204. }
  2205. else
  2206. {
  2207. linkOptions.AddFlag("EntryPointSymbol", "mainACRTStartup");
  2208. }
  2209. }
  2210. }
  2211. else
  2212. {
  2213. linkOptions.AddFlag("SubSystem", "Console");
  2214. };
  2215. }
  2216. if(const char* stackVal =
  2217. this->Makefile->GetDefinition("CMAKE_"+linkLanguage+"_STACK_SIZE"))
  2218. {
  2219. linkOptions.AddFlag("StackReserveSize", stackVal);
  2220. }
  2221. if(linkOptions.IsDebug() || flags.find("/debug") != flags.npos)
  2222. {
  2223. linkOptions.AddFlag("GenerateDebugInformation", "true");
  2224. }
  2225. else
  2226. {
  2227. linkOptions.AddFlag("GenerateDebugInformation", "false");
  2228. }
  2229. std::string pdb = this->Target->GetPDBDirectory(config.c_str());
  2230. pdb += "/";
  2231. pdb += targetNamePDB;
  2232. std::string imLib = this->Target->GetDirectory(config.c_str(), true);
  2233. imLib += "/";
  2234. imLib += targetNameImport;
  2235. linkOptions.AddFlag("ImportLibrary", imLib.c_str());
  2236. linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str());
  2237. // A Windows Runtime component uses internal .NET metadata,
  2238. // so does not have an import library.
  2239. if(this->Target->GetPropertyAsBool("VS_WINRT_COMPONENT"))
  2240. {
  2241. linkOptions.AddFlag("GenerateWindowsMetadata", "true");
  2242. }
  2243. else if (this->GlobalGenerator->TargetsWindowsPhone() ||
  2244. this->GlobalGenerator->TargetsWindowsStore())
  2245. {
  2246. // WindowsPhone and WindowsStore components are in an app container
  2247. // and produce WindowsMetadata. If we are not producing a WINRT
  2248. // component, then do not generate the metadata here.
  2249. linkOptions.AddFlag("GenerateWindowsMetadata", "false");
  2250. }
  2251. if (this->GlobalGenerator->TargetsWindowsPhone() &&
  2252. this->GlobalGenerator->GetSystemVersion() == "8.0")
  2253. {
  2254. // WindowsPhone 8.0 does not have ole32.
  2255. linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries", "ole32.lib");
  2256. }
  2257. }
  2258. else if(this->NsightTegra)
  2259. {
  2260. linkOptions.AddFlag("SoName", targetNameSO.c_str());
  2261. }
  2262. linkOptions.Parse(flags.c_str());
  2263. if(this->MSTools)
  2264. {
  2265. std::string def = this->GeneratorTarget->GetModuleDefinitionFile("");
  2266. if(!def.empty())
  2267. {
  2268. linkOptions.AddFlag("ModuleDefinitionFile", def.c_str());
  2269. }
  2270. linkOptions.AppendFlag("IgnoreSpecificDefaultLibraries",
  2271. "%(IgnoreSpecificDefaultLibraries)");
  2272. }
  2273. this->LinkOptions[config] = pOptions.release();
  2274. return true;
  2275. }
  2276. //----------------------------------------------------------------------------
  2277. void
  2278. cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& config)
  2279. {
  2280. if(this->Target->GetType() == cmTarget::STATIC_LIBRARY
  2281. || this->Target->GetType() > cmTarget::MODULE_LIBRARY)
  2282. {
  2283. return;
  2284. }
  2285. Options& linkOptions = *(this->LinkOptions[config]);
  2286. this->WriteString("<Link>\n", 2);
  2287. linkOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
  2288. linkOptions.OutputFlagMap(*this->BuildFileStream, " ");
  2289. this->WriteString("</Link>\n", 2);
  2290. if(!this->GlobalGenerator->NeedLinkLibraryDependencies(*this->Target))
  2291. {
  2292. this->WriteString("<ProjectReference>\n", 2);
  2293. this->WriteString(
  2294. " <LinkLibraryDependencies>false</LinkLibraryDependencies>\n", 2);
  2295. this->WriteString("</ProjectReference>\n", 2);
  2296. }
  2297. }
  2298. void cmVisualStudio10TargetGenerator::AddLibraries(
  2299. cmComputeLinkInformation& cli,
  2300. std::vector<std::string>& libVec)
  2301. {
  2302. typedef cmComputeLinkInformation::ItemVector ItemVector;
  2303. ItemVector libs = cli.GetItems();
  2304. for(ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l)
  2305. {
  2306. if(l->IsPath)
  2307. {
  2308. std::string path = this->LocalGenerator->
  2309. Convert(l->Value.c_str(),
  2310. cmLocalGenerator::START_OUTPUT,
  2311. cmLocalGenerator::UNCHANGED);
  2312. this->ConvertToWindowsSlash(path);
  2313. libVec.push_back(path);
  2314. }
  2315. else if (!l->Target
  2316. || l->Target->GetType() != cmTarget::INTERFACE_LIBRARY)
  2317. {
  2318. libVec.push_back(l->Value);
  2319. }
  2320. }
  2321. }
  2322. void cmVisualStudio10TargetGenerator::
  2323. WriteMidlOptions(std::string const& /*config*/,
  2324. std::vector<std::string> const & includes)
  2325. {
  2326. if(!this->MSTools)
  2327. {
  2328. return;
  2329. }
  2330. // This processes *any* of the .idl files specified in the project's file
  2331. // list (and passed as the item metadata %(Filename) expressing the rule
  2332. // input filename) into output files at the per-config *build* dir
  2333. // ($(IntDir)) each.
  2334. //
  2335. // IOW, this MIDL section is intended to provide a fully generic syntax
  2336. // content suitable for most cases (read: if you get errors, then it's quite
  2337. // probable that the error is on your side of the .idl setup).
  2338. //
  2339. // Also, note that the marked-as-generated _i.c file in the Visual Studio
  2340. // generator case needs to be referred to as $(IntDir)\foo_i.c at the
  2341. // project's file list, otherwise the compiler-side processing won't pick it
  2342. // up (for non-directory form, it ends up looking in project binary dir
  2343. // only). Perhaps there's something to be done to make this more automatic
  2344. // on the CMake side?
  2345. this->WriteString("<Midl>\n", 2);
  2346. this->WriteString("<AdditionalIncludeDirectories>", 3);
  2347. for(std::vector<std::string>::const_iterator i = includes.begin();
  2348. i != includes.end(); ++i)
  2349. {
  2350. *this->BuildFileStream << cmVS10EscapeXML(*i) << ";";
  2351. }
  2352. this->WriteString("%(AdditionalIncludeDirectories)"
  2353. "</AdditionalIncludeDirectories>\n", 0);
  2354. this->WriteString("<OutputDirectory>$(ProjectDir)/$(IntDir)"
  2355. "</OutputDirectory>\n", 3);
  2356. this->WriteString("<HeaderFileName>%(Filename).h</HeaderFileName>\n", 3);
  2357. this->WriteString(
  2358. "<TypeLibraryName>%(Filename).tlb</TypeLibraryName>\n", 3);
  2359. this->WriteString(
  2360. "<InterfaceIdentifierFileName>"
  2361. "%(Filename)_i.c</InterfaceIdentifierFileName>\n", 3);
  2362. this->WriteString("<ProxyFileName>%(Filename)_p.c</ProxyFileName>\n",3);
  2363. this->WriteString("</Midl>\n", 2);
  2364. }
  2365. void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
  2366. {
  2367. std::vector<std::string> *configs =
  2368. static_cast<cmGlobalVisualStudio7Generator *>
  2369. (this->GlobalGenerator)->GetConfigurations();
  2370. for(std::vector<std::string>::iterator i = configs->begin();
  2371. i != configs->end(); ++i)
  2372. {
  2373. std::vector<std::string> includes;
  2374. this->LocalGenerator->GetIncludeDirectories(includes,
  2375. this->GeneratorTarget,
  2376. "C", i->c_str());
  2377. for(std::vector<std::string>::iterator ii = includes.begin();
  2378. ii != includes.end(); ++ii)
  2379. {
  2380. this->ConvertToWindowsSlash(*ii);
  2381. }
  2382. this->WritePlatformConfigTag("ItemDefinitionGroup", i->c_str(), 1);
  2383. *this->BuildFileStream << "\n";
  2384. // output cl compile flags <ClCompile></ClCompile>
  2385. if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY)
  2386. {
  2387. this->WriteClOptions(*i, includes);
  2388. // output rc compile flags <ResourceCompile></ResourceCompile>
  2389. this->WriteRCOptions(*i, includes);
  2390. this->WriteMasmOptions(*i, includes);
  2391. }
  2392. // output midl flags <Midl></Midl>
  2393. this->WriteMidlOptions(*i, includes);
  2394. // write events
  2395. this->WriteEvents(*i);
  2396. // output link flags <Link></Link>
  2397. this->WriteLinkOptions(*i);
  2398. // output lib flags <Lib></Lib>
  2399. this->WriteLibOptions(*i);
  2400. if(this->NsightTegra &&
  2401. this->Target->GetType() == cmTarget::EXECUTABLE &&
  2402. this->Target->GetPropertyAsBool("ANDROID_GUI"))
  2403. {
  2404. this->WriteAntBuildOptions(*i);
  2405. }
  2406. this->WriteString("</ItemDefinitionGroup>\n", 1);
  2407. }
  2408. }
  2409. void
  2410. cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName)
  2411. {
  2412. this->WriteEvent("PreLinkEvent",
  2413. this->Target->GetPreLinkCommands(), configName);
  2414. this->WriteEvent("PreBuildEvent",
  2415. this->Target->GetPreBuildCommands(), configName);
  2416. this->WriteEvent("PostBuildEvent",
  2417. this->Target->GetPostBuildCommands(), configName);
  2418. }
  2419. void cmVisualStudio10TargetGenerator::WriteEvent(
  2420. const char* name,
  2421. std::vector<cmCustomCommand> const& commands,
  2422. std::string const& configName)
  2423. {
  2424. if(commands.size() == 0)
  2425. {
  2426. return;
  2427. }
  2428. this->WriteString("<", 2);
  2429. (*this->BuildFileStream ) << name << ">\n";
  2430. cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
  2431. std::string script;
  2432. const char* pre = "";
  2433. std::string comment;
  2434. for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
  2435. i != commands.end(); ++i)
  2436. {
  2437. cmCustomCommandGenerator ccg(*i, configName, this->Makefile);
  2438. comment += pre;
  2439. comment += lg->ConstructComment(ccg);
  2440. script += pre;
  2441. pre = "\n";
  2442. script += cmVS10EscapeXML(lg->ConstructScript(ccg));
  2443. }
  2444. comment = cmVS10EscapeComment(comment);
  2445. this->WriteString("<Message>",3);
  2446. (*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "</Message>\n";
  2447. this->WriteString("<Command>", 3);
  2448. (*this->BuildFileStream ) << script;
  2449. (*this->BuildFileStream ) << "</Command>" << "\n";
  2450. this->WriteString("</", 2);
  2451. (*this->BuildFileStream ) << name << ">\n";
  2452. }
  2453. void cmVisualStudio10TargetGenerator::WriteProjectReferences()
  2454. {
  2455. cmGlobalGenerator::TargetDependSet const& unordered
  2456. = this->GlobalGenerator->GetTargetDirectDepends(*this->Target);
  2457. typedef cmGlobalVisualStudioGenerator::OrderedTargetDependSet
  2458. OrderedTargetDependSet;
  2459. OrderedTargetDependSet depends(unordered);
  2460. this->WriteString("<ItemGroup>\n", 1);
  2461. for( OrderedTargetDependSet::const_iterator i = depends.begin();
  2462. i != depends.end(); ++i)
  2463. {
  2464. cmTarget const* dt = *i;
  2465. if(dt->GetType() == cmTarget::INTERFACE_LIBRARY)
  2466. {
  2467. continue;
  2468. }
  2469. // skip fortran targets as they can not be processed by MSBuild
  2470. // the only reference will be in the .sln file
  2471. if(static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
  2472. ->TargetIsFortranOnly(*dt))
  2473. {
  2474. continue;
  2475. }
  2476. this->WriteString("<ProjectReference Include=\"", 2);
  2477. cmMakefile* mf = dt->GetMakefile();
  2478. std::string name = dt->GetName();
  2479. std::string path;
  2480. const char* p = dt->GetProperty("EXTERNAL_MSPROJECT");
  2481. if(p)
  2482. {
  2483. path = p;
  2484. }
  2485. else
  2486. {
  2487. path = mf->GetStartOutputDirectory();
  2488. path += "/";
  2489. path += dt->GetName();
  2490. path += ".vcxproj";
  2491. }
  2492. (*this->BuildFileStream) << cmVS10EscapeXML(path) << "\">\n";
  2493. this->WriteString("<Project>", 3);
  2494. (*this->BuildFileStream)
  2495. << this->GlobalGenerator->GetGUID(name.c_str())
  2496. << "</Project>\n";
  2497. this->WriteString("</ProjectReference>\n", 2);
  2498. }
  2499. this->WriteString("</ItemGroup>\n", 1);
  2500. }
  2501. void cmVisualStudio10TargetGenerator::WriteWinRTPackageCertificateKeyFile()
  2502. {
  2503. if((this->GlobalGenerator->TargetsWindowsStore() ||
  2504. this->GlobalGenerator->TargetsWindowsPhone())
  2505. && (cmTarget::EXECUTABLE == this->Target->GetType()))
  2506. {
  2507. std::string pfxFile;
  2508. std::vector<cmSourceFile const*> certificates;
  2509. this->GeneratorTarget->GetCertificates(certificates, "");
  2510. for(std::vector<cmSourceFile const*>::const_iterator si =
  2511. certificates.begin(); si != certificates.end(); ++si)
  2512. {
  2513. pfxFile = this->ConvertPath((*si)->GetFullPath(), false);
  2514. this->ConvertToWindowsSlash(pfxFile);
  2515. break;
  2516. }
  2517. if(this->IsMissingFiles &&
  2518. !(this->GlobalGenerator->TargetsWindowsPhone() &&
  2519. this->GlobalGenerator->GetSystemVersion() == "8.0"))
  2520. {
  2521. // Move the manifest to a project directory to avoid clashes
  2522. std::string artifactDir =
  2523. this->LocalGenerator->GetTargetDirectory(*this->Target);
  2524. this->ConvertToWindowsSlash(artifactDir);
  2525. this->WriteString("<PropertyGroup>\n", 1);
  2526. this->WriteString("<AppxPackageArtifactsDir>", 2);
  2527. (*this->BuildFileStream) << cmVS10EscapeXML(artifactDir) <<
  2528. "\\</AppxPackageArtifactsDir>\n";
  2529. this->WriteString("<ProjectPriFullPath>"
  2530. "$(TargetDir)resources.pri</ProjectPriFullPath>", 2);
  2531. // If we are missing files and we don't have a certificate and
  2532. // aren't targeting WP8.0, add a default certificate
  2533. if(pfxFile.empty())
  2534. {
  2535. std::string templateFolder = cmSystemTools::GetCMakeRoot() +
  2536. "/Templates/Windows";
  2537. pfxFile = this->DefaultArtifactDir + "/Windows_TemporaryKey.pfx";
  2538. cmSystemTools::CopyAFile(templateFolder + "/Windows_TemporaryKey.pfx",
  2539. pfxFile, false);
  2540. this->ConvertToWindowsSlash(pfxFile);
  2541. this->AddedFiles.push_back(pfxFile);
  2542. }
  2543. this->WriteString("<", 2);
  2544. (*this->BuildFileStream) << "PackageCertificateKeyFile>"
  2545. << pfxFile << "</PackageCertificateKeyFile>\n";
  2546. this->WriteString("</PropertyGroup>\n", 1);
  2547. }
  2548. else if(!pfxFile.empty())
  2549. {
  2550. this->WriteString("<PropertyGroup>\n", 1);
  2551. this->WriteString("<", 2);
  2552. (*this->BuildFileStream) << "PackageCertificateKeyFile>"
  2553. << pfxFile << "</PackageCertificateKeyFile>\n";
  2554. this->WriteString("</PropertyGroup>\n", 1);
  2555. }
  2556. }
  2557. }
  2558. bool cmVisualStudio10TargetGenerator::
  2559. IsResxHeader(const std::string& headerFile)
  2560. {
  2561. std::set<std::string> expectedResxHeaders;
  2562. this->GeneratorTarget->GetExpectedResxHeaders(expectedResxHeaders, "");
  2563. std::set<std::string>::const_iterator it =
  2564. expectedResxHeaders.find(headerFile);
  2565. return it != expectedResxHeaders.end();
  2566. }
  2567. void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
  2568. {
  2569. bool isAppContainer = false;
  2570. bool const isWindowsPhone = this->GlobalGenerator->TargetsWindowsPhone();
  2571. bool const isWindowsStore = this->GlobalGenerator->TargetsWindowsStore();
  2572. std::string const& v = this->GlobalGenerator->GetSystemVersion();
  2573. if(isWindowsPhone || isWindowsStore)
  2574. {
  2575. this->WriteString("<ApplicationType>", 2);
  2576. (*this->BuildFileStream) << (isWindowsPhone ?
  2577. "Windows Phone" : "Windows Store")
  2578. << "</ApplicationType>\n";
  2579. this->WriteString("<ApplicationTypeRevision>", 2);
  2580. (*this->BuildFileStream) << cmVS10EscapeXML(v)
  2581. << "</ApplicationTypeRevision>\n";
  2582. this->WriteString("<DefaultLanguage>en-US"
  2583. "</DefaultLanguage>\n", 2);
  2584. if(v == "8.1")
  2585. {
  2586. // Visual Studio 12.0 is necessary for building 8.1 apps
  2587. this->WriteString("<MinimumVisualStudioVersion>12.0"
  2588. "</MinimumVisualStudioVersion>\n", 2);
  2589. if (this->Target->GetType() < cmTarget::UTILITY)
  2590. {
  2591. isAppContainer = true;
  2592. }
  2593. }
  2594. else if (v == "8.0")
  2595. {
  2596. // Visual Studio 11.0 is necessary for building 8.0 apps
  2597. this->WriteString("<MinimumVisualStudioVersion>11.0"
  2598. "</MinimumVisualStudioVersion>\n", 2);
  2599. if (isWindowsStore && this->Target->GetType() < cmTarget::UTILITY)
  2600. {
  2601. isAppContainer = true;
  2602. }
  2603. else if (isWindowsPhone &&
  2604. this->Target->GetType() == cmTarget::EXECUTABLE)
  2605. {
  2606. this->WriteString("<XapOutputs>true</XapOutputs>\n", 2);
  2607. this->WriteString("<XapFilename>", 2);
  2608. (*this->BuildFileStream) << cmVS10EscapeXML(this->Name.c_str()) <<
  2609. "_$(Configuration)_$(Platform).xap</XapFilename>\n";
  2610. }
  2611. }
  2612. }
  2613. if(isAppContainer)
  2614. {
  2615. this->WriteString("<AppContainerApplication>true"
  2616. "</AppContainerApplication>\n", 2);
  2617. }
  2618. else if (this->Platform == "ARM")
  2619. {
  2620. this->WriteString("<WindowsSDKDesktopARMSupport>true"
  2621. "</WindowsSDKDesktopARMSupport>\n", 2);
  2622. }
  2623. }
  2624. void cmVisualStudio10TargetGenerator::VerifyNecessaryFiles()
  2625. {
  2626. // For Windows and Windows Phone executables, we will assume that if a
  2627. // manifest is not present that we need to add all the necessary files
  2628. if (this->Target->GetType() == cmTarget::EXECUTABLE)
  2629. {
  2630. std::vector<cmSourceFile const*> manifestSources;
  2631. this->GeneratorTarget->GetAppManifest(manifestSources, "");
  2632. {
  2633. std::string const& v = this->GlobalGenerator->GetSystemVersion();
  2634. if(this->GlobalGenerator->TargetsWindowsPhone())
  2635. {
  2636. if (v == "8.0")
  2637. {
  2638. // Look through the sources for WMAppManifest.xml
  2639. std::vector<cmSourceFile const*> extraSources;
  2640. this->GeneratorTarget->GetExtraSources(extraSources, "");
  2641. bool foundManifest = false;
  2642. for(std::vector<cmSourceFile const*>::const_iterator si =
  2643. extraSources.begin(); si != extraSources.end(); ++si)
  2644. {
  2645. // Need to do a lowercase comparison on the filename
  2646. if("wmappmanifest.xml" == cmSystemTools::LowerCase(
  2647. (*si)->GetLocation().GetName()))
  2648. {
  2649. foundManifest = true;
  2650. break;
  2651. }
  2652. }
  2653. if (!foundManifest)
  2654. {
  2655. this->IsMissingFiles = true;
  2656. }
  2657. }
  2658. else if (v == "8.1")
  2659. {
  2660. if(manifestSources.empty())
  2661. {
  2662. this->IsMissingFiles = true;
  2663. }
  2664. }
  2665. }
  2666. else if (this->GlobalGenerator->TargetsWindowsStore())
  2667. {
  2668. if (manifestSources.empty())
  2669. {
  2670. if (v == "8.0")
  2671. {
  2672. this->IsMissingFiles = true;
  2673. }
  2674. else if (v == "8.1")
  2675. {
  2676. this->IsMissingFiles = true;
  2677. }
  2678. }
  2679. }
  2680. }
  2681. }
  2682. }
  2683. void cmVisualStudio10TargetGenerator::WriteMissingFiles()
  2684. {
  2685. std::string const& v = this->GlobalGenerator->GetSystemVersion();
  2686. if(this->GlobalGenerator->TargetsWindowsPhone())
  2687. {
  2688. if (v == "8.0")
  2689. {
  2690. this->WriteMissingFilesWP80();
  2691. }
  2692. else if (v == "8.1")
  2693. {
  2694. this->WriteMissingFilesWP81();
  2695. }
  2696. }
  2697. else if (this->GlobalGenerator->TargetsWindowsStore())
  2698. {
  2699. if (v == "8.0")
  2700. {
  2701. this->WriteMissingFilesWS80();
  2702. }
  2703. else if (v == "8.1")
  2704. {
  2705. this->WriteMissingFilesWS81();
  2706. }
  2707. }
  2708. }
  2709. void cmVisualStudio10TargetGenerator::WriteMissingFilesWP80()
  2710. {
  2711. std::string templateFolder = cmSystemTools::GetCMakeRoot() +
  2712. "/Templates/Windows";
  2713. // For WP80, the manifest needs to be in the same folder as the project
  2714. // this can cause an overwrite problem if projects aren't organized in
  2715. // folders
  2716. std::string manifestFile = this->Makefile->GetStartOutputDirectory() +
  2717. std::string("/WMAppManifest.xml");
  2718. std::string artifactDir =
  2719. this->LocalGenerator->GetTargetDirectory(*this->Target);
  2720. this->ConvertToWindowsSlash(artifactDir);
  2721. std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
  2722. std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName());
  2723. cmGeneratedFileStream fout(manifestFile.c_str());
  2724. fout.SetCopyIfDifferent(true);
  2725. fout <<
  2726. "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
  2727. "<Deployment"
  2728. " xmlns=\"http://schemas.microsoft.com/windowsphone/2012/deployment\""
  2729. " AppPlatformVersion=\"8.0\">\n"
  2730. "\t<DefaultLanguage xmlns=\"\" code=\"en-US\"/>\n"
  2731. "\t<App xmlns=\"\" ProductID=\"{" << this->GUID << "}\""
  2732. " Title=\"CMake Test Program\" RuntimeType=\"Modern Native\""
  2733. " Version=\"1.0.0.0\" Genre=\"apps.normal\" Author=\"CMake\""
  2734. " Description=\"Default CMake App\" Publisher=\"CMake\""
  2735. " PublisherID=\"{" << this->GUID << "}\">\n"
  2736. "\t\t<IconPath IsRelative=\"true\" IsResource=\"false\">"
  2737. << artifactDirXML << "\\ApplicationIcon.png</IconPath>\n"
  2738. "\t\t<Capabilities/>\n"
  2739. "\t\t<Tasks>\n"
  2740. "\t\t\t<DefaultTask Name=\"_default\""
  2741. " ImagePath=\"" << targetNameXML << ".exe\" ImageParams=\"\" />\n"
  2742. "\t\t</Tasks>\n"
  2743. "\t\t<Tokens>\n"
  2744. "\t\t\t<PrimaryToken TokenID=\"" << targetNameXML << "Token\""
  2745. " TaskName=\"_default\">\n"
  2746. "\t\t\t\t<TemplateFlip>\n"
  2747. "\t\t\t\t\t<SmallImageURI IsRelative=\"true\" IsResource=\"false\">"
  2748. << artifactDirXML << "\\SmallLogo.png</SmallImageURI>\n"
  2749. "\t\t\t\t\t<Count>0</Count>\n"
  2750. "\t\t\t\t\t<BackgroundImageURI IsRelative=\"true\" IsResource=\"false\">"
  2751. << artifactDirXML << "\\Logo.png</BackgroundImageURI>\n"
  2752. "\t\t\t\t</TemplateFlip>\n"
  2753. "\t\t\t</PrimaryToken>\n"
  2754. "\t\t</Tokens>\n"
  2755. "\t\t<ScreenResolutions>\n"
  2756. "\t\t\t<ScreenResolution Name=\"ID_RESOLUTION_WVGA\" />\n"
  2757. "\t\t</ScreenResolutions>\n"
  2758. "\t</App>\n"
  2759. "</Deployment>\n";
  2760. std::string sourceFile = this->ConvertPath(manifestFile, false);
  2761. this->ConvertToWindowsSlash(sourceFile);
  2762. this->WriteString("<Xml Include=\"", 2);
  2763. (*this->BuildFileStream) << cmVS10EscapeXML(sourceFile) << "\">\n";
  2764. this->WriteString("<SubType>Designer</SubType>\n", 3);
  2765. this->WriteString("</Xml>\n", 2);
  2766. this->AddedFiles.push_back(sourceFile);
  2767. std::string smallLogo = this->DefaultArtifactDir + "/SmallLogo.png";
  2768. cmSystemTools::CopyAFile(templateFolder + "/SmallLogo.png",
  2769. smallLogo, false);
  2770. this->ConvertToWindowsSlash(smallLogo);
  2771. this->WriteString("<Image Include=\"", 2);
  2772. (*this->BuildFileStream) << cmVS10EscapeXML(smallLogo) << "\" />\n";
  2773. this->AddedFiles.push_back(smallLogo);
  2774. std::string logo = this->DefaultArtifactDir + "/Logo.png";
  2775. cmSystemTools::CopyAFile(templateFolder + "/Logo.png",
  2776. logo, false);
  2777. this->ConvertToWindowsSlash(logo);
  2778. this->WriteString("<Image Include=\"", 2);
  2779. (*this->BuildFileStream) << cmVS10EscapeXML(logo) << "\" />\n";
  2780. this->AddedFiles.push_back(logo);
  2781. std::string applicationIcon =
  2782. this->DefaultArtifactDir + "/ApplicationIcon.png";
  2783. cmSystemTools::CopyAFile(templateFolder + "/ApplicationIcon.png",
  2784. applicationIcon, false);
  2785. this->ConvertToWindowsSlash(applicationIcon);
  2786. this->WriteString("<Image Include=\"", 2);
  2787. (*this->BuildFileStream) << cmVS10EscapeXML(applicationIcon) << "\" />\n";
  2788. this->AddedFiles.push_back(applicationIcon);
  2789. }
  2790. void cmVisualStudio10TargetGenerator::WriteMissingFilesWP81()
  2791. {
  2792. std::string manifestFile =
  2793. this->DefaultArtifactDir + "/package.appxManifest";
  2794. std::string artifactDir =
  2795. this->LocalGenerator->GetTargetDirectory(*this->Target);
  2796. this->ConvertToWindowsSlash(artifactDir);
  2797. std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
  2798. std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName());
  2799. cmGeneratedFileStream fout(manifestFile.c_str());
  2800. fout.SetCopyIfDifferent(true);
  2801. fout <<
  2802. "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
  2803. "<Package xmlns=\"http://schemas.microsoft.com/appx/2010/manifest\""
  2804. " xmlns:m2=\"http://schemas.microsoft.com/appx/2013/manifest\""
  2805. " xmlns:mp=\"http://schemas.microsoft.com/appx/2014/phone/manifest\">\n"
  2806. "\t<Identity Name=\"" << this->GUID << "\" Publisher=\"CN=CMake\""
  2807. " Version=\"1.0.0.0\" />\n"
  2808. "\t<mp:PhoneIdentity PhoneProductId=\"" << this->GUID << "\""
  2809. " PhonePublisherId=\"00000000-0000-0000-0000-000000000000\"/>\n"
  2810. "\t<Properties>\n"
  2811. "\t\t<DisplayName>" << targetNameXML << "</DisplayName>\n"
  2812. "\t\t<PublisherDisplayName>CMake</PublisherDisplayName>\n"
  2813. "\t\t<Logo>" << artifactDirXML << "\\StoreLogo.png</Logo>\n"
  2814. "\t</Properties>\n"
  2815. "\t<Prerequisites>\n"
  2816. "\t\t<OSMinVersion>6.3.1</OSMinVersion>\n"
  2817. "\t\t<OSMaxVersionTested>6.3.1</OSMaxVersionTested>\n"
  2818. "\t</Prerequisites>\n"
  2819. "\t<Resources>\n"
  2820. "\t\t<Resource Language=\"x-generate\" />\n"
  2821. "\t</Resources>\n"
  2822. "\t<Applications>\n"
  2823. "\t\t<Application Id=\"App\""
  2824. " Executable=\"" << targetNameXML << ".exe\""
  2825. " EntryPoint=\"" << targetNameXML << ".App\">\n"
  2826. "\t\t\t<m2:VisualElements\n"
  2827. "\t\t\t\tDisplayName=\"" << targetNameXML << "\"\n"
  2828. "\t\t\t\tDescription=\"" << targetNameXML << "\"\n"
  2829. "\t\t\t\tBackgroundColor=\"#336699\"\n"
  2830. "\t\t\t\tForegroundText=\"light\"\n"
  2831. "\t\t\t\tSquare150x150Logo=\"" << artifactDirXML << "\\Logo.png\"\n"
  2832. "\t\t\t\tSquare30x30Logo=\"" << artifactDirXML << "\\SmallLogo.png\">\n"
  2833. "\t\t\t\t<m2:DefaultTile ShortName=\"" << targetNameXML << "\">\n"
  2834. "\t\t\t\t\t<m2:ShowNameOnTiles>\n"
  2835. "\t\t\t\t\t\t<m2:ShowOn Tile=\"square150x150Logo\" />\n"
  2836. "\t\t\t\t\t</m2:ShowNameOnTiles>\n"
  2837. "\t\t\t\t</m2:DefaultTile>\n"
  2838. "\t\t\t\t<m2:SplashScreen"
  2839. " Image=\"" << artifactDirXML << "\\SplashScreen.png\" />\n"
  2840. "\t\t\t</m2:VisualElements>\n"
  2841. "\t\t</Application>\n"
  2842. "\t</Applications>\n"
  2843. "</Package>\n";
  2844. this->WriteCommonMissingFiles(manifestFile);
  2845. }
  2846. void cmVisualStudio10TargetGenerator::WriteMissingFilesWS80()
  2847. {
  2848. std::string manifestFile =
  2849. this->DefaultArtifactDir + "/package.appxManifest";
  2850. std::string artifactDir =
  2851. this->LocalGenerator->GetTargetDirectory(*this->Target);
  2852. this->ConvertToWindowsSlash(artifactDir);
  2853. std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
  2854. std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName());
  2855. cmGeneratedFileStream fout(manifestFile.c_str());
  2856. fout.SetCopyIfDifferent(true);
  2857. fout <<
  2858. "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
  2859. "<Package xmlns=\"http://schemas.microsoft.com/appx/2010/manifest\">\n"
  2860. "\t<Identity Name=\"" << this->GUID << "\" Publisher=\"CN=CMake\""
  2861. " Version=\"1.0.0.0\" />\n"
  2862. "\t<Properties>\n"
  2863. "\t\t<DisplayName>" << targetNameXML << "</DisplayName>\n"
  2864. "\t\t<PublisherDisplayName>CMake</PublisherDisplayName>\n"
  2865. "\t\t<Logo>" << artifactDirXML << "\\StoreLogo.png</Logo>\n"
  2866. "\t</Properties>\n"
  2867. "\t<Prerequisites>\n"
  2868. "\t\t<OSMinVersion>6.2.1</OSMinVersion>\n"
  2869. "\t\t<OSMaxVersionTested>6.2.1</OSMaxVersionTested>\n"
  2870. "\t</Prerequisites>\n"
  2871. "\t<Resources>\n"
  2872. "\t\t<Resource Language=\"x-generate\" />\n"
  2873. "\t</Resources>\n"
  2874. "\t<Applications>\n"
  2875. "\t\t<Application Id=\"App\""
  2876. " Executable=\"" << targetNameXML << ".exe\""
  2877. " EntryPoint=\"" << targetNameXML << ".App\">\n"
  2878. "\t\t\t<VisualElements"
  2879. " DisplayName=\"" << targetNameXML << "\""
  2880. " Description=\"" << targetNameXML << "\""
  2881. " BackgroundColor=\"#336699\" ForegroundText=\"light\""
  2882. " Logo=\"" << artifactDirXML << "\\Logo.png\""
  2883. " SmallLogo=\"" << artifactDirXML << "\\SmallLogo.png\">\n"
  2884. "\t\t\t\t<DefaultTile ShowName=\"allLogos\""
  2885. " ShortName=\"" << targetNameXML << "\" />\n"
  2886. "\t\t\t\t<SplashScreen"
  2887. " Image=\"" << artifactDirXML << "\\SplashScreen.png\" />\n"
  2888. "\t\t\t</VisualElements>\n"
  2889. "\t\t</Application>\n"
  2890. "\t</Applications>\n"
  2891. "</Package>\n";
  2892. this->WriteCommonMissingFiles(manifestFile);
  2893. }
  2894. void cmVisualStudio10TargetGenerator::WriteMissingFilesWS81()
  2895. {
  2896. std::string manifestFile =
  2897. this->DefaultArtifactDir + "/package.appxManifest";
  2898. std::string artifactDir =
  2899. this->LocalGenerator->GetTargetDirectory(*this->Target);
  2900. this->ConvertToWindowsSlash(artifactDir);
  2901. std::string artifactDirXML = cmVS10EscapeXML(artifactDir);
  2902. std::string targetNameXML = cmVS10EscapeXML(this->Target->GetName());
  2903. cmGeneratedFileStream fout(manifestFile.c_str());
  2904. fout.SetCopyIfDifferent(true);
  2905. fout <<
  2906. "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
  2907. "<Package xmlns=\"http://schemas.microsoft.com/appx/2010/manifest\""
  2908. " xmlns:m2=\"http://schemas.microsoft.com/appx/2013/manifest\">\n"
  2909. "\t<Identity Name=\"" << this->GUID << "\" Publisher=\"CN=CMake\""
  2910. " Version=\"1.0.0.0\" />\n"
  2911. "\t<Properties>\n"
  2912. "\t\t<DisplayName>" << targetNameXML << "</DisplayName>\n"
  2913. "\t\t<PublisherDisplayName>CMake</PublisherDisplayName>\n"
  2914. "\t\t<Logo>" << artifactDirXML << "\\StoreLogo.png</Logo>\n"
  2915. "\t</Properties>\n"
  2916. "\t<Prerequisites>\n"
  2917. "\t\t<OSMinVersion>6.3</OSMinVersion>\n"
  2918. "\t\t<OSMaxVersionTested>6.3</OSMaxVersionTested>\n"
  2919. "\t</Prerequisites>\n"
  2920. "\t<Resources>\n"
  2921. "\t\t<Resource Language=\"x-generate\" />\n"
  2922. "\t</Resources>\n"
  2923. "\t<Applications>\n"
  2924. "\t\t<Application Id=\"App\""
  2925. " Executable=\"" << targetNameXML << ".exe\""
  2926. " EntryPoint=\"" << targetNameXML << ".App\">\n"
  2927. "\t\t\t<m2:VisualElements\n"
  2928. "\t\t\t\tDisplayName=\"" << targetNameXML << "\"\n"
  2929. "\t\t\t\tDescription=\"" << targetNameXML << "\"\n"
  2930. "\t\t\t\tBackgroundColor=\"#336699\"\n"
  2931. "\t\t\t\tForegroundText=\"light\"\n"
  2932. "\t\t\t\tSquare150x150Logo=\"" << artifactDirXML << "\\Logo.png\"\n"
  2933. "\t\t\t\tSquare30x30Logo=\"" << artifactDirXML << "\\SmallLogo.png\">\n"
  2934. "\t\t\t\t<m2:DefaultTile ShortName=\"" << targetNameXML << "\">\n"
  2935. "\t\t\t\t\t<m2:ShowNameOnTiles>\n"
  2936. "\t\t\t\t\t\t<m2:ShowOn Tile=\"square150x150Logo\" />\n"
  2937. "\t\t\t\t\t</m2:ShowNameOnTiles>\n"
  2938. "\t\t\t\t</m2:DefaultTile>\n"
  2939. "\t\t\t\t<m2:SplashScreen"
  2940. " Image=\"" << artifactDirXML << "\\SplashScreen.png\" />\n"
  2941. "\t\t\t</m2:VisualElements>\n"
  2942. "\t\t</Application>\n"
  2943. "\t</Applications>\n"
  2944. "</Package>\n";
  2945. this->WriteCommonMissingFiles(manifestFile);
  2946. }
  2947. void
  2948. cmVisualStudio10TargetGenerator
  2949. ::WriteCommonMissingFiles(const std::string& manifestFile)
  2950. {
  2951. std::string templateFolder = cmSystemTools::GetCMakeRoot() +
  2952. "/Templates/Windows";
  2953. std::string sourceFile = this->ConvertPath(manifestFile, false);
  2954. this->ConvertToWindowsSlash(sourceFile);
  2955. this->WriteString("<AppxManifest Include=\"", 2);
  2956. (*this->BuildFileStream) << cmVS10EscapeXML(sourceFile) << "\">\n";
  2957. this->WriteString("<SubType>Designer</SubType>\n", 3);
  2958. this->WriteString("</AppxManifest>\n", 2);
  2959. this->AddedFiles.push_back(sourceFile);
  2960. std::string smallLogo = this->DefaultArtifactDir + "/SmallLogo.png";
  2961. cmSystemTools::CopyAFile(templateFolder + "/SmallLogo.png",
  2962. smallLogo, false);
  2963. this->ConvertToWindowsSlash(smallLogo);
  2964. this->WriteString("<Image Include=\"", 2);
  2965. (*this->BuildFileStream) << cmVS10EscapeXML(smallLogo) << "\" />\n";
  2966. this->AddedFiles.push_back(smallLogo);
  2967. std::string logo = this->DefaultArtifactDir + "/Logo.png";
  2968. cmSystemTools::CopyAFile(templateFolder + "/Logo.png",
  2969. logo, false);
  2970. this->ConvertToWindowsSlash(logo);
  2971. this->WriteString("<Image Include=\"", 2);
  2972. (*this->BuildFileStream) << cmVS10EscapeXML(logo) << "\" />\n";
  2973. this->AddedFiles.push_back(logo);
  2974. std::string storeLogo = this->DefaultArtifactDir + "/StoreLogo.png";
  2975. cmSystemTools::CopyAFile(templateFolder + "/StoreLogo.png",
  2976. storeLogo, false);
  2977. this->ConvertToWindowsSlash(storeLogo);
  2978. this->WriteString("<Image Include=\"", 2);
  2979. (*this->BuildFileStream) << cmVS10EscapeXML(storeLogo) << "\" />\n";
  2980. this->AddedFiles.push_back(storeLogo);
  2981. std::string splashScreen = this->DefaultArtifactDir + "/SplashScreen.png";
  2982. cmSystemTools::CopyAFile(templateFolder + "/SplashScreen.png",
  2983. splashScreen, false);
  2984. this->ConvertToWindowsSlash(splashScreen);
  2985. this->WriteString("<Image Include=\"", 2);
  2986. (*this->BuildFileStream) << cmVS10EscapeXML(splashScreen) << "\" />\n";
  2987. this->AddedFiles.push_back(splashScreen);
  2988. // This file has already been added to the build so don't copy it
  2989. std::string keyFile = this->DefaultArtifactDir + "/Windows_TemporaryKey.pfx";
  2990. this->ConvertToWindowsSlash(keyFile);
  2991. this->WriteString("<None Include=\"", 2);
  2992. (*this->BuildFileStream) << cmVS10EscapeXML(keyFile) << "\" />\n";
  2993. }