cmVisualStudio10TargetGenerator.cxx 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmVisualStudio10TargetGenerator.h"
  11. #include "cmGlobalVisualStudio10Generator.h"
  12. #include "cmTarget.h"
  13. #include "cmComputeLinkInformation.h"
  14. #include "cmGeneratedFileStream.h"
  15. #include "cmMakefile.h"
  16. #include "cmSourceFile.h"
  17. #include "cmVisualStudioGeneratorOptions.h"
  18. #include "cmLocalVisualStudio7Generator.h"
  19. #include "cmVS10CLFlagTable.h"
  20. #include "cmVS10LinkFlagTable.h"
  21. #include "cmVS10LibFlagTable.h"
  22. #include <cmsys/auto_ptr.hxx>
  23. static std::string cmVS10EscapeXML(std::string arg)
  24. {
  25. cmSystemTools::ReplaceString(arg, "&", "&amp;");
  26. cmSystemTools::ReplaceString(arg, "<", "&lt;");
  27. cmSystemTools::ReplaceString(arg, ">", "&gt;");
  28. return arg;
  29. }
  30. static std::string cmVS10EscapeComment(std::string comment)
  31. {
  32. // MSBuild takes the CDATA of a <Message></Message> element and just
  33. // does "echo $CDATA" with no escapes. We must encode the string.
  34. // http://technet.microsoft.com/en-us/library/cc772462%28WS.10%29.aspx
  35. std::string echoable;
  36. for(std::string::iterator c = comment.begin(); c != comment.end(); ++c)
  37. {
  38. switch (*c)
  39. {
  40. case '\r': break;
  41. case '\n': echoable += '\t'; break;
  42. case '"': /* no break */
  43. case '|': /* no break */
  44. case '&': /* no break */
  45. case '<': /* no break */
  46. case '>': /* no break */
  47. case '^': echoable += '^'; /* no break */
  48. default: echoable += *c; break;
  49. }
  50. }
  51. return echoable;
  52. }
  53. cmVisualStudio10TargetGenerator::
  54. cmVisualStudio10TargetGenerator(cmTarget* target,
  55. cmGlobalVisualStudio10Generator* gg)
  56. {
  57. this->GlobalGenerator = gg;
  58. this->Target = target;
  59. this->Makefile = target->GetMakefile();
  60. this->LocalGenerator =
  61. (cmLocalVisualStudio7Generator*)
  62. this->Makefile->GetLocalGenerator();
  63. this->Name = this->Target->GetName();
  64. this->GlobalGenerator->CreateGUID(this->Name.c_str());
  65. this->GUID = this->GlobalGenerator->GetGUID(this->Name.c_str());
  66. this->Platform = gg->GetPlatformName();
  67. this->ComputeObjectNames();
  68. this->BuildFileStream = 0;
  69. }
  70. cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator()
  71. {
  72. for(OptionsMap::iterator i = this->ClOptions.begin();
  73. i != this->ClOptions.end(); ++i)
  74. {
  75. delete i->second;
  76. }
  77. if(!this->BuildFileStream)
  78. {
  79. return;
  80. }
  81. if (this->BuildFileStream->Close())
  82. {
  83. this->GlobalGenerator
  84. ->FileReplacedDuringGenerate(this->PathToVcxproj);
  85. }
  86. delete this->BuildFileStream;
  87. }
  88. void cmVisualStudio10TargetGenerator::WritePlatformConfigTag(
  89. const char* tag,
  90. const char* config,
  91. int indentLevel,
  92. const char* attribute,
  93. const char* end,
  94. std::ostream* stream)
  95. {
  96. if(!stream)
  97. {
  98. stream = this->BuildFileStream;
  99. }
  100. stream->fill(' ');
  101. stream->width(indentLevel*2 );
  102. (*stream ) << "";
  103. (*stream ) << "<" << tag
  104. << " Condition=\"'$(Configuration)|$(Platform)'=='";
  105. (*stream ) << config << "|" << this->Platform << "'\"";
  106. if(attribute)
  107. {
  108. (*stream ) << attribute;
  109. }
  110. // close the tag
  111. (*stream ) << ">";
  112. if(end)
  113. {
  114. (*stream ) << end;
  115. }
  116. }
  117. void cmVisualStudio10TargetGenerator::WriteString(const char* line,
  118. int indentLevel)
  119. {
  120. this->BuildFileStream->fill(' ');
  121. this->BuildFileStream->width(indentLevel*2 );
  122. // write an empty string to get the fill level indent to print
  123. (*this->BuildFileStream ) << "";
  124. (*this->BuildFileStream ) << line;
  125. }
  126. #define VS10_USER_PROPS "$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props"
  127. void cmVisualStudio10TargetGenerator::Generate()
  128. {
  129. // do not generate external ms projects
  130. if(this->Target->GetProperty("EXTERNAL_MSPROJECT"))
  131. {
  132. return;
  133. }
  134. // Tell the global generator the name of the project file
  135. this->Target->SetProperty("GENERATOR_FILE_NAME",this->Name.c_str());
  136. this->Target->SetProperty("GENERATOR_FILE_NAME_EXT",
  137. ".vcxproj");
  138. if(this->Target->GetType() <= cmTarget::MODULE_LIBRARY)
  139. {
  140. if(!this->ComputeClOptions())
  141. {
  142. return;
  143. }
  144. }
  145. cmMakefile* mf = this->Target->GetMakefile();
  146. std::string path = mf->GetStartOutputDirectory();
  147. path += "/";
  148. path += this->Name;
  149. path += ".vcxproj";
  150. this->BuildFileStream =
  151. new cmGeneratedFileStream(path.c_str());
  152. this->PathToVcxproj = path;
  153. this->BuildFileStream->SetCopyIfDifferent(true);
  154. // Write the encoding header into the file
  155. char magic[] = {0xEF,0xBB, 0xBF};
  156. this->BuildFileStream->write(magic, 3);
  157. this->WriteString("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",0);
  158. this->WriteString("<Project DefaultTargets=\"Build\" "
  159. "ToolsVersion=\"4.0\" "
  160. "xmlns=\"http://schemas.microsoft.com/"
  161. "developer/msbuild/2003\">\n",
  162. 0);
  163. this->WriteProjectConfigurations();
  164. this->WriteString("<PropertyGroup Label=\"Globals\">\n", 1);
  165. this->WriteString("<ProjectGUID>", 2);
  166. (*this->BuildFileStream) << "{" << this->GUID << "}</ProjectGUID>\n";
  167. const char* vsProjectTypes =
  168. this->Target->GetProperty("VS_GLOBAL_PROJECT_TYPES");
  169. if(vsProjectTypes)
  170. {
  171. this->WriteString("<ProjectTypes>", 2);
  172. (*this->BuildFileStream) << cmVS10EscapeXML(vsProjectTypes) <<
  173. "</ProjectTypes>\n";
  174. }
  175. const char* vsProjectName = this->Target->GetProperty("VS_SCC_PROJECTNAME");
  176. const char* vsLocalPath = this->Target->GetProperty("VS_SCC_LOCALPATH");
  177. const char* vsProvider = this->Target->GetProperty("VS_SCC_PROVIDER");
  178. if( vsProjectName && vsLocalPath && vsProvider )
  179. {
  180. this->WriteString("<SccProjectName>", 2);
  181. (*this->BuildFileStream) << cmVS10EscapeXML(vsProjectName) <<
  182. "</SccProjectName>\n";
  183. this->WriteString("<SccLocalPath>", 2);
  184. (*this->BuildFileStream) << cmVS10EscapeXML(vsLocalPath) <<
  185. "</SccLocalPath>\n";
  186. this->WriteString("<SccProvider>", 2);
  187. (*this->BuildFileStream) << cmVS10EscapeXML(vsProvider) <<
  188. "</SccProvider>\n";
  189. const char* vsAuxPath = this->Target->GetProperty("VS_SCC_AUXPATH");
  190. if( vsAuxPath )
  191. {
  192. this->WriteString("<SccAuxPath>", 2);
  193. (*this->BuildFileStream) << cmVS10EscapeXML(vsAuxPath) <<
  194. "</SccAuxPath>\n";
  195. }
  196. }
  197. const char* vsGlobalKeyword =
  198. this->Target->GetProperty("VS_GLOBAL_KEYWORD");
  199. if(!vsGlobalKeyword)
  200. {
  201. this->WriteString("<Keyword>Win32Proj</Keyword>\n", 2);
  202. }
  203. else
  204. {
  205. this->WriteString("<Keyword>", 2);
  206. (*this->BuildFileStream) << cmVS10EscapeXML(vsGlobalKeyword) <<
  207. "</Keyword>\n";
  208. }
  209. this->WriteString("<Platform>", 2);
  210. (*this->BuildFileStream) << this->Platform << "</Platform>\n";
  211. const char* projLabel = this->Target->GetProperty("PROJECT_LABEL");
  212. if(!projLabel)
  213. {
  214. projLabel = this->Name.c_str();
  215. }
  216. this->WriteString("<ProjectName>", 2);
  217. (*this->BuildFileStream) << projLabel << "</ProjectName>\n";
  218. this->WriteString("</PropertyGroup>\n", 1);
  219. this->WriteString("<Import Project="
  220. "\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n",
  221. 1);
  222. this->WriteProjectConfigurationValues();
  223. this->WriteString(
  224. "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n", 1);
  225. this->WriteString("<ImportGroup Label=\"ExtensionSettings\">\n", 1);
  226. this->WriteString("</ImportGroup>\n", 1);
  227. this->WriteString("<ImportGroup Label=\"PropertySheets\">\n", 1);
  228. this->WriteString("<Import Project=\"" VS10_USER_PROPS "\""
  229. " Condition=\"exists('" VS10_USER_PROPS "')\""
  230. " Label=\"LocalAppDataPlatform\" />", 2);
  231. this->WriteString("</ImportGroup>\n", 1);
  232. this->WriteString("<PropertyGroup Label=\"UserMacros\" />\n", 1);
  233. this->WritePathAndIncrementalLinkOptions();
  234. this->WriteItemDefinitionGroups();
  235. this->WriteCustomCommands();
  236. this->WriteObjSources();
  237. this->WriteCLSources();
  238. this->WriteDotNetReferences();
  239. this->WriteWinRTReferences();
  240. this->WriteProjectReferences();
  241. this->WriteString(
  242. "<Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\""
  243. " />\n", 1);
  244. this->WriteString("<ImportGroup Label=\"ExtensionTargets\">\n", 1);
  245. this->WriteString("</ImportGroup>\n", 1);
  246. this->WriteString("</Project>", 0);
  247. // The groups are stored in a separate file for VS 10
  248. this->WriteGroups();
  249. }
  250. void cmVisualStudio10TargetGenerator::WriteDotNetReferences()
  251. {
  252. std::vector<std::string> references;
  253. if(const char* vsDotNetReferences =
  254. this->Target->GetProperty("VS_DOTNET_REFERENCES"))
  255. {
  256. cmSystemTools::ExpandListArgument(vsDotNetReferences, references);
  257. }
  258. if(!references.empty())
  259. {
  260. this->WriteString("<ItemGroup>\n", 1);
  261. for(std::vector<std::string>::iterator ri = references.begin();
  262. ri != references.end(); ++ri)
  263. {
  264. this->WriteString("<Reference Include=\"", 2);
  265. (*this->BuildFileStream) << cmVS10EscapeXML(*ri) << "\">\n";
  266. this->WriteString("<CopyLocalSatelliteAssemblies>true"
  267. "</CopyLocalSatelliteAssemblies>\n", 3);
  268. this->WriteString("<ReferenceOutputAssembly>true"
  269. "</ReferenceOutputAssembly>\n", 3);
  270. this->WriteString("</Reference>\n", 2);
  271. }
  272. this->WriteString("</ItemGroup>\n", 1);
  273. }
  274. }
  275. void cmVisualStudio10TargetGenerator::WriteWinRTReferences()
  276. {
  277. std::vector<std::string> references;
  278. if(const char* vsWinRTReferences =
  279. this->Target->GetProperty("VS_WINRT_REFERENCES"))
  280. {
  281. cmSystemTools::ExpandListArgument(vsWinRTReferences, references);
  282. }
  283. if(!references.empty())
  284. {
  285. this->WriteString("<ItemGroup>\n", 1);
  286. for(std::vector<std::string>::iterator ri = references.begin();
  287. ri != references.end(); ++ri)
  288. {
  289. this->WriteString("<Reference Include=\"", 2);
  290. (*this->BuildFileStream) << cmVS10EscapeXML(*ri) << "\">\n";
  291. this->WriteString("<IsWinMDFile>true</IsWinMDFile>\n", 3);
  292. this->WriteString("</Reference>\n", 2);
  293. }
  294. this->WriteString("</ItemGroup>\n", 1);
  295. }
  296. }
  297. // ConfigurationType Application, Utility StaticLibrary DynamicLibrary
  298. void cmVisualStudio10TargetGenerator::WriteProjectConfigurations()
  299. {
  300. this->WriteString("<ItemGroup Label=\"ProjectConfigurations\">\n", 1);
  301. std::vector<std::string> *configs =
  302. static_cast<cmGlobalVisualStudio7Generator *>
  303. (this->GlobalGenerator)->GetConfigurations();
  304. for(std::vector<std::string>::iterator i = configs->begin();
  305. i != configs->end(); ++i)
  306. {
  307. this->WriteString("<ProjectConfiguration Include=\"", 2);
  308. (*this->BuildFileStream ) << *i << "|" << this->Platform << "\">\n";
  309. this->WriteString("<Configuration>", 3);
  310. (*this->BuildFileStream ) << *i << "</Configuration>\n";
  311. this->WriteString("<Platform>", 3);
  312. (*this->BuildFileStream) << this->Platform << "</Platform>\n";
  313. this->WriteString("</ProjectConfiguration>\n", 2);
  314. }
  315. this->WriteString("</ItemGroup>\n", 1);
  316. }
  317. void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
  318. {
  319. cmGlobalVisualStudio10Generator* gg =
  320. static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
  321. std::vector<std::string> *configs =
  322. static_cast<cmGlobalVisualStudio7Generator *>
  323. (this->GlobalGenerator)->GetConfigurations();
  324. for(std::vector<std::string>::iterator i = configs->begin();
  325. i != configs->end(); ++i)
  326. {
  327. this->WritePlatformConfigTag("PropertyGroup",
  328. i->c_str(),
  329. 1, " Label=\"Configuration\"", "\n");
  330. std::string configType = "<ConfigurationType>";
  331. switch(this->Target->GetType())
  332. {
  333. case cmTarget::SHARED_LIBRARY:
  334. case cmTarget::MODULE_LIBRARY:
  335. configType += "DynamicLibrary";
  336. break;
  337. case cmTarget::STATIC_LIBRARY:
  338. configType += "StaticLibrary";
  339. break;
  340. case cmTarget::EXECUTABLE:
  341. configType += "Application";
  342. break;
  343. case cmTarget::UTILITY:
  344. configType += "Utility";
  345. break;
  346. }
  347. configType += "</ConfigurationType>\n";
  348. this->WriteString(configType.c_str(), 2);
  349. const char* mfcFlag =
  350. this->Target->GetMakefile()->GetDefinition("CMAKE_MFC_FLAG");
  351. std::string mfcFlagValue = mfcFlag ? mfcFlag : "0";
  352. std::string useOfMfcValue = "false";
  353. if(mfcFlagValue == "1")
  354. {
  355. useOfMfcValue = "Static";
  356. }
  357. else if(mfcFlagValue == "2")
  358. {
  359. useOfMfcValue = "Dynamic";
  360. }
  361. std::string mfcLine = "<UseOfMfc>";
  362. mfcLine += useOfMfcValue + "</UseOfMfc>\n";
  363. this->WriteString(mfcLine.c_str(), 2);
  364. if(this->Target->GetType() <= cmTarget::MODULE_LIBRARY &&
  365. this->ClOptions[*i]->UsingUnicode() ||
  366. this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS"))
  367. {
  368. this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2);
  369. }
  370. else if (this->Target->GetType() <= cmTarget::MODULE_LIBRARY &&
  371. this->ClOptions[*i]->UsingSBCS())
  372. {
  373. this->WriteString("<CharacterSet>NotSet</CharacterSet>\n", 2);
  374. }
  375. else
  376. {
  377. this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2);
  378. }
  379. if(const char* toolset = gg->GetPlatformToolset())
  380. {
  381. std::string pts = "<PlatformToolset>";
  382. pts += toolset;
  383. pts += "</PlatformToolset>\n";
  384. this->WriteString(pts.c_str(), 2);
  385. }
  386. if(this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS"))
  387. {
  388. this->WriteString("<Immersive>true</Immersive>\n", 2);
  389. }
  390. this->WriteString("</PropertyGroup>\n", 1);
  391. }
  392. }
  393. void cmVisualStudio10TargetGenerator::WriteCustomCommands()
  394. {
  395. this->SourcesVisited.clear();
  396. std::vector<cmSourceFile*> const& sources = this->Target->GetSourceFiles();
  397. for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
  398. source != sources.end(); ++source)
  399. {
  400. cmSourceFile* sf = *source;
  401. this->WriteCustomCommand(sf);
  402. }
  403. }
  404. //----------------------------------------------------------------------------
  405. void cmVisualStudio10TargetGenerator::WriteCustomCommand(cmSourceFile* sf)
  406. {
  407. if(this->SourcesVisited.insert(sf).second)
  408. {
  409. if(std::vector<cmSourceFile*> const* depends =
  410. this->Target->GetSourceDepends(sf))
  411. {
  412. for(std::vector<cmSourceFile*>::const_iterator di = depends->begin();
  413. di != depends->end(); ++di)
  414. {
  415. this->WriteCustomCommand(*di);
  416. }
  417. }
  418. if(cmCustomCommand const* command = sf->GetCustomCommand())
  419. {
  420. this->WriteString("<ItemGroup>\n", 1);
  421. this->WriteCustomRule(sf, *command);
  422. this->WriteString("</ItemGroup>\n", 1);
  423. }
  424. }
  425. }
  426. void
  427. cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
  428. cmCustomCommand const &
  429. command)
  430. {
  431. std::string sourcePath = source->GetFullPath();
  432. // the rule file seems to need to exist for vs10
  433. if (source->GetExtension() == "rule")
  434. {
  435. if(!cmSystemTools::FileExists(sourcePath.c_str()))
  436. {
  437. // Make sure the path exists for the file
  438. std::string path = cmSystemTools::GetFilenamePath(sourcePath);
  439. cmSystemTools::MakeDirectory(path.c_str());
  440. std::ofstream fout(sourcePath.c_str());
  441. if(fout)
  442. {
  443. fout << "# generated from CMake\n";
  444. fout.flush();
  445. fout.close();
  446. }
  447. else
  448. {
  449. std::string error = "Could not create file: [";
  450. error += sourcePath;
  451. error += "] ";
  452. cmSystemTools::Error
  453. (error.c_str(), cmSystemTools::GetLastSystemError().c_str());
  454. }
  455. }
  456. }
  457. cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
  458. std::string comment = lg->ConstructComment(command);
  459. comment = cmVS10EscapeComment(comment);
  460. std::vector<std::string> *configs =
  461. static_cast<cmGlobalVisualStudio7Generator *>
  462. (this->GlobalGenerator)->GetConfigurations();
  463. this->WriteString("<CustomBuild Include=\"", 2);
  464. // custom command have to use relative paths or they do not
  465. // show up in the GUI
  466. std::string path = cmSystemTools::RelativePath(
  467. this->Makefile->GetCurrentOutputDirectory(),
  468. sourcePath.c_str());
  469. this->ConvertToWindowsSlash(path);
  470. (*this->BuildFileStream ) << path << "\">\n";
  471. for(std::vector<std::string>::iterator i = configs->begin();
  472. i != configs->end(); ++i)
  473. {
  474. std::string script =
  475. cmVS10EscapeXML(lg->ConstructScript(command, i->c_str()));
  476. this->WritePlatformConfigTag("Message",i->c_str(), 3);
  477. (*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "</Message>\n";
  478. this->WritePlatformConfigTag("Command", i->c_str(), 3);
  479. (*this->BuildFileStream ) << script << "</Command>\n";
  480. this->WritePlatformConfigTag("AdditionalInputs", i->c_str(), 3);
  481. (*this->BuildFileStream ) << source->GetFullPath();
  482. for(std::vector<std::string>::const_iterator d =
  483. command.GetDepends().begin();
  484. d != command.GetDepends().end();
  485. ++d)
  486. {
  487. std::string dep;
  488. if(this->LocalGenerator->GetRealDependency(d->c_str(), i->c_str(), dep))
  489. {
  490. this->ConvertToWindowsSlash(dep);
  491. (*this->BuildFileStream ) << ";" << dep;
  492. }
  493. }
  494. (*this->BuildFileStream ) << ";%(AdditionalInputs)</AdditionalInputs>\n";
  495. this->WritePlatformConfigTag("Outputs", i->c_str(), 3);
  496. const char* sep = "";
  497. for(std::vector<std::string>::const_iterator o =
  498. command.GetOutputs().begin();
  499. o != command.GetOutputs().end();
  500. ++o)
  501. {
  502. std::string out = *o;
  503. this->ConvertToWindowsSlash(out);
  504. (*this->BuildFileStream ) << sep << out;
  505. sep = ";";
  506. }
  507. (*this->BuildFileStream ) << "</Outputs>\n";
  508. }
  509. this->WriteString("</CustomBuild>\n", 2);
  510. }
  511. void cmVisualStudio10TargetGenerator::ConvertToWindowsSlash(std::string& s)
  512. {
  513. // first convert all of the slashes
  514. std::string::size_type pos = 0;
  515. while((pos = s.find('/', pos)) != std::string::npos)
  516. {
  517. s[pos] = '\\';
  518. pos++;
  519. }
  520. }
  521. void cmVisualStudio10TargetGenerator::WriteGroups()
  522. {
  523. // collect up group information
  524. std::vector<cmSourceGroup> sourceGroups =
  525. this->Makefile->GetSourceGroups();
  526. std::vector<cmSourceFile*> classes = this->Target->GetSourceFiles();
  527. std::set<cmSourceGroup*> groupsUsed;
  528. std::vector<cmSourceFile*> clCompile;
  529. std::vector<cmSourceFile*> customBuild;
  530. std::vector<cmSourceFile*> none;
  531. std::vector<cmSourceFile*> headers;
  532. std::vector<cmSourceFile*> idls;
  533. std::vector<cmSourceFile*> resource;
  534. for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();
  535. s != classes.end(); s++)
  536. {
  537. cmSourceFile* sf = *s;
  538. std::string const& source = sf->GetFullPath();
  539. cmSourceGroup& sourceGroup =
  540. this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
  541. groupsUsed.insert(&sourceGroup);
  542. const char* lang = sf->GetLanguage();
  543. bool header = (*s)->GetPropertyAsBool("HEADER_FILE_ONLY")
  544. || this->GlobalGenerator->IgnoreFile
  545. ((*s)->GetExtension().c_str());
  546. std::string ext =
  547. cmSystemTools::LowerCase((*s)->GetExtension());
  548. if(!lang)
  549. {
  550. lang = "None";
  551. }
  552. if(header)
  553. {
  554. headers.push_back(sf);
  555. }
  556. else if(lang[0] == 'C')
  557. {
  558. clCompile.push_back(sf);
  559. }
  560. else if(strcmp(lang, "RC") == 0)
  561. {
  562. resource.push_back(sf);
  563. }
  564. else if(sf->GetCustomCommand())
  565. {
  566. customBuild.push_back(sf);
  567. }
  568. else if(ext == "idl")
  569. {
  570. idls.push_back(sf);
  571. }
  572. else
  573. {
  574. none.push_back(sf);
  575. }
  576. }
  577. this->AddMissingSourceGroups(groupsUsed, sourceGroups);
  578. // Write out group file
  579. std::string path = this->Makefile->GetStartOutputDirectory();
  580. path += "/";
  581. path += this->Name;
  582. path += ".vcxproj.filters";
  583. cmGeneratedFileStream fout(path.c_str());
  584. fout.SetCopyIfDifferent(true);
  585. char magic[] = {0xEF,0xBB, 0xBF};
  586. fout.write(magic, 3);
  587. cmGeneratedFileStream* save = this->BuildFileStream;
  588. this->BuildFileStream = & fout;
  589. this->WriteString("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
  590. "<Project "
  591. "ToolsVersion=\"4.0\" "
  592. "xmlns=\"http://schemas.microsoft.com/"
  593. "developer/msbuild/2003\">\n",
  594. 0);
  595. this->WriteGroupSources("ClCompile", clCompile, sourceGroups);
  596. this->WriteGroupSources("ClInclude", headers, sourceGroups);
  597. this->WriteGroupSources("ResourceCompile", resource, sourceGroups);
  598. this->WriteGroupSources("Midl", idls, sourceGroups);
  599. this->WriteGroupSources("CustomBuild", customBuild, sourceGroups);
  600. this->WriteString("<ItemGroup>\n", 1);
  601. for(std::set<cmSourceGroup*>::iterator g = groupsUsed.begin();
  602. g != groupsUsed.end(); ++g)
  603. {
  604. cmSourceGroup* sg = *g;
  605. const char* name = sg->GetFullName();
  606. if(strlen(name) != 0)
  607. {
  608. this->WriteString("<Filter Include=\"", 2);
  609. (*this->BuildFileStream) << name << "\">\n";
  610. std::string guidName = "SG_Filter_";
  611. guidName += name;
  612. this->GlobalGenerator->CreateGUID(guidName.c_str());
  613. this->WriteString("<UniqueIdentifier>", 3);
  614. std::string guid
  615. = this->GlobalGenerator->GetGUID(guidName.c_str());
  616. (*this->BuildFileStream)
  617. << "{"
  618. << guid << "}"
  619. << "</UniqueIdentifier>\n";
  620. this->WriteString("</Filter>\n", 2);
  621. }
  622. }
  623. this->WriteString("</ItemGroup>\n", 1);
  624. this->WriteGroupSources("None", none, sourceGroups);
  625. this->WriteString("</Project>\n", 0);
  626. // restore stream pointer
  627. this->BuildFileStream = save;
  628. if (fout.Close())
  629. {
  630. this->GlobalGenerator->FileReplacedDuringGenerate(path);
  631. }
  632. }
  633. // Add to groupsUsed empty source groups that have non-empty children.
  634. void
  635. cmVisualStudio10TargetGenerator::AddMissingSourceGroups(
  636. std::set<cmSourceGroup*>& groupsUsed,
  637. const std::vector<cmSourceGroup>& allGroups
  638. )
  639. {
  640. for(std::vector<cmSourceGroup>::const_iterator current = allGroups.begin();
  641. current != allGroups.end(); ++current)
  642. {
  643. std::vector<cmSourceGroup> const& children = current->GetGroupChildren();
  644. if(children.empty())
  645. {
  646. continue; // the group is really empty
  647. }
  648. this->AddMissingSourceGroups(groupsUsed, children);
  649. cmSourceGroup* current_ptr = const_cast<cmSourceGroup*>(&(*current));
  650. if(groupsUsed.find(current_ptr) != groupsUsed.end())
  651. {
  652. continue; // group has already been added to set
  653. }
  654. // check if it least one of the group's descendants is not empty
  655. // (at least one child must already have been added)
  656. std::vector<cmSourceGroup>::const_iterator child_it = children.begin();
  657. while(child_it != children.end())
  658. {
  659. cmSourceGroup* child_ptr = const_cast<cmSourceGroup*>(&(*child_it));
  660. if(groupsUsed.find(child_ptr) != groupsUsed.end())
  661. {
  662. break; // found a child that was already added => add current group too
  663. }
  664. child_it++;
  665. }
  666. if(child_it == children.end())
  667. {
  668. continue; // no descendants have source files => ignore this group
  669. }
  670. groupsUsed.insert(current_ptr);
  671. }
  672. }
  673. void
  674. cmVisualStudio10TargetGenerator::
  675. WriteGroupSources(const char* name,
  676. std::vector<cmSourceFile*> const& sources,
  677. std::vector<cmSourceGroup>& sourceGroups)
  678. {
  679. this->WriteString("<ItemGroup>\n", 1);
  680. for(std::vector<cmSourceFile*>::const_iterator s = sources.begin();
  681. s != sources.end(); ++s)
  682. {
  683. cmSourceFile* sf = *s;
  684. if(sf->GetExtension() == "obj")
  685. {
  686. continue;
  687. }
  688. std::string const& source = sf->GetFullPath();
  689. cmSourceGroup& sourceGroup =
  690. this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
  691. const char* filter = sourceGroup.GetFullName();
  692. this->WriteString("<", 2);
  693. std::string path = source;
  694. // custom command sources must use relative paths or they will
  695. // not show up in the GUI.
  696. if(sf->GetCustomCommand())
  697. {
  698. path = cmSystemTools::RelativePath(
  699. this->Makefile->GetCurrentOutputDirectory(),
  700. source.c_str());
  701. }
  702. this->ConvertToWindowsSlash(path);
  703. (*this->BuildFileStream) << name << " Include=\""
  704. << path;
  705. if(strlen(filter))
  706. {
  707. (*this->BuildFileStream) << "\">\n";
  708. this->WriteString("<Filter>", 3);
  709. (*this->BuildFileStream) << filter << "</Filter>\n";
  710. this->WriteString("</", 2);
  711. (*this->BuildFileStream) << name << ">\n";
  712. }
  713. else
  714. {
  715. (*this->BuildFileStream) << "\" />\n";
  716. }
  717. }
  718. this->WriteString("</ItemGroup>\n", 1);
  719. }
  720. void cmVisualStudio10TargetGenerator::WriteObjSources()
  721. {
  722. if(this->Target->GetType() > cmTarget::MODULE_LIBRARY)
  723. {
  724. return;
  725. }
  726. bool first = true;
  727. std::vector<cmSourceFile*>const & sources = this->Target->GetSourceFiles();
  728. for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
  729. source != sources.end(); ++source)
  730. {
  731. std::string ext =
  732. cmSystemTools::LowerCase((*source)->GetExtension());
  733. if(ext == "obj" || ext == "o")
  734. {
  735. if(first)
  736. {
  737. this->WriteString("<ItemGroup>\n", 1);
  738. first = false;
  739. }
  740. // If an object file is generated, then vs10
  741. // will use it in the build, and we have to list
  742. // it as None instead of Object
  743. if((*source)->GetPropertyAsBool("GENERATED"))
  744. {
  745. this->WriteString("<None Include=\"", 2);
  746. }
  747. // If it is not a generated object then we have
  748. // to use the Object type
  749. else
  750. {
  751. this->WriteString("<Object Include=\"", 2);
  752. }
  753. (*this->BuildFileStream ) << (*source)->GetFullPath() << "\" />\n";
  754. }
  755. }
  756. if(!first)
  757. {
  758. this->WriteString("</ItemGroup>\n", 1);
  759. }
  760. }
  761. void cmVisualStudio10TargetGenerator::WriteCLSources()
  762. {
  763. if(this->Target->GetType() > cmTarget::UTILITY)
  764. {
  765. return;
  766. }
  767. this->WriteString("<ItemGroup>\n", 1);
  768. std::vector<cmSourceFile*>const& sources = this->Target->GetSourceFiles();
  769. for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
  770. source != sources.end(); ++source)
  771. {
  772. std::string ext = cmSystemTools::LowerCase((*source)->GetExtension());
  773. if((*source)->GetCustomCommand() || ext == "o" || ext == "obj")
  774. {
  775. continue;
  776. }
  777. // If it is not a custom command and it is not a pre-built obj file,
  778. // then add it as a source (c/c++/header/rc/idl) file
  779. bool header = (*source)->GetPropertyAsBool("HEADER_FILE_ONLY")
  780. || this->GlobalGenerator->IgnoreFile(ext.c_str());
  781. const char* lang = (*source)->GetLanguage();
  782. bool cl = lang && (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") ==0);
  783. bool rc = lang && (strcmp(lang, "RC") == 0);
  784. bool idl = ext == "idl";
  785. std::string sourceFile = (*source)->GetFullPath();
  786. // do not use a relative path here because it means that you
  787. // can not use as long a path to the file.
  788. this->ConvertToWindowsSlash(sourceFile);
  789. // output the source file
  790. if(header)
  791. {
  792. this->WriteString("<ClInclude Include=\"", 2);
  793. }
  794. else if(cl)
  795. {
  796. this->WriteString("<ClCompile Include=\"", 2);
  797. }
  798. else if(rc)
  799. {
  800. this->WriteString("<ResourceCompile Include=\"", 2);
  801. }
  802. else if(idl)
  803. {
  804. this->WriteString("<Midl Include=\"", 2);
  805. }
  806. else
  807. {
  808. this->WriteString("<None Include=\"", 2);
  809. }
  810. (*this->BuildFileStream ) << sourceFile << "\"";
  811. // ouput any flags specific to this source file
  812. if(!header && cl && this->OutputSourceSpecificFlags(*source))
  813. {
  814. // if the source file has specific flags the tag
  815. // is ended on a new line
  816. this->WriteString("</ClCompile>\n", 2);
  817. }
  818. else if(!header && rc && this->OutputSourceSpecificFlags(*source))
  819. {
  820. this->WriteString("</ResourceCompile>\n", 2);
  821. }
  822. else
  823. {
  824. (*this->BuildFileStream ) << " />\n";
  825. }
  826. }
  827. this->WriteString("</ItemGroup>\n", 1);
  828. }
  829. void cmVisualStudio10TargetGenerator::ComputeObjectNames()
  830. {
  831. // get the classes from the source lists then add them to the groups
  832. std::vector<cmSourceFile*>const & classes = this->Target->GetSourceFiles();
  833. for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
  834. i != classes.end(); i++)
  835. {
  836. // Add the file to the list of sources.
  837. std::string source = (*i)->GetFullPath();
  838. if(cmSystemTools::UpperCase((*i)->GetExtension()) == "DEF")
  839. {
  840. this->ModuleDefinitionFile = (*i)->GetFullPath();
  841. }
  842. }
  843. // Compute which sources need unique object computation.
  844. this->LocalGenerator->ComputeObjectNameRequirements(classes);
  845. }
  846. bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
  847. cmSourceFile* source)
  848. {
  849. cmSourceFile& sf = *source;
  850. cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
  851. // Compute the maximum length full path to the intermediate
  852. // files directory for any configuration. This is used to construct
  853. // object file names that do not produce paths that are too long.
  854. std::string dir_max;
  855. lg->ComputeMaxDirectoryLength(dir_max, *this->Target);
  856. std::string objectName;
  857. if(lg->NeedObjectName.find(&sf) != lg->NeedObjectName.end())
  858. {
  859. objectName = lg->GetObjectFileNameWithoutTarget(sf, dir_max);
  860. }
  861. std::string flags;
  862. std::string defines;
  863. if(const char* cflags = sf.GetProperty("COMPILE_FLAGS"))
  864. {
  865. flags += cflags;
  866. }
  867. if(const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS"))
  868. {
  869. defines += cdefs;
  870. }
  871. const char* lang =
  872. this->GlobalGenerator->GetLanguageFromExtension
  873. (sf.GetExtension().c_str());
  874. const char* sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf);
  875. const char* linkLanguage = this->Target->GetLinkerLanguage();
  876. bool needForceLang = false;
  877. // source file does not match its extension language
  878. if(lang && sourceLang && strcmp(lang, sourceLang) != 0)
  879. {
  880. needForceLang = true;
  881. lang = sourceLang;
  882. }
  883. // if the source file does not match the linker language
  884. // then force c or c++
  885. if(needForceLang || (linkLanguage && lang
  886. && strcmp(lang, linkLanguage) != 0))
  887. {
  888. if(strcmp(lang, "CXX") == 0)
  889. {
  890. // force a C++ file type
  891. flags += " /TP ";
  892. }
  893. else if(strcmp(lang, "C") == 0)
  894. {
  895. // force to c
  896. flags += " /TC ";
  897. }
  898. }
  899. bool hasFlags = false;
  900. // for the first time we need a new line if there is something
  901. // produced here.
  902. const char* firstString = ">\n";
  903. if(objectName.size())
  904. {
  905. (*this->BuildFileStream ) << firstString;
  906. firstString = "";
  907. hasFlags = true;
  908. this->WriteString("<ObjectFileName>", 3);
  909. (*this->BuildFileStream )
  910. << "$(IntDir)/" << objectName << "</ObjectFileName>\n";
  911. }
  912. std::vector<std::string> *configs =
  913. static_cast<cmGlobalVisualStudio7Generator *>
  914. (this->GlobalGenerator)->GetConfigurations();
  915. for( std::vector<std::string>::iterator config = configs->begin();
  916. config != configs->end(); ++config)
  917. {
  918. std::string configUpper = cmSystemTools::UpperCase(*config);
  919. std::string configDefines = defines;
  920. std::string defPropName = "COMPILE_DEFINITIONS_";
  921. defPropName += configUpper;
  922. if(const char* ccdefs = sf.GetProperty(defPropName.c_str()))
  923. {
  924. if(configDefines.size())
  925. {
  926. configDefines += ";";
  927. }
  928. configDefines += ccdefs;
  929. }
  930. // if we have flags or defines for this config then
  931. // use them
  932. if(flags.size() || configDefines.size())
  933. {
  934. (*this->BuildFileStream ) << firstString;
  935. firstString = ""; // only do firstString once
  936. hasFlags = true;
  937. cmVisualStudioGeneratorOptions
  938. clOptions(this->LocalGenerator,
  939. cmVisualStudioGeneratorOptions::Compiler,
  940. cmVS10CLFlagTable, 0, this);
  941. clOptions.Parse(flags.c_str());
  942. clOptions.AddDefines(configDefines.c_str());
  943. clOptions.SetConfiguration((*config).c_str());
  944. clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
  945. clOptions.OutputFlagMap(*this->BuildFileStream, " ");
  946. clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream,
  947. " ", "\n", lang);
  948. }
  949. }
  950. return hasFlags;
  951. }
  952. void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
  953. {
  954. cmTarget::TargetType ttype = this->Target->GetType();
  955. if(ttype > cmTarget::GLOBAL_TARGET)
  956. {
  957. return;
  958. }
  959. this->WriteString("<PropertyGroup>\n", 2);
  960. this->WriteString("<_ProjectFileVersion>10.0.20506.1"
  961. "</_ProjectFileVersion>\n", 3);
  962. std::vector<std::string> *configs =
  963. static_cast<cmGlobalVisualStudio7Generator *>
  964. (this->GlobalGenerator)->GetConfigurations();
  965. for(std::vector<std::string>::iterator config = configs->begin();
  966. config != configs->end(); ++config)
  967. {
  968. if(ttype >= cmTarget::UTILITY)
  969. {
  970. this->WritePlatformConfigTag("IntDir", config->c_str(), 3);
  971. *this->BuildFileStream
  972. << "$(Platform)\\$(Configuration)\\$(ProjectName)\\"
  973. << "</IntDir>\n";
  974. }
  975. else
  976. {
  977. std::string targetNameFull =
  978. this->Target->GetFullName(config->c_str());
  979. std::string intermediateDir = this->LocalGenerator->
  980. GetTargetDirectory(*this->Target);
  981. intermediateDir += "/";
  982. intermediateDir += *config;
  983. intermediateDir += "/";
  984. this->ConvertToWindowsSlash(intermediateDir);
  985. std::string outDir = this->Target->GetDirectory(config->c_str());
  986. this->ConvertToWindowsSlash(outDir);
  987. this->WritePlatformConfigTag("OutDir", config->c_str(), 3);
  988. *this->BuildFileStream << outDir
  989. << "\\"
  990. << "</OutDir>\n";
  991. this->WritePlatformConfigTag("IntDir", config->c_str(), 3);
  992. *this->BuildFileStream << intermediateDir
  993. << "</IntDir>\n";
  994. this->WritePlatformConfigTag("TargetName", config->c_str(), 3);
  995. *this->BuildFileStream
  996. << cmSystemTools::GetFilenameWithoutLastExtension(
  997. targetNameFull.c_str())
  998. << "</TargetName>\n";
  999. this->WritePlatformConfigTag("TargetExt", config->c_str(), 3);
  1000. *this->BuildFileStream
  1001. << cmSystemTools::GetFilenameLastExtension(targetNameFull.c_str())
  1002. << "</TargetExt>\n";
  1003. this->OutputLinkIncremental(*config);
  1004. }
  1005. }
  1006. this->WriteString("</PropertyGroup>\n", 2);
  1007. }
  1008. void
  1009. cmVisualStudio10TargetGenerator::
  1010. OutputLinkIncremental(std::string const& configName)
  1011. {
  1012. std::string CONFIG = cmSystemTools::UpperCase(configName);
  1013. // static libraries and things greater than modules do not need
  1014. // to set this option
  1015. if(this->Target->GetType() == cmTarget::STATIC_LIBRARY
  1016. || this->Target->GetType() > cmTarget::MODULE_LIBRARY)
  1017. {
  1018. return;
  1019. }
  1020. const char* linkType = "SHARED";
  1021. if(this->Target->GetType() == cmTarget::EXECUTABLE)
  1022. {
  1023. linkType = "EXE";
  1024. }
  1025. // assume incremental linking
  1026. const char* incremental = "true";
  1027. const char* linkLanguage =
  1028. this->Target->GetLinkerLanguage(configName.c_str());
  1029. if(!linkLanguage)
  1030. {
  1031. cmSystemTools::Error
  1032. ("CMake can not determine linker language for target:",
  1033. this->Name.c_str());
  1034. return;
  1035. }
  1036. std::string linkFlagVarBase = "CMAKE_";
  1037. linkFlagVarBase += linkType;
  1038. linkFlagVarBase += "_LINKER_FLAGS";
  1039. std::string flags = this->
  1040. Target->GetMakefile()->GetRequiredDefinition(linkFlagVarBase.c_str());
  1041. std::string linkFlagVar = linkFlagVarBase + "_" + CONFIG;
  1042. flags += this->
  1043. Target->GetMakefile()->GetRequiredDefinition(linkFlagVar.c_str());
  1044. if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0
  1045. || strcmp(linkLanguage, "Fortran") == 0)
  1046. {
  1047. std::string baseFlagVar = "CMAKE_";
  1048. baseFlagVar += linkLanguage;
  1049. baseFlagVar += "_FLAGS";
  1050. flags += this->
  1051. Target->GetMakefile()->GetRequiredDefinition(baseFlagVar.c_str());
  1052. std::string flagVar = baseFlagVar + std::string("_") + CONFIG;
  1053. flags +=
  1054. Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str());
  1055. }
  1056. const char* targetLinkFlags = this->Target->GetProperty("LINK_FLAGS");
  1057. if(targetLinkFlags)
  1058. {
  1059. flags += " ";
  1060. flags += targetLinkFlags;
  1061. }
  1062. std::string flagsProp = "LINK_FLAGS_";
  1063. flagsProp += CONFIG;
  1064. if(const char* flagsConfig = this->Target->GetProperty(flagsProp.c_str()))
  1065. {
  1066. flags += " ";
  1067. flags += flagsConfig;
  1068. }
  1069. if(flags.find("INCREMENTAL:NO") != flags.npos)
  1070. {
  1071. incremental = "false";
  1072. }
  1073. this->WritePlatformConfigTag("LinkIncremental", configName.c_str(), 3);
  1074. *this->BuildFileStream << incremental
  1075. << "</LinkIncremental>\n";
  1076. const char* manifest = "true";
  1077. if(flags.find("MANIFEST:NO") != flags.npos)
  1078. {
  1079. manifest = "false";
  1080. }
  1081. this->WritePlatformConfigTag("GenerateManifest", configName.c_str(), 3);
  1082. *this->BuildFileStream << manifest
  1083. << "</GenerateManifest>\n";
  1084. }
  1085. //----------------------------------------------------------------------------
  1086. bool cmVisualStudio10TargetGenerator::ComputeClOptions()
  1087. {
  1088. std::vector<std::string> const* configs =
  1089. this->GlobalGenerator->GetConfigurations();
  1090. for(std::vector<std::string>::const_iterator i = configs->begin();
  1091. i != configs->end(); ++i)
  1092. {
  1093. if(!this->ComputeClOptions(*i))
  1094. {
  1095. return false;
  1096. }
  1097. }
  1098. return true;
  1099. }
  1100. //----------------------------------------------------------------------------
  1101. bool cmVisualStudio10TargetGenerator::ComputeClOptions(
  1102. std::string const& configName)
  1103. {
  1104. // much of this was copied from here:
  1105. // copied from cmLocalVisualStudio7Generator.cxx 805
  1106. // TODO: Integrate code below with cmLocalVisualStudio7Generator.
  1107. cmsys::auto_ptr<Options> pOptions(
  1108. new Options(this->LocalGenerator, Options::Compiler,
  1109. cmVS10CLFlagTable));
  1110. Options& clOptions = *pOptions;
  1111. std::string flags;
  1112. // collect up flags for
  1113. if(this->Target->GetType() < cmTarget::UTILITY)
  1114. {
  1115. const char* linkLanguage =
  1116. this->Target->GetLinkerLanguage(configName.c_str());
  1117. if(!linkLanguage)
  1118. {
  1119. cmSystemTools::Error
  1120. ("CMake can not determine linker language for target:",
  1121. this->Name.c_str());
  1122. return false;
  1123. }
  1124. if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0
  1125. || strcmp(linkLanguage, "Fortran") == 0)
  1126. {
  1127. std::string baseFlagVar = "CMAKE_";
  1128. baseFlagVar += linkLanguage;
  1129. baseFlagVar += "_FLAGS";
  1130. flags = this->
  1131. Target->GetMakefile()->GetRequiredDefinition(baseFlagVar.c_str());
  1132. std::string flagVar = baseFlagVar + std::string("_") +
  1133. cmSystemTools::UpperCase(configName);
  1134. flags += " ";
  1135. flags += this->
  1136. Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str());
  1137. }
  1138. // set the correct language
  1139. if(strcmp(linkLanguage, "C") == 0)
  1140. {
  1141. flags += " /TC ";
  1142. }
  1143. if(strcmp(linkLanguage, "CXX") == 0)
  1144. {
  1145. flags += " /TP ";
  1146. }
  1147. }
  1148. // Add the target-specific flags.
  1149. if(const char* targetFlags = this->Target->GetProperty("COMPILE_FLAGS"))
  1150. {
  1151. flags += " ";
  1152. flags += targetFlags;
  1153. }
  1154. std::string configUpper = cmSystemTools::UpperCase(configName);
  1155. std::string defPropName = "COMPILE_DEFINITIONS_";
  1156. defPropName += configUpper;
  1157. // Get preprocessor definitions for this directory.
  1158. std::string defineFlags = this->Target->GetMakefile()->GetDefineFlags();
  1159. clOptions.FixExceptionHandlingDefault();
  1160. clOptions.Parse(flags.c_str());
  1161. clOptions.Parse(defineFlags.c_str());
  1162. clOptions.AddDefines
  1163. (this->Makefile->GetProperty("COMPILE_DEFINITIONS"));
  1164. clOptions.AddDefines(this->Target->GetProperty("COMPILE_DEFINITIONS"));
  1165. clOptions.AddDefines(this->Makefile->GetProperty(defPropName.c_str()));
  1166. clOptions.AddDefines(this->Target->GetProperty(defPropName.c_str()));
  1167. clOptions.SetVerboseMakefile(
  1168. this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
  1169. // Add a definition for the configuration name.
  1170. std::string configDefine = "CMAKE_INTDIR=\"";
  1171. configDefine += configName;
  1172. configDefine += "\"";
  1173. clOptions.AddDefine(configDefine);
  1174. if(const char* exportMacro = this->Target->GetExportMacro())
  1175. {
  1176. clOptions.AddDefine(exportMacro);
  1177. }
  1178. this->ClOptions[configName] = pOptions.release();
  1179. return true;
  1180. }
  1181. //----------------------------------------------------------------------------
  1182. void cmVisualStudio10TargetGenerator::WriteClOptions(
  1183. std::string const& configName,
  1184. std::vector<std::string> const& includes)
  1185. {
  1186. Options& clOptions = *(this->ClOptions[configName]);
  1187. this->WriteString("<ClCompile>\n", 2);
  1188. clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
  1189. this->OutputIncludes(includes);
  1190. clOptions.OutputFlagMap(*this->BuildFileStream, " ");
  1191. // If not in debug mode, write the DebugInformationFormat field
  1192. // without value so PDBs don't get generated uselessly.
  1193. if(!clOptions.IsDebug())
  1194. {
  1195. this->WriteString("<DebugInformationFormat>"
  1196. "</DebugInformationFormat>\n", 3);
  1197. }
  1198. clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
  1199. "\n", "CXX");
  1200. this->WriteString("<AssemblerListingLocation>", 3);
  1201. *this->BuildFileStream << configName
  1202. << "</AssemblerListingLocation>\n";
  1203. this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3);
  1204. this->WriteString("<ProgramDataBaseFileName>", 3);
  1205. *this->BuildFileStream << this->Target->GetDirectory(configName.c_str())
  1206. << "/"
  1207. << this->Target->GetPDBName(configName.c_str())
  1208. << "</ProgramDataBaseFileName>\n";
  1209. this->WriteString("</ClCompile>\n", 2);
  1210. }
  1211. void cmVisualStudio10TargetGenerator::
  1212. OutputIncludes(std::vector<std::string> const & includes)
  1213. {
  1214. this->WriteString("<AdditionalIncludeDirectories>", 3);
  1215. for(std::vector<std::string>::const_iterator i = includes.begin();
  1216. i != includes.end(); ++i)
  1217. {
  1218. *this->BuildFileStream << *i << ";";
  1219. }
  1220. this->WriteString("%(AdditionalIncludeDirectories)"
  1221. "</AdditionalIncludeDirectories>\n", 0);
  1222. }
  1223. void cmVisualStudio10TargetGenerator::
  1224. WriteRCOptions(std::string const& configName,
  1225. std::vector<std::string> const & includes)
  1226. {
  1227. this->WriteString("<ResourceCompile>\n", 2);
  1228. Options& clOptions = *(this->ClOptions[configName]);
  1229. clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
  1230. "\n", "RC");
  1231. this->OutputIncludes(includes);
  1232. this->WriteString("</ResourceCompile>\n", 2);
  1233. }
  1234. void
  1235. cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config)
  1236. {
  1237. if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
  1238. {
  1239. return;
  1240. }
  1241. const char* libflags = this->Target->GetProperty("STATIC_LIBRARY_FLAGS");
  1242. std::string flagsConfigVar = "STATIC_LIBRARY_FLAGS_";
  1243. flagsConfigVar += cmSystemTools::UpperCase(config);
  1244. const char* libflagsConfig =
  1245. this->Target->GetProperty(flagsConfigVar.c_str());
  1246. if(libflags || libflagsConfig)
  1247. {
  1248. this->WriteString("<Lib>\n", 2);
  1249. cmVisualStudioGeneratorOptions
  1250. libOptions(this->LocalGenerator,
  1251. cmVisualStudioGeneratorOptions::Linker,
  1252. cmVS10LibFlagTable, 0, this);
  1253. libOptions.Parse(libflags?libflags:"");
  1254. libOptions.Parse(libflagsConfig?libflagsConfig:"");
  1255. libOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
  1256. libOptions.OutputFlagMap(*this->BuildFileStream, " ");
  1257. this->WriteString("</Lib>\n", 2);
  1258. }
  1259. }
  1260. void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const&
  1261. config)
  1262. {
  1263. // static libraries and things greater than modules do not need
  1264. // to set this option
  1265. if(this->Target->GetType() == cmTarget::STATIC_LIBRARY
  1266. || this->Target->GetType() > cmTarget::MODULE_LIBRARY)
  1267. {
  1268. return;
  1269. }
  1270. const char* linkLanguage =
  1271. this->Target->GetLinkerLanguage(config.c_str());
  1272. if(!linkLanguage)
  1273. {
  1274. cmSystemTools::Error
  1275. ("CMake can not determine linker language for target:",
  1276. this->Name.c_str());
  1277. return;
  1278. }
  1279. this->WriteString("<Link>\n", 2);
  1280. std::string CONFIG = cmSystemTools::UpperCase(config);
  1281. const char* linkType = "SHARED";
  1282. if(this->Target->GetType() == cmTarget::MODULE_LIBRARY)
  1283. {
  1284. linkType = "MODULE";
  1285. }
  1286. if(this->Target->GetType() == cmTarget::EXECUTABLE)
  1287. {
  1288. linkType = "EXE";
  1289. }
  1290. std::string stackVar = "CMAKE_";
  1291. stackVar += linkLanguage;
  1292. stackVar += "_STACK_SIZE";
  1293. const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str());
  1294. std::string flags;
  1295. if(stackVal)
  1296. {
  1297. flags += " ";
  1298. flags += stackVal;
  1299. }
  1300. // assume incremental linking
  1301. std::string linkFlagVarBase = "CMAKE_";
  1302. linkFlagVarBase += linkType;
  1303. linkFlagVarBase += "_LINKER_FLAGS";
  1304. flags += " ";
  1305. flags += this->
  1306. Target->GetMakefile()->GetRequiredDefinition(linkFlagVarBase.c_str());
  1307. std::string linkFlagVar = linkFlagVarBase + "_" + CONFIG;
  1308. flags += " ";
  1309. flags += this->
  1310. Target->GetMakefile()->GetRequiredDefinition(linkFlagVar.c_str());
  1311. const char* targetLinkFlags = this->Target->GetProperty("LINK_FLAGS");
  1312. if(targetLinkFlags)
  1313. {
  1314. flags += " ";
  1315. flags += targetLinkFlags;
  1316. }
  1317. std::string flagsProp = "LINK_FLAGS_";
  1318. flagsProp += CONFIG;
  1319. if(const char* flagsConfig = this->Target->GetProperty(flagsProp.c_str()))
  1320. {
  1321. flags += " ";
  1322. flags += flagsConfig;
  1323. }
  1324. cmVisualStudioGeneratorOptions
  1325. linkOptions(this->LocalGenerator,
  1326. cmVisualStudioGeneratorOptions::Linker,
  1327. cmVS10LinkFlagTable, 0, this);
  1328. if ( this->Target->GetPropertyAsBool("WIN32_EXECUTABLE") )
  1329. {
  1330. flags += " /SUBSYSTEM:WINDOWS";
  1331. }
  1332. else
  1333. {
  1334. flags += " /SUBSYSTEM:CONSOLE";
  1335. }
  1336. cmSystemTools::ReplaceString(flags, "/INCREMENTAL:YES", "");
  1337. cmSystemTools::ReplaceString(flags, "/INCREMENTAL:NO", "");
  1338. std::string standardLibsVar = "CMAKE_";
  1339. standardLibsVar += linkLanguage;
  1340. standardLibsVar += "_STANDARD_LIBRARIES";
  1341. std::string
  1342. libs = this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
  1343. // Remove trailing spaces from libs
  1344. std::string::size_type pos = libs.size()-1;
  1345. if(libs.size() != 0)
  1346. {
  1347. while(libs[pos] == ' ')
  1348. {
  1349. pos--;
  1350. }
  1351. }
  1352. if(pos != libs.size()-1)
  1353. {
  1354. libs = libs.substr(0, pos+1);
  1355. }
  1356. // Replace spaces in libs with ;
  1357. cmSystemTools::ReplaceString(libs, " ", ";");
  1358. cmComputeLinkInformation* pcli =
  1359. this->Target->GetLinkInformation(config.c_str());
  1360. if(!pcli)
  1361. {
  1362. cmSystemTools::Error
  1363. ("CMake can not compute cmComputeLinkInformation for target:",
  1364. this->Name.c_str());
  1365. return;
  1366. }
  1367. // add the libraries for the target to libs string
  1368. cmComputeLinkInformation& cli = *pcli;
  1369. this->AddLibraries(cli, libs);
  1370. linkOptions.AddFlag("AdditionalDependencies", libs.c_str());
  1371. std::vector<std::string> const& ldirs = cli.GetDirectories();
  1372. const char* sep = "";
  1373. std::string linkDirs;
  1374. for(std::vector<std::string>::const_iterator d = ldirs.begin();
  1375. d != ldirs.end(); ++d)
  1376. {
  1377. // first just full path
  1378. linkDirs += sep;
  1379. linkDirs += *d;
  1380. sep = ";";
  1381. linkDirs += sep;
  1382. // next path with configuration type Debug, Release, etc
  1383. linkDirs += *d;
  1384. linkDirs += "/$(Configuration)";
  1385. linkDirs += sep;
  1386. }
  1387. linkDirs += "%(AdditionalLibraryDirectories)";
  1388. linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs.c_str());
  1389. linkOptions.AddFlag("AdditionalDependencies", libs.c_str());
  1390. linkOptions.AddFlag("Version", "");
  1391. if(linkOptions.IsDebug() || flags.find("/debug") != flags.npos)
  1392. {
  1393. linkOptions.AddFlag("GenerateDebugInformation", "true");
  1394. }
  1395. else
  1396. {
  1397. linkOptions.AddFlag("GenerateDebugInformation", "false");
  1398. }
  1399. std::string targetName;
  1400. std::string targetNameSO;
  1401. std::string targetNameFull;
  1402. std::string targetNameImport;
  1403. std::string targetNamePDB;
  1404. if(this->Target->GetType() == cmTarget::EXECUTABLE)
  1405. {
  1406. this->Target->GetExecutableNames(targetName, targetNameFull,
  1407. targetNameImport, targetNamePDB,
  1408. config.c_str());
  1409. }
  1410. else
  1411. {
  1412. this->Target->GetLibraryNames(targetName, targetNameSO, targetNameFull,
  1413. targetNameImport, targetNamePDB,
  1414. config.c_str());
  1415. }
  1416. std::string dir = this->Target->GetDirectory(config.c_str());
  1417. dir += "/";
  1418. std::string pdb = dir;
  1419. pdb += targetNamePDB;
  1420. std::string imLib = this->Target->GetDirectory(config.c_str(), true);
  1421. imLib += "/";
  1422. imLib += targetNameImport;
  1423. linkOptions.AddFlag("ImportLibrary", imLib.c_str());
  1424. linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str());
  1425. linkOptions.Parse(flags.c_str());
  1426. if(!this->ModuleDefinitionFile.empty())
  1427. {
  1428. linkOptions.AddFlag("ModuleDefinitionFile",
  1429. this->ModuleDefinitionFile.c_str());
  1430. }
  1431. linkOptions.RemoveFlag("GenerateManifest");
  1432. linkOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
  1433. linkOptions.OutputFlagMap(*this->BuildFileStream, " ");
  1434. this->WriteString("</Link>\n", 2);
  1435. if(!this->GlobalGenerator->NeedLinkLibraryDependencies(*this->Target))
  1436. {
  1437. this->WriteString("<ProjectReference>\n", 2);
  1438. this->WriteString(
  1439. " <LinkLibraryDependencies>false</LinkLibraryDependencies>\n", 2);
  1440. this->WriteString("</ProjectReference>\n", 2);
  1441. }
  1442. }
  1443. void cmVisualStudio10TargetGenerator::AddLibraries(
  1444. cmComputeLinkInformation& cli,
  1445. std::string& libstring)
  1446. {
  1447. typedef cmComputeLinkInformation::ItemVector ItemVector;
  1448. ItemVector libs = cli.GetItems();
  1449. const char* sep = ";";
  1450. for(ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l)
  1451. {
  1452. if(l->IsPath)
  1453. {
  1454. std::string path = this->LocalGenerator->
  1455. Convert(l->Value.c_str(),
  1456. cmLocalGenerator::START_OUTPUT,
  1457. cmLocalGenerator::UNCHANGED);
  1458. this->ConvertToWindowsSlash(path);
  1459. libstring += sep;
  1460. libstring += path;
  1461. }
  1462. else
  1463. {
  1464. libstring += sep;
  1465. libstring += l->Value;
  1466. }
  1467. }
  1468. }
  1469. void cmVisualStudio10TargetGenerator::
  1470. WriteMidlOptions(std::string const& /*config*/,
  1471. std::vector<std::string> const & includes)
  1472. {
  1473. this->WriteString("<Midl>\n", 2);
  1474. this->OutputIncludes(includes);
  1475. this->WriteString("<OutputDirectory>$(IntDir)</OutputDirectory>\n", 3);
  1476. this->WriteString("<HeaderFileName>%(Filename).h</HeaderFileName>\n", 3);
  1477. this->WriteString(
  1478. "<TypeLibraryName>%(Filename).tlb</TypeLibraryName>\n", 3);
  1479. this->WriteString(
  1480. "<InterfaceIdentifierFileName>"
  1481. "%(Filename)_i.c</InterfaceIdentifierFileName>\n", 3);
  1482. this->WriteString("<ProxyFileName>%(Filename)_p.c</ProxyFileName>\n",3);
  1483. this->WriteString("</Midl>\n", 2);
  1484. }
  1485. void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
  1486. {
  1487. std::vector<std::string> *configs =
  1488. static_cast<cmGlobalVisualStudio7Generator *>
  1489. (this->GlobalGenerator)->GetConfigurations();
  1490. std::vector<std::string> includes;
  1491. this->LocalGenerator->GetIncludeDirectories(includes, this->Target);
  1492. for(std::vector<std::string>::iterator i = configs->begin();
  1493. i != configs->end(); ++i)
  1494. {
  1495. this->WritePlatformConfigTag("ItemDefinitionGroup", i->c_str(), 1);
  1496. *this->BuildFileStream << "\n";
  1497. // output cl compile flags <ClCompile></ClCompile>
  1498. if(this->Target->GetType() <= cmTarget::MODULE_LIBRARY)
  1499. {
  1500. this->WriteClOptions(*i, includes);
  1501. // output rc compile flags <ResourceCompile></ResourceCompile>
  1502. this->WriteRCOptions(*i, includes);
  1503. }
  1504. // output midl flags <Midl></Midl>
  1505. this->WriteMidlOptions(*i, includes);
  1506. // write events
  1507. this->WriteEvents(*i);
  1508. // output link flags <Link></Link>
  1509. this->WriteLinkOptions(*i);
  1510. // output lib flags <Lib></Lib>
  1511. this->WriteLibOptions(*i);
  1512. this->WriteString("</ItemDefinitionGroup>\n", 1);
  1513. }
  1514. }
  1515. void
  1516. cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName)
  1517. {
  1518. this->WriteEvent("PreLinkEvent",
  1519. this->Target->GetPreLinkCommands(), configName);
  1520. this->WriteEvent("PreBuildEvent",
  1521. this->Target->GetPreBuildCommands(), configName);
  1522. this->WriteEvent("PostBuildEvent",
  1523. this->Target->GetPostBuildCommands(), configName);
  1524. }
  1525. void cmVisualStudio10TargetGenerator::WriteEvent(
  1526. const char* name,
  1527. std::vector<cmCustomCommand> & commands,
  1528. std::string const& configName)
  1529. {
  1530. if(commands.size() == 0)
  1531. {
  1532. return;
  1533. }
  1534. this->WriteString("<", 2);
  1535. (*this->BuildFileStream ) << name << ">\n";
  1536. cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
  1537. std::string script;
  1538. const char* pre = "";
  1539. std::string comment;
  1540. for(std::vector<cmCustomCommand>::iterator i = commands.begin();
  1541. i != commands.end(); ++i)
  1542. {
  1543. cmCustomCommand& command = *i;
  1544. comment += pre;
  1545. comment += lg->ConstructComment(command);
  1546. script += pre;
  1547. pre = "\n";
  1548. script +=
  1549. cmVS10EscapeXML(lg->ConstructScript(command, configName.c_str()));
  1550. }
  1551. comment = cmVS10EscapeComment(comment);
  1552. this->WriteString("<Message>",3);
  1553. (*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "</Message>\n";
  1554. this->WriteString("<Command>", 3);
  1555. (*this->BuildFileStream ) << script;
  1556. (*this->BuildFileStream ) << "</Command>" << "\n";
  1557. this->WriteString("</", 2);
  1558. (*this->BuildFileStream ) << name << ">\n";
  1559. }
  1560. void cmVisualStudio10TargetGenerator::WriteProjectReferences()
  1561. {
  1562. cmGlobalGenerator::TargetDependSet const& unordered
  1563. = this->GlobalGenerator->GetTargetDirectDepends(*this->Target);
  1564. typedef cmGlobalVisualStudioGenerator::OrderedTargetDependSet
  1565. OrderedTargetDependSet;
  1566. OrderedTargetDependSet depends(unordered);
  1567. this->WriteString("<ItemGroup>\n", 1);
  1568. for( OrderedTargetDependSet::const_iterator i = depends.begin();
  1569. i != depends.end(); ++i)
  1570. {
  1571. cmTarget* dt = *i;
  1572. // skip fortran targets as they can not be processed by MSBuild
  1573. // the only reference will be in the .sln file
  1574. if(static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
  1575. ->TargetIsFortranOnly(*dt))
  1576. {
  1577. continue;
  1578. }
  1579. this->WriteString("<ProjectReference Include=\"", 2);
  1580. cmMakefile* mf = dt->GetMakefile();
  1581. std::string name = dt->GetName();
  1582. std::string path;
  1583. const char* p = dt->GetProperty("EXTERNAL_MSPROJECT");
  1584. if(p)
  1585. {
  1586. path = p;
  1587. }
  1588. else
  1589. {
  1590. path = mf->GetStartOutputDirectory();
  1591. path += "/";
  1592. path += dt->GetName();
  1593. path += ".vcxproj";
  1594. }
  1595. (*this->BuildFileStream) << path << "\">\n";
  1596. this->WriteString("<Project>", 3);
  1597. (*this->BuildFileStream)
  1598. << this->GlobalGenerator->GetGUID(name.c_str())
  1599. << "</Project>\n";
  1600. this->WriteString("</ProjectReference>\n", 2);
  1601. }
  1602. this->WriteString("</ItemGroup>\n", 1);
  1603. }