cmVisualStudio10TargetGenerator.cxx 124 KB

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