cmVisualStudio10TargetGenerator.cxx 55 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705
  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. // We may be modifying the source groups temporarily, so make a copy.
  827. std::vector<cmSourceGroup> sourceGroups = this->Makefile->GetSourceGroups();
  828. // get the classes from the source lists then add them to the groups
  829. std::vector<cmSourceFile*>const & classes = this->Target->GetSourceFiles();
  830. for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
  831. i != classes.end(); i++)
  832. {
  833. // Add the file to the list of sources.
  834. std::string source = (*i)->GetFullPath();
  835. if(cmSystemTools::UpperCase((*i)->GetExtension()) == "DEF")
  836. {
  837. this->ModuleDefinitionFile = (*i)->GetFullPath();
  838. }
  839. cmSourceGroup& sourceGroup =
  840. this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
  841. sourceGroup.AssignSource(*i);
  842. }
  843. // Compute which sources need unique object computation.
  844. this->LocalGenerator->ComputeObjectNameRequirements(sourceGroups);
  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);
  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. }