cmVisualStudio10TargetGenerator.cxx 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699
  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
  371. {
  372. this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2);
  373. }
  374. if(const char* toolset = gg->GetPlatformToolset())
  375. {
  376. std::string pts = "<PlatformToolset>";
  377. pts += toolset;
  378. pts += "</PlatformToolset>\n";
  379. this->WriteString(pts.c_str(), 2);
  380. }
  381. if(this->Target->GetPropertyAsBool("VS_WINRT_EXTENSIONS"))
  382. {
  383. this->WriteString("<Immersive>true</Immersive>\n", 2);
  384. }
  385. this->WriteString("</PropertyGroup>\n", 1);
  386. }
  387. }
  388. void cmVisualStudio10TargetGenerator::WriteCustomCommands()
  389. {
  390. this->SourcesVisited.clear();
  391. std::vector<cmSourceFile*> const& sources = this->Target->GetSourceFiles();
  392. for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
  393. source != sources.end(); ++source)
  394. {
  395. cmSourceFile* sf = *source;
  396. this->WriteCustomCommand(sf);
  397. }
  398. }
  399. //----------------------------------------------------------------------------
  400. void cmVisualStudio10TargetGenerator::WriteCustomCommand(cmSourceFile* sf)
  401. {
  402. if(this->SourcesVisited.insert(sf).second)
  403. {
  404. if(std::vector<cmSourceFile*> const* depends =
  405. this->Target->GetSourceDepends(sf))
  406. {
  407. for(std::vector<cmSourceFile*>::const_iterator di = depends->begin();
  408. di != depends->end(); ++di)
  409. {
  410. this->WriteCustomCommand(*di);
  411. }
  412. }
  413. if(cmCustomCommand const* command = sf->GetCustomCommand())
  414. {
  415. this->WriteString("<ItemGroup>\n", 1);
  416. this->WriteCustomRule(sf, *command);
  417. this->WriteString("</ItemGroup>\n", 1);
  418. }
  419. }
  420. }
  421. void
  422. cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
  423. cmCustomCommand const &
  424. command)
  425. {
  426. std::string sourcePath = source->GetFullPath();
  427. // the rule file seems to need to exist for vs10
  428. if (source->GetExtension() == "rule")
  429. {
  430. if(!cmSystemTools::FileExists(sourcePath.c_str()))
  431. {
  432. // Make sure the path exists for the file
  433. std::string path = cmSystemTools::GetFilenamePath(sourcePath);
  434. cmSystemTools::MakeDirectory(path.c_str());
  435. std::ofstream fout(sourcePath.c_str());
  436. if(fout)
  437. {
  438. fout << "# generated from CMake\n";
  439. fout.flush();
  440. fout.close();
  441. }
  442. else
  443. {
  444. std::string error = "Could not create file: [";
  445. error += sourcePath;
  446. error += "] ";
  447. cmSystemTools::Error
  448. (error.c_str(), cmSystemTools::GetLastSystemError().c_str());
  449. }
  450. }
  451. }
  452. cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
  453. std::string comment = lg->ConstructComment(command);
  454. comment = cmVS10EscapeComment(comment);
  455. std::vector<std::string> *configs =
  456. static_cast<cmGlobalVisualStudio7Generator *>
  457. (this->GlobalGenerator)->GetConfigurations();
  458. this->WriteString("<CustomBuild Include=\"", 2);
  459. // custom command have to use relative paths or they do not
  460. // show up in the GUI
  461. std::string path = cmSystemTools::RelativePath(
  462. this->Makefile->GetCurrentOutputDirectory(),
  463. sourcePath.c_str());
  464. this->ConvertToWindowsSlash(path);
  465. (*this->BuildFileStream ) << path << "\">\n";
  466. for(std::vector<std::string>::iterator i = configs->begin();
  467. i != configs->end(); ++i)
  468. {
  469. std::string script =
  470. cmVS10EscapeXML(lg->ConstructScript(command, i->c_str()));
  471. this->WritePlatformConfigTag("Message",i->c_str(), 3);
  472. (*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "</Message>\n";
  473. this->WritePlatformConfigTag("Command", i->c_str(), 3);
  474. (*this->BuildFileStream ) << script << "</Command>\n";
  475. this->WritePlatformConfigTag("AdditionalInputs", i->c_str(), 3);
  476. (*this->BuildFileStream ) << source->GetFullPath();
  477. for(std::vector<std::string>::const_iterator d =
  478. command.GetDepends().begin();
  479. d != command.GetDepends().end();
  480. ++d)
  481. {
  482. std::string dep;
  483. if(this->LocalGenerator->GetRealDependency(d->c_str(), i->c_str(), dep))
  484. {
  485. this->ConvertToWindowsSlash(dep);
  486. (*this->BuildFileStream ) << ";" << dep;
  487. }
  488. }
  489. (*this->BuildFileStream ) << ";%(AdditionalInputs)</AdditionalInputs>\n";
  490. this->WritePlatformConfigTag("Outputs", i->c_str(), 3);
  491. const char* sep = "";
  492. for(std::vector<std::string>::const_iterator o =
  493. command.GetOutputs().begin();
  494. o != command.GetOutputs().end();
  495. ++o)
  496. {
  497. std::string out = *o;
  498. this->ConvertToWindowsSlash(out);
  499. (*this->BuildFileStream ) << sep << out;
  500. sep = ";";
  501. }
  502. (*this->BuildFileStream ) << "</Outputs>\n";
  503. }
  504. this->WriteString("</CustomBuild>\n", 2);
  505. }
  506. void cmVisualStudio10TargetGenerator::ConvertToWindowsSlash(std::string& s)
  507. {
  508. // first convert all of the slashes
  509. std::string::size_type pos = 0;
  510. while((pos = s.find('/', pos)) != std::string::npos)
  511. {
  512. s[pos] = '\\';
  513. pos++;
  514. }
  515. }
  516. void cmVisualStudio10TargetGenerator::WriteGroups()
  517. {
  518. // collect up group information
  519. std::vector<cmSourceGroup> sourceGroups =
  520. this->Makefile->GetSourceGroups();
  521. std::vector<cmSourceFile*> classes = this->Target->GetSourceFiles();
  522. std::set<cmSourceGroup*> groupsUsed;
  523. std::vector<cmSourceFile*> clCompile;
  524. std::vector<cmSourceFile*> customBuild;
  525. std::vector<cmSourceFile*> none;
  526. std::vector<cmSourceFile*> headers;
  527. std::vector<cmSourceFile*> idls;
  528. std::vector<cmSourceFile*> resource;
  529. for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();
  530. s != classes.end(); s++)
  531. {
  532. cmSourceFile* sf = *s;
  533. std::string const& source = sf->GetFullPath();
  534. cmSourceGroup& sourceGroup =
  535. this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
  536. groupsUsed.insert(&sourceGroup);
  537. const char* lang = sf->GetLanguage();
  538. bool header = (*s)->GetPropertyAsBool("HEADER_FILE_ONLY")
  539. || this->GlobalGenerator->IgnoreFile
  540. ((*s)->GetExtension().c_str());
  541. std::string ext =
  542. cmSystemTools::LowerCase((*s)->GetExtension());
  543. if(!lang)
  544. {
  545. lang = "None";
  546. }
  547. if(header)
  548. {
  549. headers.push_back(sf);
  550. }
  551. else if(lang[0] == 'C')
  552. {
  553. clCompile.push_back(sf);
  554. }
  555. else if(strcmp(lang, "RC") == 0)
  556. {
  557. resource.push_back(sf);
  558. }
  559. else if(sf->GetCustomCommand())
  560. {
  561. customBuild.push_back(sf);
  562. }
  563. else if(ext == "idl")
  564. {
  565. idls.push_back(sf);
  566. }
  567. else
  568. {
  569. none.push_back(sf);
  570. }
  571. }
  572. this->AddMissingSourceGroups(groupsUsed, sourceGroups);
  573. // Write out group file
  574. std::string path = this->Makefile->GetStartOutputDirectory();
  575. path += "/";
  576. path += this->Name;
  577. path += ".vcxproj.filters";
  578. cmGeneratedFileStream fout(path.c_str());
  579. fout.SetCopyIfDifferent(true);
  580. char magic[] = {0xEF,0xBB, 0xBF};
  581. fout.write(magic, 3);
  582. cmGeneratedFileStream* save = this->BuildFileStream;
  583. this->BuildFileStream = & fout;
  584. this->WriteString("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"
  585. "<Project "
  586. "ToolsVersion=\"4.0\" "
  587. "xmlns=\"http://schemas.microsoft.com/"
  588. "developer/msbuild/2003\">\n",
  589. 0);
  590. this->WriteGroupSources("ClCompile", clCompile, sourceGroups);
  591. this->WriteGroupSources("ClInclude", headers, sourceGroups);
  592. this->WriteGroupSources("ResourceCompile", resource, sourceGroups);
  593. this->WriteGroupSources("Midl", idls, sourceGroups);
  594. this->WriteGroupSources("CustomBuild", customBuild, sourceGroups);
  595. this->WriteString("<ItemGroup>\n", 1);
  596. for(std::set<cmSourceGroup*>::iterator g = groupsUsed.begin();
  597. g != groupsUsed.end(); ++g)
  598. {
  599. cmSourceGroup* sg = *g;
  600. const char* name = sg->GetFullName();
  601. if(strlen(name) != 0)
  602. {
  603. this->WriteString("<Filter Include=\"", 2);
  604. (*this->BuildFileStream) << name << "\">\n";
  605. std::string guidName = "SG_Filter_";
  606. guidName += name;
  607. this->GlobalGenerator->CreateGUID(guidName.c_str());
  608. this->WriteString("<UniqueIdentifier>", 3);
  609. std::string guid
  610. = this->GlobalGenerator->GetGUID(guidName.c_str());
  611. (*this->BuildFileStream)
  612. << "{"
  613. << guid << "}"
  614. << "</UniqueIdentifier>\n";
  615. this->WriteString("</Filter>\n", 2);
  616. }
  617. }
  618. this->WriteString("</ItemGroup>\n", 1);
  619. this->WriteGroupSources("None", none, sourceGroups);
  620. this->WriteString("</Project>\n", 0);
  621. // restore stream pointer
  622. this->BuildFileStream = save;
  623. if (fout.Close())
  624. {
  625. this->GlobalGenerator->FileReplacedDuringGenerate(path);
  626. }
  627. }
  628. // Add to groupsUsed empty source groups that have non-empty children.
  629. void
  630. cmVisualStudio10TargetGenerator::AddMissingSourceGroups(
  631. std::set<cmSourceGroup*>& groupsUsed,
  632. const std::vector<cmSourceGroup>& allGroups
  633. )
  634. {
  635. for(std::vector<cmSourceGroup>::const_iterator current = allGroups.begin();
  636. current != allGroups.end(); ++current)
  637. {
  638. std::vector<cmSourceGroup> const& children = current->GetGroupChildren();
  639. if(children.empty())
  640. {
  641. continue; // the group is really empty
  642. }
  643. this->AddMissingSourceGroups(groupsUsed, children);
  644. cmSourceGroup* current_ptr = const_cast<cmSourceGroup*>(&(*current));
  645. if(groupsUsed.find(current_ptr) != groupsUsed.end())
  646. {
  647. continue; // group has already been added to set
  648. }
  649. // check if it least one of the group's descendants is not empty
  650. // (at least one child must already have been added)
  651. std::vector<cmSourceGroup>::const_iterator child_it = children.begin();
  652. while(child_it != children.end())
  653. {
  654. cmSourceGroup* child_ptr = const_cast<cmSourceGroup*>(&(*child_it));
  655. if(groupsUsed.find(child_ptr) != groupsUsed.end())
  656. {
  657. break; // found a child that was already added => add current group too
  658. }
  659. child_it++;
  660. }
  661. if(child_it == children.end())
  662. {
  663. continue; // no descendants have source files => ignore this group
  664. }
  665. groupsUsed.insert(current_ptr);
  666. }
  667. }
  668. void
  669. cmVisualStudio10TargetGenerator::
  670. WriteGroupSources(const char* name,
  671. std::vector<cmSourceFile*> const& sources,
  672. std::vector<cmSourceGroup>& sourceGroups)
  673. {
  674. this->WriteString("<ItemGroup>\n", 1);
  675. for(std::vector<cmSourceFile*>::const_iterator s = sources.begin();
  676. s != sources.end(); ++s)
  677. {
  678. cmSourceFile* sf = *s;
  679. if(sf->GetExtension() == "obj")
  680. {
  681. continue;
  682. }
  683. std::string const& source = sf->GetFullPath();
  684. cmSourceGroup& sourceGroup =
  685. this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
  686. const char* filter = sourceGroup.GetFullName();
  687. this->WriteString("<", 2);
  688. std::string path = source;
  689. // custom command sources must use relative paths or they will
  690. // not show up in the GUI.
  691. if(sf->GetCustomCommand())
  692. {
  693. path = cmSystemTools::RelativePath(
  694. this->Makefile->GetCurrentOutputDirectory(),
  695. source.c_str());
  696. }
  697. this->ConvertToWindowsSlash(path);
  698. (*this->BuildFileStream) << name << " Include=\""
  699. << path;
  700. if(strlen(filter))
  701. {
  702. (*this->BuildFileStream) << "\">\n";
  703. this->WriteString("<Filter>", 3);
  704. (*this->BuildFileStream) << filter << "</Filter>\n";
  705. this->WriteString("</", 2);
  706. (*this->BuildFileStream) << name << ">\n";
  707. }
  708. else
  709. {
  710. (*this->BuildFileStream) << "\" />\n";
  711. }
  712. }
  713. this->WriteString("</ItemGroup>\n", 1);
  714. }
  715. void cmVisualStudio10TargetGenerator::WriteObjSources()
  716. {
  717. if(this->Target->GetType() > cmTarget::MODULE_LIBRARY)
  718. {
  719. return;
  720. }
  721. bool first = true;
  722. std::vector<cmSourceFile*>const & sources = this->Target->GetSourceFiles();
  723. for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
  724. source != sources.end(); ++source)
  725. {
  726. std::string ext =
  727. cmSystemTools::LowerCase((*source)->GetExtension());
  728. if(ext == "obj" || ext == "o")
  729. {
  730. if(first)
  731. {
  732. this->WriteString("<ItemGroup>\n", 1);
  733. first = false;
  734. }
  735. // If an object file is generated, then vs10
  736. // will use it in the build, and we have to list
  737. // it as None instead of Object
  738. if((*source)->GetPropertyAsBool("GENERATED"))
  739. {
  740. this->WriteString("<None Include=\"", 2);
  741. }
  742. // If it is not a generated object then we have
  743. // to use the Object type
  744. else
  745. {
  746. this->WriteString("<Object Include=\"", 2);
  747. }
  748. (*this->BuildFileStream ) << (*source)->GetFullPath() << "\" />\n";
  749. }
  750. }
  751. if(!first)
  752. {
  753. this->WriteString("</ItemGroup>\n", 1);
  754. }
  755. }
  756. void cmVisualStudio10TargetGenerator::WriteCLSources()
  757. {
  758. if(this->Target->GetType() > cmTarget::UTILITY)
  759. {
  760. return;
  761. }
  762. this->WriteString("<ItemGroup>\n", 1);
  763. std::vector<cmSourceFile*>const& sources = this->Target->GetSourceFiles();
  764. for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
  765. source != sources.end(); ++source)
  766. {
  767. std::string ext = cmSystemTools::LowerCase((*source)->GetExtension());
  768. if((*source)->GetCustomCommand() || ext == "o" || ext == "obj")
  769. {
  770. continue;
  771. }
  772. // If it is not a custom command and it is not a pre-built obj file,
  773. // then add it as a source (c/c++/header/rc/idl) file
  774. bool header = (*source)->GetPropertyAsBool("HEADER_FILE_ONLY")
  775. || this->GlobalGenerator->IgnoreFile(ext.c_str());
  776. const char* lang = (*source)->GetLanguage();
  777. bool cl = lang && (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") ==0);
  778. bool rc = lang && (strcmp(lang, "RC") == 0);
  779. bool idl = ext == "idl";
  780. std::string sourceFile = (*source)->GetFullPath();
  781. // do not use a relative path here because it means that you
  782. // can not use as long a path to the file.
  783. this->ConvertToWindowsSlash(sourceFile);
  784. // output the source file
  785. if(header)
  786. {
  787. this->WriteString("<ClInclude Include=\"", 2);
  788. }
  789. else if(cl)
  790. {
  791. this->WriteString("<ClCompile Include=\"", 2);
  792. }
  793. else if(rc)
  794. {
  795. this->WriteString("<ResourceCompile Include=\"", 2);
  796. }
  797. else if(idl)
  798. {
  799. this->WriteString("<Midl Include=\"", 2);
  800. }
  801. else
  802. {
  803. this->WriteString("<None Include=\"", 2);
  804. }
  805. (*this->BuildFileStream ) << sourceFile << "\"";
  806. // ouput any flags specific to this source file
  807. if(!header && cl && this->OutputSourceSpecificFlags(*source))
  808. {
  809. // if the source file has specific flags the tag
  810. // is ended on a new line
  811. this->WriteString("</ClCompile>\n", 2);
  812. }
  813. else if(!header && rc && this->OutputSourceSpecificFlags(*source))
  814. {
  815. this->WriteString("</ResourceCompile>\n", 2);
  816. }
  817. else
  818. {
  819. (*this->BuildFileStream ) << " />\n";
  820. }
  821. }
  822. this->WriteString("</ItemGroup>\n", 1);
  823. }
  824. void cmVisualStudio10TargetGenerator::ComputeObjectNames()
  825. {
  826. // get the classes from the source lists then add them to the groups
  827. std::vector<cmSourceFile*>const & classes = this->Target->GetSourceFiles();
  828. for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
  829. i != classes.end(); i++)
  830. {
  831. // Add the file to the list of sources.
  832. std::string source = (*i)->GetFullPath();
  833. if(cmSystemTools::UpperCase((*i)->GetExtension()) == "DEF")
  834. {
  835. this->ModuleDefinitionFile = (*i)->GetFullPath();
  836. }
  837. }
  838. // Compute which sources need unique object computation.
  839. this->LocalGenerator->ComputeObjectNameRequirements(classes);
  840. }
  841. bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
  842. cmSourceFile* source)
  843. {
  844. cmSourceFile& sf = *source;
  845. cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
  846. // Compute the maximum length full path to the intermediate
  847. // files directory for any configuration. This is used to construct
  848. // object file names that do not produce paths that are too long.
  849. std::string dir_max;
  850. lg->ComputeMaxDirectoryLength(dir_max, *this->Target);
  851. std::string objectName;
  852. if(lg->NeedObjectName.find(&sf) != lg->NeedObjectName.end())
  853. {
  854. objectName = lg->GetObjectFileNameWithoutTarget(sf, dir_max);
  855. }
  856. std::string flags;
  857. std::string defines;
  858. if(const char* cflags = sf.GetProperty("COMPILE_FLAGS"))
  859. {
  860. flags += cflags;
  861. }
  862. if(const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS"))
  863. {
  864. defines += cdefs;
  865. }
  866. const char* lang =
  867. this->GlobalGenerator->GetLanguageFromExtension
  868. (sf.GetExtension().c_str());
  869. const char* sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf);
  870. const char* linkLanguage = this->Target->GetLinkerLanguage();
  871. bool needForceLang = false;
  872. // source file does not match its extension language
  873. if(lang && sourceLang && strcmp(lang, sourceLang) != 0)
  874. {
  875. needForceLang = true;
  876. lang = sourceLang;
  877. }
  878. // if the source file does not match the linker language
  879. // then force c or c++
  880. if(needForceLang || (linkLanguage && lang
  881. && strcmp(lang, linkLanguage) != 0))
  882. {
  883. if(strcmp(lang, "CXX") == 0)
  884. {
  885. // force a C++ file type
  886. flags += " /TP ";
  887. }
  888. else if(strcmp(lang, "C") == 0)
  889. {
  890. // force to c
  891. flags += " /TC ";
  892. }
  893. }
  894. bool hasFlags = false;
  895. // for the first time we need a new line if there is something
  896. // produced here.
  897. const char* firstString = ">\n";
  898. if(objectName.size())
  899. {
  900. (*this->BuildFileStream ) << firstString;
  901. firstString = "";
  902. hasFlags = true;
  903. this->WriteString("<ObjectFileName>", 3);
  904. (*this->BuildFileStream )
  905. << "$(IntDir)/" << objectName << "</ObjectFileName>\n";
  906. }
  907. std::vector<std::string> *configs =
  908. static_cast<cmGlobalVisualStudio7Generator *>
  909. (this->GlobalGenerator)->GetConfigurations();
  910. for( std::vector<std::string>::iterator config = configs->begin();
  911. config != configs->end(); ++config)
  912. {
  913. std::string configUpper = cmSystemTools::UpperCase(*config);
  914. std::string configDefines = defines;
  915. std::string defPropName = "COMPILE_DEFINITIONS_";
  916. defPropName += configUpper;
  917. if(const char* ccdefs = sf.GetProperty(defPropName.c_str()))
  918. {
  919. if(configDefines.size())
  920. {
  921. configDefines += ";";
  922. }
  923. configDefines += ccdefs;
  924. }
  925. // if we have flags or defines for this config then
  926. // use them
  927. if(flags.size() || configDefines.size())
  928. {
  929. (*this->BuildFileStream ) << firstString;
  930. firstString = ""; // only do firstString once
  931. hasFlags = true;
  932. cmVisualStudioGeneratorOptions
  933. clOptions(this->LocalGenerator,
  934. cmVisualStudioGeneratorOptions::Compiler,
  935. cmVS10CLFlagTable, 0, this);
  936. clOptions.Parse(flags.c_str());
  937. clOptions.AddDefines(configDefines.c_str());
  938. clOptions.SetConfiguration((*config).c_str());
  939. clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
  940. clOptions.OutputFlagMap(*this->BuildFileStream, " ");
  941. clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream,
  942. " ", "\n", lang);
  943. }
  944. }
  945. return hasFlags;
  946. }
  947. void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions()
  948. {
  949. cmTarget::TargetType ttype = this->Target->GetType();
  950. if(ttype > cmTarget::GLOBAL_TARGET)
  951. {
  952. return;
  953. }
  954. this->WriteString("<PropertyGroup>\n", 2);
  955. this->WriteString("<_ProjectFileVersion>10.0.20506.1"
  956. "</_ProjectFileVersion>\n", 3);
  957. std::vector<std::string> *configs =
  958. static_cast<cmGlobalVisualStudio7Generator *>
  959. (this->GlobalGenerator)->GetConfigurations();
  960. for(std::vector<std::string>::iterator config = configs->begin();
  961. config != configs->end(); ++config)
  962. {
  963. if(ttype >= cmTarget::UTILITY)
  964. {
  965. this->WritePlatformConfigTag("IntDir", config->c_str(), 3);
  966. *this->BuildFileStream
  967. << "$(Platform)\\$(Configuration)\\$(ProjectName)\\"
  968. << "</IntDir>\n";
  969. }
  970. else
  971. {
  972. std::string targetNameFull =
  973. this->Target->GetFullName(config->c_str());
  974. std::string intermediateDir = this->LocalGenerator->
  975. GetTargetDirectory(*this->Target);
  976. intermediateDir += "/";
  977. intermediateDir += *config;
  978. intermediateDir += "/";
  979. this->ConvertToWindowsSlash(intermediateDir);
  980. std::string outDir = this->Target->GetDirectory(config->c_str());
  981. this->ConvertToWindowsSlash(outDir);
  982. this->WritePlatformConfigTag("OutDir", config->c_str(), 3);
  983. *this->BuildFileStream << outDir
  984. << "\\"
  985. << "</OutDir>\n";
  986. this->WritePlatformConfigTag("IntDir", config->c_str(), 3);
  987. *this->BuildFileStream << intermediateDir
  988. << "</IntDir>\n";
  989. this->WritePlatformConfigTag("TargetName", config->c_str(), 3);
  990. *this->BuildFileStream
  991. << cmSystemTools::GetFilenameWithoutLastExtension(
  992. targetNameFull.c_str())
  993. << "</TargetName>\n";
  994. this->WritePlatformConfigTag("TargetExt", config->c_str(), 3);
  995. *this->BuildFileStream
  996. << cmSystemTools::GetFilenameLastExtension(targetNameFull.c_str())
  997. << "</TargetExt>\n";
  998. this->OutputLinkIncremental(*config);
  999. }
  1000. }
  1001. this->WriteString("</PropertyGroup>\n", 2);
  1002. }
  1003. void
  1004. cmVisualStudio10TargetGenerator::
  1005. OutputLinkIncremental(std::string const& configName)
  1006. {
  1007. std::string CONFIG = cmSystemTools::UpperCase(configName);
  1008. // static libraries and things greater than modules do not need
  1009. // to set this option
  1010. if(this->Target->GetType() == cmTarget::STATIC_LIBRARY
  1011. || this->Target->GetType() > cmTarget::MODULE_LIBRARY)
  1012. {
  1013. return;
  1014. }
  1015. const char* linkType = "SHARED";
  1016. if(this->Target->GetType() == cmTarget::EXECUTABLE)
  1017. {
  1018. linkType = "EXE";
  1019. }
  1020. // assume incremental linking
  1021. const char* incremental = "true";
  1022. const char* linkLanguage =
  1023. this->Target->GetLinkerLanguage(configName.c_str());
  1024. if(!linkLanguage)
  1025. {
  1026. cmSystemTools::Error
  1027. ("CMake can not determine linker language for target:",
  1028. this->Name.c_str());
  1029. return;
  1030. }
  1031. std::string linkFlagVarBase = "CMAKE_";
  1032. linkFlagVarBase += linkType;
  1033. linkFlagVarBase += "_LINKER_FLAGS";
  1034. std::string flags = this->
  1035. Target->GetMakefile()->GetRequiredDefinition(linkFlagVarBase.c_str());
  1036. std::string linkFlagVar = linkFlagVarBase + "_" + CONFIG;
  1037. flags += this->
  1038. Target->GetMakefile()->GetRequiredDefinition(linkFlagVar.c_str());
  1039. if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0
  1040. || strcmp(linkLanguage, "Fortran") == 0)
  1041. {
  1042. std::string baseFlagVar = "CMAKE_";
  1043. baseFlagVar += linkLanguage;
  1044. baseFlagVar += "_FLAGS";
  1045. flags += this->
  1046. Target->GetMakefile()->GetRequiredDefinition(baseFlagVar.c_str());
  1047. std::string flagVar = baseFlagVar + std::string("_") + CONFIG;
  1048. flags +=
  1049. Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str());
  1050. }
  1051. const char* targetLinkFlags = this->Target->GetProperty("LINK_FLAGS");
  1052. if(targetLinkFlags)
  1053. {
  1054. flags += " ";
  1055. flags += targetLinkFlags;
  1056. }
  1057. std::string flagsProp = "LINK_FLAGS_";
  1058. flagsProp += CONFIG;
  1059. if(const char* flagsConfig = this->Target->GetProperty(flagsProp.c_str()))
  1060. {
  1061. flags += " ";
  1062. flags += flagsConfig;
  1063. }
  1064. if(flags.find("INCREMENTAL:NO") != flags.npos)
  1065. {
  1066. incremental = "false";
  1067. }
  1068. this->WritePlatformConfigTag("LinkIncremental", configName.c_str(), 3);
  1069. *this->BuildFileStream << incremental
  1070. << "</LinkIncremental>\n";
  1071. const char* manifest = "true";
  1072. if(flags.find("MANIFEST:NO") != flags.npos)
  1073. {
  1074. manifest = "false";
  1075. }
  1076. this->WritePlatformConfigTag("GenerateManifest", configName.c_str(), 3);
  1077. *this->BuildFileStream << manifest
  1078. << "</GenerateManifest>\n";
  1079. }
  1080. //----------------------------------------------------------------------------
  1081. bool cmVisualStudio10TargetGenerator::ComputeClOptions()
  1082. {
  1083. std::vector<std::string> const* configs =
  1084. this->GlobalGenerator->GetConfigurations();
  1085. for(std::vector<std::string>::const_iterator i = configs->begin();
  1086. i != configs->end(); ++i)
  1087. {
  1088. if(!this->ComputeClOptions(*i))
  1089. {
  1090. return false;
  1091. }
  1092. }
  1093. return true;
  1094. }
  1095. //----------------------------------------------------------------------------
  1096. bool cmVisualStudio10TargetGenerator::ComputeClOptions(
  1097. std::string const& configName)
  1098. {
  1099. // much of this was copied from here:
  1100. // copied from cmLocalVisualStudio7Generator.cxx 805
  1101. // TODO: Integrate code below with cmLocalVisualStudio7Generator.
  1102. cmsys::auto_ptr<Options> pOptions(
  1103. new Options(this->LocalGenerator, Options::Compiler,
  1104. cmVS10CLFlagTable));
  1105. Options& clOptions = *pOptions;
  1106. std::string flags;
  1107. // collect up flags for
  1108. if(this->Target->GetType() < cmTarget::UTILITY)
  1109. {
  1110. const char* linkLanguage =
  1111. this->Target->GetLinkerLanguage(configName.c_str());
  1112. if(!linkLanguage)
  1113. {
  1114. cmSystemTools::Error
  1115. ("CMake can not determine linker language for target:",
  1116. this->Name.c_str());
  1117. return false;
  1118. }
  1119. if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0
  1120. || strcmp(linkLanguage, "Fortran") == 0)
  1121. {
  1122. std::string baseFlagVar = "CMAKE_";
  1123. baseFlagVar += linkLanguage;
  1124. baseFlagVar += "_FLAGS";
  1125. flags = this->
  1126. Target->GetMakefile()->GetRequiredDefinition(baseFlagVar.c_str());
  1127. std::string flagVar = baseFlagVar + std::string("_") +
  1128. cmSystemTools::UpperCase(configName);
  1129. flags += " ";
  1130. flags += this->
  1131. Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str());
  1132. }
  1133. // set the correct language
  1134. if(strcmp(linkLanguage, "C") == 0)
  1135. {
  1136. flags += " /TC ";
  1137. }
  1138. if(strcmp(linkLanguage, "CXX") == 0)
  1139. {
  1140. flags += " /TP ";
  1141. }
  1142. }
  1143. // Add the target-specific flags.
  1144. if(const char* targetFlags = this->Target->GetProperty("COMPILE_FLAGS"))
  1145. {
  1146. flags += " ";
  1147. flags += targetFlags;
  1148. }
  1149. std::string configUpper = cmSystemTools::UpperCase(configName);
  1150. std::string defPropName = "COMPILE_DEFINITIONS_";
  1151. defPropName += configUpper;
  1152. // Get preprocessor definitions for this directory.
  1153. std::string defineFlags = this->Target->GetMakefile()->GetDefineFlags();
  1154. clOptions.FixExceptionHandlingDefault();
  1155. clOptions.Parse(flags.c_str());
  1156. clOptions.Parse(defineFlags.c_str());
  1157. clOptions.AddDefines
  1158. (this->Makefile->GetProperty("COMPILE_DEFINITIONS"));
  1159. clOptions.AddDefines(this->Target->GetProperty("COMPILE_DEFINITIONS"));
  1160. clOptions.AddDefines(this->Makefile->GetProperty(defPropName.c_str()));
  1161. clOptions.AddDefines(this->Target->GetProperty(defPropName.c_str()));
  1162. clOptions.SetVerboseMakefile(
  1163. this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
  1164. // Add a definition for the configuration name.
  1165. std::string configDefine = "CMAKE_INTDIR=\"";
  1166. configDefine += configName;
  1167. configDefine += "\"";
  1168. clOptions.AddDefine(configDefine);
  1169. if(const char* exportMacro = this->Target->GetExportMacro())
  1170. {
  1171. clOptions.AddDefine(exportMacro);
  1172. }
  1173. this->ClOptions[configName] = pOptions.release();
  1174. return true;
  1175. }
  1176. //----------------------------------------------------------------------------
  1177. void cmVisualStudio10TargetGenerator::WriteClOptions(
  1178. std::string const& configName,
  1179. std::vector<std::string> const& includes)
  1180. {
  1181. Options& clOptions = *(this->ClOptions[configName]);
  1182. this->WriteString("<ClCompile>\n", 2);
  1183. clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
  1184. this->OutputIncludes(includes);
  1185. clOptions.OutputFlagMap(*this->BuildFileStream, " ");
  1186. // If not in debug mode, write the DebugInformationFormat field
  1187. // without value so PDBs don't get generated uselessly.
  1188. if(!clOptions.IsDebug())
  1189. {
  1190. this->WriteString("<DebugInformationFormat>"
  1191. "</DebugInformationFormat>\n", 3);
  1192. }
  1193. clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
  1194. "\n", "CXX");
  1195. this->WriteString("<AssemblerListingLocation>", 3);
  1196. *this->BuildFileStream << configName
  1197. << "</AssemblerListingLocation>\n";
  1198. this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3);
  1199. this->WriteString("<ProgramDataBaseFileName>", 3);
  1200. *this->BuildFileStream << this->Target->GetDirectory(configName.c_str())
  1201. << "/"
  1202. << this->Target->GetPDBName(configName.c_str())
  1203. << "</ProgramDataBaseFileName>\n";
  1204. this->WriteString("</ClCompile>\n", 2);
  1205. }
  1206. void cmVisualStudio10TargetGenerator::
  1207. OutputIncludes(std::vector<std::string> const & includes)
  1208. {
  1209. this->WriteString("<AdditionalIncludeDirectories>", 3);
  1210. for(std::vector<std::string>::const_iterator i = includes.begin();
  1211. i != includes.end(); ++i)
  1212. {
  1213. *this->BuildFileStream << *i << ";";
  1214. }
  1215. this->WriteString("%(AdditionalIncludeDirectories)"
  1216. "</AdditionalIncludeDirectories>\n", 0);
  1217. }
  1218. void cmVisualStudio10TargetGenerator::
  1219. WriteRCOptions(std::string const& configName,
  1220. std::vector<std::string> const & includes)
  1221. {
  1222. this->WriteString("<ResourceCompile>\n", 2);
  1223. Options& clOptions = *(this->ClOptions[configName]);
  1224. clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
  1225. "\n", "RC");
  1226. this->OutputIncludes(includes);
  1227. this->WriteString("</ResourceCompile>\n", 2);
  1228. }
  1229. void
  1230. cmVisualStudio10TargetGenerator::WriteLibOptions(std::string const& config)
  1231. {
  1232. if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
  1233. {
  1234. return;
  1235. }
  1236. const char* libflags = this->Target->GetProperty("STATIC_LIBRARY_FLAGS");
  1237. std::string flagsConfigVar = "STATIC_LIBRARY_FLAGS_";
  1238. flagsConfigVar += cmSystemTools::UpperCase(config);
  1239. const char* libflagsConfig =
  1240. this->Target->GetProperty(flagsConfigVar.c_str());
  1241. if(libflags || libflagsConfig)
  1242. {
  1243. this->WriteString("<Lib>\n", 2);
  1244. cmVisualStudioGeneratorOptions
  1245. libOptions(this->LocalGenerator,
  1246. cmVisualStudioGeneratorOptions::Linker,
  1247. cmVS10LibFlagTable, 0, this);
  1248. libOptions.Parse(libflags?libflags:"");
  1249. libOptions.Parse(libflagsConfig?libflagsConfig:"");
  1250. libOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
  1251. libOptions.OutputFlagMap(*this->BuildFileStream, " ");
  1252. this->WriteString("</Lib>\n", 2);
  1253. }
  1254. }
  1255. void cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const&
  1256. config)
  1257. {
  1258. // static libraries and things greater than modules do not need
  1259. // to set this option
  1260. if(this->Target->GetType() == cmTarget::STATIC_LIBRARY
  1261. || this->Target->GetType() > cmTarget::MODULE_LIBRARY)
  1262. {
  1263. return;
  1264. }
  1265. const char* linkLanguage =
  1266. this->Target->GetLinkerLanguage(config.c_str());
  1267. if(!linkLanguage)
  1268. {
  1269. cmSystemTools::Error
  1270. ("CMake can not determine linker language for target:",
  1271. this->Name.c_str());
  1272. return;
  1273. }
  1274. this->WriteString("<Link>\n", 2);
  1275. std::string CONFIG = cmSystemTools::UpperCase(config);
  1276. const char* linkType = "SHARED";
  1277. if(this->Target->GetType() == cmTarget::MODULE_LIBRARY)
  1278. {
  1279. linkType = "MODULE";
  1280. }
  1281. if(this->Target->GetType() == cmTarget::EXECUTABLE)
  1282. {
  1283. linkType = "EXE";
  1284. }
  1285. std::string stackVar = "CMAKE_";
  1286. stackVar += linkLanguage;
  1287. stackVar += "_STACK_SIZE";
  1288. const char* stackVal = this->Makefile->GetDefinition(stackVar.c_str());
  1289. std::string flags;
  1290. if(stackVal)
  1291. {
  1292. flags += " ";
  1293. flags += stackVal;
  1294. }
  1295. // assume incremental linking
  1296. std::string linkFlagVarBase = "CMAKE_";
  1297. linkFlagVarBase += linkType;
  1298. linkFlagVarBase += "_LINKER_FLAGS";
  1299. flags += " ";
  1300. flags += this->
  1301. Target->GetMakefile()->GetRequiredDefinition(linkFlagVarBase.c_str());
  1302. std::string linkFlagVar = linkFlagVarBase + "_" + CONFIG;
  1303. flags += " ";
  1304. flags += this->
  1305. Target->GetMakefile()->GetRequiredDefinition(linkFlagVar.c_str());
  1306. const char* targetLinkFlags = this->Target->GetProperty("LINK_FLAGS");
  1307. if(targetLinkFlags)
  1308. {
  1309. flags += " ";
  1310. flags += targetLinkFlags;
  1311. }
  1312. std::string flagsProp = "LINK_FLAGS_";
  1313. flagsProp += CONFIG;
  1314. if(const char* flagsConfig = this->Target->GetProperty(flagsProp.c_str()))
  1315. {
  1316. flags += " ";
  1317. flags += flagsConfig;
  1318. }
  1319. cmVisualStudioGeneratorOptions
  1320. linkOptions(this->LocalGenerator,
  1321. cmVisualStudioGeneratorOptions::Linker,
  1322. cmVS10LinkFlagTable, 0, this);
  1323. if ( this->Target->GetPropertyAsBool("WIN32_EXECUTABLE") )
  1324. {
  1325. flags += " /SUBSYSTEM:WINDOWS";
  1326. }
  1327. else
  1328. {
  1329. flags += " /SUBSYSTEM:CONSOLE";
  1330. }
  1331. cmSystemTools::ReplaceString(flags, "/INCREMENTAL:YES", "");
  1332. cmSystemTools::ReplaceString(flags, "/INCREMENTAL:NO", "");
  1333. std::string standardLibsVar = "CMAKE_";
  1334. standardLibsVar += linkLanguage;
  1335. standardLibsVar += "_STANDARD_LIBRARIES";
  1336. std::string
  1337. libs = this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
  1338. // Remove trailing spaces from libs
  1339. std::string::size_type pos = libs.size()-1;
  1340. if(libs.size() != 0)
  1341. {
  1342. while(libs[pos] == ' ')
  1343. {
  1344. pos--;
  1345. }
  1346. }
  1347. if(pos != libs.size()-1)
  1348. {
  1349. libs = libs.substr(0, pos+1);
  1350. }
  1351. // Replace spaces in libs with ;
  1352. cmSystemTools::ReplaceString(libs, " ", ";");
  1353. cmComputeLinkInformation* pcli =
  1354. this->Target->GetLinkInformation(config.c_str());
  1355. if(!pcli)
  1356. {
  1357. cmSystemTools::Error
  1358. ("CMake can not compute cmComputeLinkInformation for target:",
  1359. this->Name.c_str());
  1360. return;
  1361. }
  1362. // add the libraries for the target to libs string
  1363. cmComputeLinkInformation& cli = *pcli;
  1364. this->AddLibraries(cli, libs);
  1365. linkOptions.AddFlag("AdditionalDependencies", libs.c_str());
  1366. std::vector<std::string> const& ldirs = cli.GetDirectories();
  1367. const char* sep = "";
  1368. std::string linkDirs;
  1369. for(std::vector<std::string>::const_iterator d = ldirs.begin();
  1370. d != ldirs.end(); ++d)
  1371. {
  1372. // first just full path
  1373. linkDirs += sep;
  1374. linkDirs += *d;
  1375. sep = ";";
  1376. linkDirs += sep;
  1377. // next path with configuration type Debug, Release, etc
  1378. linkDirs += *d;
  1379. linkDirs += "/$(Configuration)";
  1380. linkDirs += sep;
  1381. }
  1382. linkDirs += "%(AdditionalLibraryDirectories)";
  1383. linkOptions.AddFlag("AdditionalLibraryDirectories", linkDirs.c_str());
  1384. linkOptions.AddFlag("AdditionalDependencies", libs.c_str());
  1385. linkOptions.AddFlag("Version", "");
  1386. if(linkOptions.IsDebug() || flags.find("/debug") != flags.npos)
  1387. {
  1388. linkOptions.AddFlag("GenerateDebugInformation", "true");
  1389. }
  1390. else
  1391. {
  1392. linkOptions.AddFlag("GenerateDebugInformation", "false");
  1393. }
  1394. std::string targetName;
  1395. std::string targetNameSO;
  1396. std::string targetNameFull;
  1397. std::string targetNameImport;
  1398. std::string targetNamePDB;
  1399. if(this->Target->GetType() == cmTarget::EXECUTABLE)
  1400. {
  1401. this->Target->GetExecutableNames(targetName, targetNameFull,
  1402. targetNameImport, targetNamePDB,
  1403. config.c_str());
  1404. }
  1405. else
  1406. {
  1407. this->Target->GetLibraryNames(targetName, targetNameSO, targetNameFull,
  1408. targetNameImport, targetNamePDB,
  1409. config.c_str());
  1410. }
  1411. std::string dir = this->Target->GetDirectory(config.c_str());
  1412. dir += "/";
  1413. std::string pdb = dir;
  1414. pdb += targetNamePDB;
  1415. std::string imLib = this->Target->GetDirectory(config.c_str(), true);
  1416. imLib += "/";
  1417. imLib += targetNameImport;
  1418. linkOptions.AddFlag("ImportLibrary", imLib.c_str());
  1419. linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str());
  1420. linkOptions.Parse(flags.c_str());
  1421. if(!this->ModuleDefinitionFile.empty())
  1422. {
  1423. linkOptions.AddFlag("ModuleDefinitionFile",
  1424. this->ModuleDefinitionFile.c_str());
  1425. }
  1426. linkOptions.RemoveFlag("GenerateManifest");
  1427. linkOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
  1428. linkOptions.OutputFlagMap(*this->BuildFileStream, " ");
  1429. this->WriteString("</Link>\n", 2);
  1430. if(!this->GlobalGenerator->NeedLinkLibraryDependencies(*this->Target))
  1431. {
  1432. this->WriteString("<ProjectReference>\n", 2);
  1433. this->WriteString(
  1434. " <LinkLibraryDependencies>false</LinkLibraryDependencies>\n", 2);
  1435. this->WriteString("</ProjectReference>\n", 2);
  1436. }
  1437. }
  1438. void cmVisualStudio10TargetGenerator::AddLibraries(
  1439. cmComputeLinkInformation& cli,
  1440. std::string& libstring)
  1441. {
  1442. typedef cmComputeLinkInformation::ItemVector ItemVector;
  1443. ItemVector libs = cli.GetItems();
  1444. const char* sep = ";";
  1445. for(ItemVector::const_iterator l = libs.begin(); l != libs.end(); ++l)
  1446. {
  1447. if(l->IsPath)
  1448. {
  1449. std::string path = this->LocalGenerator->
  1450. Convert(l->Value.c_str(),
  1451. cmLocalGenerator::START_OUTPUT,
  1452. cmLocalGenerator::UNCHANGED);
  1453. this->ConvertToWindowsSlash(path);
  1454. libstring += sep;
  1455. libstring += path;
  1456. }
  1457. else
  1458. {
  1459. libstring += sep;
  1460. libstring += l->Value;
  1461. }
  1462. }
  1463. }
  1464. void cmVisualStudio10TargetGenerator::
  1465. WriteMidlOptions(std::string const& /*config*/,
  1466. std::vector<std::string> const & includes)
  1467. {
  1468. this->WriteString("<Midl>\n", 2);
  1469. this->OutputIncludes(includes);
  1470. this->WriteString("<OutputDirectory>$(IntDir)</OutputDirectory>\n", 3);
  1471. this->WriteString("<HeaderFileName>%(Filename).h</HeaderFileName>\n", 3);
  1472. this->WriteString(
  1473. "<TypeLibraryName>%(Filename).tlb</TypeLibraryName>\n", 3);
  1474. this->WriteString(
  1475. "<InterfaceIdentifierFileName>"
  1476. "%(Filename)_i.c</InterfaceIdentifierFileName>\n", 3);
  1477. this->WriteString("<ProxyFileName>%(Filename)_p.c</ProxyFileName>\n",3);
  1478. this->WriteString("</Midl>\n", 2);
  1479. }
  1480. void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
  1481. {
  1482. std::vector<std::string> *configs =
  1483. static_cast<cmGlobalVisualStudio7Generator *>
  1484. (this->GlobalGenerator)->GetConfigurations();
  1485. std::vector<std::string> includes;
  1486. this->LocalGenerator->GetIncludeDirectories(includes);
  1487. for(std::vector<std::string>::iterator i = configs->begin();
  1488. i != configs->end(); ++i)
  1489. {
  1490. this->WritePlatformConfigTag("ItemDefinitionGroup", i->c_str(), 1);
  1491. *this->BuildFileStream << "\n";
  1492. // output cl compile flags <ClCompile></ClCompile>
  1493. if(this->Target->GetType() <= cmTarget::MODULE_LIBRARY)
  1494. {
  1495. this->WriteClOptions(*i, includes);
  1496. // output rc compile flags <ResourceCompile></ResourceCompile>
  1497. this->WriteRCOptions(*i, includes);
  1498. }
  1499. // output midl flags <Midl></Midl>
  1500. this->WriteMidlOptions(*i, includes);
  1501. // write events
  1502. this->WriteEvents(*i);
  1503. // output link flags <Link></Link>
  1504. this->WriteLinkOptions(*i);
  1505. // output lib flags <Lib></Lib>
  1506. this->WriteLibOptions(*i);
  1507. this->WriteString("</ItemDefinitionGroup>\n", 1);
  1508. }
  1509. }
  1510. void
  1511. cmVisualStudio10TargetGenerator::WriteEvents(std::string const& configName)
  1512. {
  1513. this->WriteEvent("PreLinkEvent",
  1514. this->Target->GetPreLinkCommands(), configName);
  1515. this->WriteEvent("PreBuildEvent",
  1516. this->Target->GetPreBuildCommands(), configName);
  1517. this->WriteEvent("PostBuildEvent",
  1518. this->Target->GetPostBuildCommands(), configName);
  1519. }
  1520. void cmVisualStudio10TargetGenerator::WriteEvent(
  1521. const char* name,
  1522. std::vector<cmCustomCommand> & commands,
  1523. std::string const& configName)
  1524. {
  1525. if(commands.size() == 0)
  1526. {
  1527. return;
  1528. }
  1529. this->WriteString("<", 2);
  1530. (*this->BuildFileStream ) << name << ">\n";
  1531. cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
  1532. std::string script;
  1533. const char* pre = "";
  1534. std::string comment;
  1535. for(std::vector<cmCustomCommand>::iterator i = commands.begin();
  1536. i != commands.end(); ++i)
  1537. {
  1538. cmCustomCommand& command = *i;
  1539. comment += pre;
  1540. comment += lg->ConstructComment(command);
  1541. script += pre;
  1542. pre = "\n";
  1543. script +=
  1544. cmVS10EscapeXML(lg->ConstructScript(command, configName.c_str()));
  1545. }
  1546. comment = cmVS10EscapeComment(comment);
  1547. this->WriteString("<Message>",3);
  1548. (*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "</Message>\n";
  1549. this->WriteString("<Command>", 3);
  1550. (*this->BuildFileStream ) << script;
  1551. (*this->BuildFileStream ) << "</Command>" << "\n";
  1552. this->WriteString("</", 2);
  1553. (*this->BuildFileStream ) << name << ">\n";
  1554. }
  1555. void cmVisualStudio10TargetGenerator::WriteProjectReferences()
  1556. {
  1557. cmGlobalGenerator::TargetDependSet const& unordered
  1558. = this->GlobalGenerator->GetTargetDirectDepends(*this->Target);
  1559. typedef cmGlobalVisualStudioGenerator::OrderedTargetDependSet
  1560. OrderedTargetDependSet;
  1561. OrderedTargetDependSet depends(unordered);
  1562. this->WriteString("<ItemGroup>\n", 1);
  1563. for( OrderedTargetDependSet::const_iterator i = depends.begin();
  1564. i != depends.end(); ++i)
  1565. {
  1566. cmTarget* dt = *i;
  1567. // skip fortran targets as they can not be processed by MSBuild
  1568. // the only reference will be in the .sln file
  1569. if(static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
  1570. ->TargetIsFortranOnly(*dt))
  1571. {
  1572. continue;
  1573. }
  1574. this->WriteString("<ProjectReference Include=\"", 2);
  1575. cmMakefile* mf = dt->GetMakefile();
  1576. std::string name = dt->GetName();
  1577. std::string path;
  1578. const char* p = dt->GetProperty("EXTERNAL_MSPROJECT");
  1579. if(p)
  1580. {
  1581. path = p;
  1582. }
  1583. else
  1584. {
  1585. path = mf->GetStartOutputDirectory();
  1586. path += "/";
  1587. path += dt->GetName();
  1588. path += ".vcxproj";
  1589. }
  1590. (*this->BuildFileStream) << path << "\">\n";
  1591. this->WriteString("<Project>", 3);
  1592. (*this->BuildFileStream)
  1593. << this->GlobalGenerator->GetGUID(name.c_str())
  1594. << "</Project>\n";
  1595. this->WriteString("</ProjectReference>\n", 2);
  1596. }
  1597. this->WriteString("</ItemGroup>\n", 1);
  1598. }