cmMSDotNETGenerator.cxx 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  1. /*=========================================================================
  2. Program: Insight Segmentation & Registration Toolkit
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Insight Consortium. All rights reserved.
  8. See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmMSDotNETGenerator.h"
  14. #include "cmStandardIncludes.h"
  15. #include "cmMakefile.h"
  16. #include "cmCacheManager.h"
  17. #include "windows.h"
  18. #include "cmSystemTools.h"
  19. #include "cmRegularExpression.h"
  20. #include "cmSourceGroup.h"
  21. cmMSDotNETGenerator::cmMSDotNETGenerator()
  22. {
  23. m_Configurations.push_back("Debug");
  24. m_Configurations.push_back("Release");
  25. // m_Configurations.push_back("MinSizeRel");
  26. // m_Configurations.push_back("RelWithDebInfo");
  27. // default to building a sln project file
  28. BuildProjOn();
  29. }
  30. void cmMSDotNETGenerator::GenerateMakefile()
  31. {
  32. if(m_BuildSLN)
  33. {
  34. this->OutputSLNFile();
  35. }
  36. else
  37. {
  38. this->OutputVCProjFile();
  39. }
  40. }
  41. cmMSDotNETGenerator::~cmMSDotNETGenerator()
  42. {
  43. }
  44. void cmMSDotNETGenerator::SetLocal(bool local)
  45. {
  46. m_BuildSLN = !local;
  47. }
  48. void cmMSDotNETGenerator::ComputeSystemInfo()
  49. {
  50. // now load the settings
  51. if(!m_Makefile->GetDefinition("CMAKE_ROOT"))
  52. {
  53. cmSystemTools::Error(
  54. "CMAKE_ROOT has not been defined, bad GUI or driver program");
  55. return;
  56. }
  57. std::string fpath =
  58. m_Makefile->GetDefinition("CMAKE_ROOT");
  59. fpath += "/Templates/CMakeDotNetSystemConfig.cmake";
  60. m_Makefile->ReadListFile(NULL,fpath.c_str());
  61. }
  62. // output the SLN file
  63. void cmMSDotNETGenerator::OutputSLNFile()
  64. {
  65. // if this is an out of source build, create the output directory
  66. if(strcmp(m_Makefile->GetStartOutputDirectory(),
  67. m_Makefile->GetHomeDirectory()) != 0)
  68. {
  69. if(!cmSystemTools::MakeDirectory(m_Makefile->GetStartOutputDirectory()))
  70. {
  71. cmSystemTools::Error("Error creating output directory for SLN file",
  72. m_Makefile->GetStartOutputDirectory());
  73. }
  74. }
  75. // create the dsw file name
  76. std::string fname;
  77. fname = m_Makefile->GetStartOutputDirectory();
  78. fname += "/";
  79. if(strlen(m_Makefile->GetProjectName()) == 0)
  80. {
  81. m_Makefile->SetProjectName("Project");
  82. }
  83. fname += m_Makefile->GetProjectName();
  84. fname += ".sln";
  85. std::ofstream fout(fname.c_str());
  86. if(!fout)
  87. {
  88. cmSystemTools::Error("Error can not open SLN file for write: "
  89. ,fname.c_str());
  90. return;
  91. }
  92. this->WriteSLNFile(fout);
  93. }
  94. // Write a SLN file to the stream
  95. void cmMSDotNETGenerator::WriteSLNFile(std::ostream& fout)
  96. {
  97. // Write out the header for a SLN file
  98. this->WriteSLNHeader(fout);
  99. // Create a list of cmMakefile created from all the
  100. // CMakeLists.txt files that are in sub directories of
  101. // this one.
  102. std::vector<cmMakefile*> allListFiles;
  103. // add this makefile to the list
  104. allListFiles.push_back(m_Makefile);
  105. // add a special target that depends on ALL projects for easy build
  106. // of Debug only
  107. m_Makefile->AddUtilityCommand("ALL_BUILD", "echo", "\"Build all projects\"",
  108. false);
  109. std::string ctest = m_Makefile->GetDefinition("CMAKE_COMMAND");
  110. ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
  111. ctest += "/";
  112. ctest += "ctest";
  113. ctest += cmSystemTools::GetExecutableExtension();
  114. if(!cmSystemTools::FileExists(ctest.c_str()))
  115. {
  116. ctest = m_Makefile->GetDefinition("CMAKE_COMMAND");
  117. ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
  118. ctest += "/Debug/";
  119. ctest += "ctest";
  120. ctest += cmSystemTools::GetExecutableExtension();
  121. }
  122. if(!cmSystemTools::FileExists(ctest.c_str()))
  123. {
  124. ctest = m_Makefile->GetDefinition("CMAKE_COMMAND");
  125. ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
  126. ctest += "/Release/";
  127. ctest += "ctest";
  128. ctest += cmSystemTools::GetExecutableExtension();
  129. }
  130. m_Makefile->AddUtilityCommand("RUN_TESTS", ctest.c_str(), "-D $(IntDir)",
  131. false);
  132. m_Makefile->FindSubDirectoryCMakeListsFiles(allListFiles);
  133. // For each cmMakefile, create a VCProj for it, and
  134. // add it to this SLN file
  135. std::vector<cmMakefile*>::iterator k;
  136. for(k = allListFiles.begin();
  137. k != allListFiles.end(); ++k)
  138. {
  139. cmMakefile* mf = *k;
  140. cmMSDotNETGenerator* pg = 0;
  141. // if not this makefile, then create a new generator
  142. if(m_Makefile != mf)
  143. {
  144. // Create an MS generator with SLN off, so it only creates dsp files
  145. pg = new cmMSDotNETGenerator;
  146. }
  147. else
  148. {
  149. pg = static_cast<cmMSDotNETGenerator*>(m_Makefile->GetMakefileGenerator());
  150. }
  151. // make sure the generator is building dsp files
  152. pg->BuildSLNOff();
  153. mf->SetMakefileGenerator(pg);
  154. mf->GenerateMakefile();
  155. // Get the source directory from the makefile
  156. std::string dir = mf->GetStartDirectory();
  157. // Get the home directory with the trailing slash
  158. std::string homedir = m_Makefile->GetHomeDirectory();
  159. homedir += "/";
  160. // remove the home directory and / from the source directory
  161. // this gives a relative path
  162. cmSystemTools::ReplaceString(dir, homedir.c_str(), "");
  163. // Get the list of create dsp files names from the cmVCProjWriter, more
  164. // than one dsp could have been created per input CMakeLists.txt file
  165. // for each target
  166. std::vector<std::string> dspnames =
  167. pg->GetCreatedProjectNames();
  168. cmTargets &tgts = pg->GetMakefile()->GetTargets();
  169. cmTargets::iterator l = tgts.begin();
  170. for(std::vector<std::string>::iterator si = dspnames.begin();
  171. l != tgts.end(); ++l)
  172. {
  173. // special handling for the current makefile
  174. if(mf == m_Makefile)
  175. {
  176. dir = "."; // no subdirectory for project generated
  177. // if this is the special ALL_BUILD utility, then
  178. // make it depend on every other non UTILITY project.
  179. // This is done by adding the names to the GetUtilities
  180. // vector on the makefile
  181. if(l->first == "ALL_BUILD")
  182. {
  183. for(std::vector<cmMakefile*>::iterator a = allListFiles.begin();
  184. a != allListFiles.end(); ++a)
  185. {
  186. const cmTargets &atgts = (*a)->GetTargets();
  187. for(cmTargets::const_iterator al = atgts.begin();
  188. al != atgts.end(); ++al)
  189. {
  190. if (al->second.IsInAll())
  191. {
  192. if (al->second.GetType() == cmTarget::UTILITY)
  193. {
  194. l->second.AddUtility(al->first.c_str());
  195. }
  196. else
  197. {
  198. l->second.GetLinkLibraries().push_back(
  199. cmTarget::LinkLibraries::value_type(al->first,
  200. cmTarget::GENERAL));
  201. }
  202. }
  203. }
  204. }
  205. }
  206. }
  207. // Write the project into the SLN file
  208. if (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
  209. {
  210. cmCustomCommand cc = l->second.GetCustomCommands()[0];
  211. // dodgy use of the cmCustomCommand's members to store the
  212. // arguments from the INCLUDE_EXTERNAL_MSPROJECT command
  213. std::vector<std::string> stuff = cc.GetDepends();
  214. std::vector<std::string> depends = cc.GetOutputs();
  215. this->WriteExternalProject(fout, stuff[0].c_str(), stuff[1].c_str(), depends);
  216. ++si;
  217. }
  218. else if ((l->second.GetType() != cmTarget::INSTALL_FILES)
  219. && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
  220. {
  221. this->WriteProject(fout, si->c_str(), dir.c_str(),
  222. pg,l->second);
  223. ++si;
  224. }
  225. }
  226. }
  227. fout << "Global\n"
  228. << "\tGlobalSection(SolutionConfiguration) = preSolution\n";
  229. int c = 0;
  230. for(std::vector<std::string>::iterator i = m_Configurations.begin();
  231. i != m_Configurations.end(); ++i)
  232. {
  233. fout << "\t\tConfigName." << c << " = " << *i << "\n";
  234. c++;
  235. }
  236. fout << "\tEndGlobalSection\n"
  237. << "\tGlobalSection(ProjectDependencies) = postSolution\n";
  238. // loop over again and compute the depends
  239. for(k = allListFiles.begin(); k != allListFiles.end(); ++k)
  240. {
  241. cmMakefile* mf = *k;
  242. cmMSDotNETGenerator* pg =
  243. static_cast<cmMSDotNETGenerator*>(mf->GetMakefileGenerator());
  244. // Get the list of create dsp files names from the cmVCProjWriter, more
  245. // than one dsp could have been created per input CMakeLists.txt file
  246. // for each target
  247. std::vector<std::string> dspnames =
  248. pg->GetCreatedProjectNames();
  249. cmTargets &tgts = pg->GetMakefile()->GetTargets();
  250. cmTargets::iterator l = tgts.begin();
  251. std::string dir = mf->GetStartDirectory();
  252. for(std::vector<std::string>::iterator si = dspnames.begin();
  253. l != tgts.end(); ++l)
  254. {
  255. if ((l->second.GetType() != cmTarget::INSTALL_FILES)
  256. && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
  257. {
  258. this->WriteProjectDepends(fout, si->c_str(), dir.c_str(),
  259. pg,l->second);
  260. ++si;
  261. }
  262. }
  263. }
  264. fout << "\tEndGlobalSection\n";
  265. fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n";
  266. // loop over again and compute the depends
  267. for(k = allListFiles.begin(); k != allListFiles.end(); ++k)
  268. {
  269. cmMakefile* mf = *k;
  270. cmMSDotNETGenerator* pg =
  271. static_cast<cmMSDotNETGenerator*>(mf->GetMakefileGenerator());
  272. // Get the list of create dsp files names from the cmVCProjWriter, more
  273. // than one dsp could have been created per input CMakeLists.txt file
  274. // for each target
  275. std::vector<std::string> dspnames =
  276. pg->GetCreatedProjectNames();
  277. cmTargets &tgts = pg->GetMakefile()->GetTargets();
  278. cmTargets::iterator l = tgts.begin();
  279. std::string dir = mf->GetStartDirectory();
  280. for(std::vector<std::string>::iterator si = dspnames.begin();
  281. l != tgts.end(); ++l)
  282. {
  283. if ((l->second.GetType() != cmTarget::INSTALL_FILES)
  284. && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
  285. {
  286. this->WriteProjectConfigurations(fout, si->c_str());
  287. ++si;
  288. }
  289. }
  290. // delete the cmMakefile which also deletes the cmMSProjectGenerator
  291. if(mf != m_Makefile)
  292. {
  293. delete mf;
  294. }
  295. }
  296. fout << "\tEndGlobalSection\n";
  297. // Write the footer for the SLN file
  298. this->WriteSLNFooter(fout);
  299. }
  300. // Write a dsp file into the SLN file,
  301. // Note, that dependencies from executables to
  302. // the libraries it uses are also done here
  303. void cmMSDotNETGenerator::WriteProject(std::ostream& fout,
  304. const char* dspname,
  305. const char* dir,
  306. cmMSDotNETGenerator*,
  307. const cmTarget& target
  308. )
  309. {
  310. std::string d = cmSystemTools::ConvertToOutputPath(dir);
  311. fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\" = \""
  312. << dspname << "\", \""
  313. << d << "\\" << dspname << ".vcproj\", \"{"
  314. << this->CreateGUID(dspname) << "}\"\nEndProject\n";
  315. }
  316. // Write a dsp file into the SLN file,
  317. // Note, that dependencies from executables to
  318. // the libraries it uses are also done here
  319. void cmMSDotNETGenerator::WriteProjectDepends(std::ostream& fout,
  320. const char* dspname,
  321. const char* dir,
  322. cmMSDotNETGenerator*,
  323. const cmTarget& target
  324. )
  325. {
  326. int depcount = 0;
  327. // insert Begin Project Dependency Project_Dep_Name project stuff here
  328. if (target.GetType() != cmTarget::STATIC_LIBRARY)
  329. {
  330. cmTarget::LinkLibraries::const_iterator j, jend;
  331. j = target.GetLinkLibraries().begin();
  332. jend = target.GetLinkLibraries().end();
  333. for(;j!= jend; ++j)
  334. {
  335. if(j->first != dspname)
  336. {
  337. // is the library part of this SLN ? If so add dependency
  338. const char* cacheValue
  339. = m_Makefile->GetDefinition(j->first.c_str());
  340. if(cacheValue)
  341. {
  342. fout << "\t\t{" << this->CreateGUID(dspname) << "}." << depcount << " = {"
  343. << this->CreateGUID(j->first.c_str()) << "}\n";
  344. depcount++;
  345. }
  346. }
  347. }
  348. }
  349. std::set<std::string>::const_iterator i, end;
  350. // write utility dependencies.
  351. i = target.GetUtilities().begin();
  352. end = target.GetUtilities().end();
  353. for(;i!= end; ++i)
  354. {
  355. if(*i != dspname)
  356. {
  357. fout << "\t\t{" << this->CreateGUID(dspname) << "}." << depcount << " = {"
  358. << this->CreateGUID(i->c_str()) << "}\n";
  359. depcount++;
  360. }
  361. }
  362. }
  363. // Write a dsp file into the SLN file,
  364. // Note, that dependencies from executables to
  365. // the libraries it uses are also done here
  366. void cmMSDotNETGenerator::WriteProjectConfigurations(std::ostream& fout, const char* name)
  367. {
  368. std::string guid = this->CreateGUID(name);
  369. for(std::vector<std::string>::iterator i = m_Configurations.begin();
  370. i != m_Configurations.end(); ++i)
  371. {
  372. fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << *i << "|Win32\n"
  373. << "\t\t{" << guid << "}." << *i << ".Build.0 = " << *i << "|Win32\n";
  374. }
  375. }
  376. // Write a dsp file into the SLN file,
  377. // Note, that dependencies from executables to
  378. // the libraries it uses are also done here
  379. void cmMSDotNETGenerator::WriteExternalProject(std::ostream& fout,
  380. const char* name,
  381. const char* location,
  382. const std::vector<std::string>& dependencies)
  383. {
  384. cmSystemTools::Error("WriteExternalProject not implemented");
  385. // fout << "#########################################################"
  386. // "######################\n\n";
  387. // fout << "Project: \"" << name << "\"="
  388. // << location << " - Package Owner=<4>\n\n";
  389. // fout << "Package=<5>\n{{{\n}}}\n\n";
  390. // fout << "Package=<4>\n";
  391. // fout << "{{{\n";
  392. // std::vector<std::string>::const_iterator i, end;
  393. // // write dependencies.
  394. // i = dependencies.begin();
  395. // end = dependencies.end();
  396. // for(;i!= end; ++i)
  397. // {
  398. // fout << "Begin Project Dependency\n";
  399. // fout << "Project_Dep_Name " << *i << "\n";
  400. // fout << "End Project Dependency\n";
  401. // }
  402. // fout << "}}}\n\n";
  403. }
  404. // Standard end of dsw file
  405. void cmMSDotNETGenerator::WriteSLNFooter(std::ostream& fout)
  406. {
  407. fout << "\tGlobalSection(ExtensibilityGlobals) = postSolution\n"
  408. << "\tEndGlobalSection\n"
  409. << "\tGlobalSection(ExtensibilityAddIns) = postSolution\n"
  410. << "\tEndGlobalSection\n"
  411. << "EndGlobal\n";
  412. }
  413. // ouput standard header for dsw file
  414. void cmMSDotNETGenerator::WriteSLNHeader(std::ostream& fout)
  415. {
  416. fout << "Microsoft Visual Studio Solution File, Format Version 7.00\n";
  417. }
  418. std::string cmMSDotNETGenerator::CreateGUID(const char* name)
  419. {
  420. std::map<cmStdString, cmStdString>::iterator i = m_GUIDMap.find(name);
  421. if(i != m_GUIDMap.end())
  422. {
  423. return i->second;
  424. }
  425. std::string ret;
  426. UUID uid;
  427. unsigned char *uidstr;
  428. UuidCreate(&uid);
  429. UuidToString(&uid,&uidstr);
  430. ret = reinterpret_cast<char*>(uidstr);
  431. RpcStringFree(&uidstr);
  432. ret = cmSystemTools::UpperCase(ret);
  433. m_GUIDMap[name] = ret;
  434. return ret;
  435. }
  436. // TODO
  437. // for CommandLine= need to repleace quotes with &quot
  438. // write out configurations
  439. void cmMSDotNETGenerator::OutputVCProjFile()
  440. {
  441. // If not an in source build, then create the output directory
  442. if(strcmp(m_Makefile->GetStartOutputDirectory(),
  443. m_Makefile->GetHomeDirectory()) != 0)
  444. {
  445. if(!cmSystemTools::MakeDirectory(m_Makefile->GetStartOutputDirectory()))
  446. {
  447. cmSystemTools::Error("Error creating directory ",
  448. m_Makefile->GetStartOutputDirectory());
  449. }
  450. }
  451. m_LibraryOutputPath = "";
  452. if (m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH"))
  453. {
  454. m_LibraryOutputPath = m_Makefile->GetDefinition("LIBRARY_OUTPUT_PATH");
  455. }
  456. if(m_LibraryOutputPath.size())
  457. {
  458. // make sure there is a trailing slash
  459. if(m_LibraryOutputPath[m_LibraryOutputPath.size()-1] != '/')
  460. {
  461. m_LibraryOutputPath += "/";
  462. }
  463. m_LibraryOutputPath =
  464. cmSystemTools::ConvertToOutputPath(m_LibraryOutputPath.c_str());
  465. }
  466. m_ExecutableOutputPath = "";
  467. if (m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH"))
  468. {
  469. m_ExecutableOutputPath = m_Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
  470. }
  471. if(m_ExecutableOutputPath.size())
  472. {
  473. // make sure there is a trailing slash
  474. if(m_ExecutableOutputPath[m_ExecutableOutputPath.size()-1] != '/')
  475. {
  476. m_ExecutableOutputPath += "/";
  477. }
  478. }
  479. m_ExecutableOutputPath =
  480. cmSystemTools::ConvertToOutputPath(m_ExecutableOutputPath.c_str());
  481. std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
  482. std::vector<std::string>::iterator i;
  483. for(i = includes.begin(); i != includes.end(); ++i)
  484. {
  485. std::string tmp = cmSystemTools::ConvertToOutputPath(i->c_str());
  486. m_IncludeOptions += ",";
  487. // quote if not already quoted
  488. if (tmp[0] != '"')
  489. {
  490. m_IncludeOptions += tmp;
  491. }
  492. else
  493. {
  494. m_IncludeOptions += tmp;
  495. }
  496. }
  497. // Create the VCProj or set of VCProj's for libraries and executables
  498. // clear project names
  499. m_CreatedProjectNames.clear();
  500. // build any targets
  501. cmTargets &tgts = m_Makefile->GetTargets();
  502. for(cmTargets::iterator l = tgts.begin();
  503. l != tgts.end(); l++)
  504. {
  505. // INCLUDE_EXTERNAL_MSPROJECT command only affects the workspace
  506. // so don't build a projectfile for it
  507. if ((l->second.GetType() != cmTarget::INSTALL_FILES)
  508. && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS)
  509. && (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) != 0))
  510. {
  511. this->CreateSingleVCProj(l->first.c_str(),l->second);
  512. }
  513. }
  514. }
  515. void cmMSDotNETGenerator::CreateSingleVCProj(const char *lname, cmTarget &target)
  516. {
  517. // add to the list of projects
  518. std::string pname = lname;
  519. m_CreatedProjectNames.push_back(pname);
  520. // create the dsp.cmake file
  521. std::string fname;
  522. fname = m_Makefile->GetStartOutputDirectory();
  523. fname += "/";
  524. fname += lname;
  525. fname += ".vcproj";
  526. // save the name of the real dsp file
  527. std::string realVCProj = fname;
  528. fname += ".cmake";
  529. std::ofstream fout(fname.c_str());
  530. if(!fout)
  531. {
  532. cmSystemTools::Error("Error Writing ", fname.c_str());
  533. }
  534. this->WriteVCProjFile(fout,lname,target);
  535. fout.close();
  536. // if the dsp file has changed, then write it.
  537. cmSystemTools::CopyFileIfDifferent(fname.c_str(), realVCProj.c_str());
  538. }
  539. void cmMSDotNETGenerator::AddVCProjBuildRule(cmSourceGroup& sourceGroup)
  540. {
  541. std::string dspname = *(m_CreatedProjectNames.end()-1);
  542. if(dspname == "ALL_BUILD")
  543. {
  544. return;
  545. }
  546. dspname += ".vcproj.cmake";
  547. std::string makefileIn = m_Makefile->GetStartDirectory();
  548. makefileIn += "/";
  549. makefileIn += "CMakeLists.txt";
  550. makefileIn = cmSystemTools::ConvertToOutputPath(makefileIn.c_str());
  551. std::string dsprule = "${CMAKE_COMMAND}";
  552. m_Makefile->ExpandVariablesInString(dsprule);
  553. dsprule = cmSystemTools::ConvertToOutputPath(dsprule.c_str());
  554. std::string args = makefileIn;
  555. args += " -H\"";
  556. args +=
  557. cmSystemTools::ConvertToOutputPath(m_Makefile->GetHomeDirectory());
  558. args += "\" -S\"";
  559. args +=
  560. cmSystemTools::ConvertToOutputPath(m_Makefile->GetStartDirectory());
  561. args += "\" -O\"";
  562. args +=
  563. cmSystemTools::ConvertToOutputPath(m_Makefile->GetStartOutputDirectory());
  564. args += "\" -B\"";
  565. args +=
  566. cmSystemTools::ConvertToOutputPath(m_Makefile->GetHomeOutputDirectory());
  567. args += "\"";
  568. m_Makefile->ExpandVariablesInString(args);
  569. std::string configFile =
  570. m_Makefile->GetDefinition("CMAKE_ROOT");
  571. configFile += "/Templates/CMakeWindowsSystemConfig.cmake";
  572. std::vector<std::string> listFiles = m_Makefile->GetListFiles();
  573. bool found = false;
  574. for(std::vector<std::string>::iterator i = listFiles.begin();
  575. i != listFiles.end(); ++i)
  576. {
  577. if(*i == configFile)
  578. {
  579. found = true;
  580. }
  581. }
  582. if(!found)
  583. {
  584. listFiles.push_back(configFile);
  585. }
  586. std::vector<std::string> outputs;
  587. outputs.push_back(dspname);
  588. cmCustomCommand cc(makefileIn.c_str(), dsprule.c_str(),
  589. args.c_str(),
  590. listFiles,
  591. outputs);
  592. sourceGroup.AddCustomCommand(cc);
  593. }
  594. void cmMSDotNETGenerator::WriteConfigurations(std::ostream& fout,
  595. const char *libName,
  596. const cmTarget &target)
  597. {
  598. fout << "\t<Configurations>\n";
  599. for( std::vector<std::string>::iterator i = m_Configurations.begin();
  600. i != m_Configurations.end(); ++i)
  601. {
  602. this->WriteConfiguration(fout, i->c_str(), libName, target);
  603. }
  604. fout << "\t</Configurations>\n";
  605. }
  606. void cmMSDotNETGenerator::WriteConfiguration(std::ostream& fout,
  607. const char* configName,
  608. const char *libName,
  609. const cmTarget &target)
  610. {
  611. const char* mfcFlag = m_Makefile->GetDefinition("CMAKE_MFC_FLAG");
  612. if(!mfcFlag)
  613. {
  614. mfcFlag = "0";
  615. }
  616. fout << "\t\t<Configuration\n"
  617. << "\t\t\tName=\"" << configName << "|Win32\"\n"
  618. << "\t\t\tOutputDirectory=\"";
  619. // This is an internal type to Visual Studio, it seems that:
  620. // 4 == static library
  621. // 2 == dll
  622. // 1 == executable
  623. // 10 == utility
  624. const char* configType = "10";
  625. switch(target.GetType())
  626. {
  627. case cmTarget::STATIC_LIBRARY:
  628. configType = "4";
  629. fout << m_LibraryOutputPath << configName << "\"\n";
  630. break;
  631. case cmTarget::SHARED_LIBRARY:
  632. case cmTarget::MODULE_LIBRARY:
  633. fout << m_LibraryOutputPath << configName << "\"\n";
  634. configType = "2";
  635. break;
  636. case cmTarget::EXECUTABLE:
  637. case cmTarget::WIN32_EXECUTABLE:
  638. fout << m_ExecutableOutputPath << configName << "\"\n";
  639. configType = "1";
  640. break;
  641. case cmTarget::UTILITY:
  642. configType = "10";
  643. default:
  644. fout << configName << "\"\n";
  645. break;
  646. }
  647. fout << "\t\t\tIntermediateDirectory=\".\\" << configName << "\"\n"
  648. << "\t\t\tConfigurationType=\"" << configType << "\"\n"
  649. << "\t\t\tUseOfMFC=\"" << mfcFlag << "\"\n"
  650. << "\t\t\tATLMinimizesCRunTimeLibraryUsage=\"FALSE\"\n"
  651. << "\t\t\tCharacterSet=\"2\">\n";
  652. fout << "\t\t\t<Tool\n"
  653. << "\t\t\t\tName=\"VCCLCompilerTool\"\n"
  654. << "\t\t\t\tAdditionalOptions=\"" <<
  655. m_Makefile->GetDefinition("CMAKE_CXX_FLAGS") << "\"\n";
  656. fout << "\t\t\t\tAdditionalIncludeDirectories=\"";
  657. std::vector<std::string>& includes = m_Makefile->GetIncludeDirectories();
  658. std::vector<std::string>::iterator i = includes.begin();
  659. if(i != includes.end())
  660. {
  661. fout << "&quot;" << *i << "&quot;";
  662. }
  663. for(;i != includes.end(); ++i)
  664. {
  665. fout << ";&quot;" << *i << "&quot;";
  666. }
  667. fout << "\"\n";
  668. if(strcmp(configName, "Debug") == 0)
  669. {
  670. fout << "\t\t\t\tOptimization=\"0\"\n"
  671. << "\t\t\t\tRuntimeLibrary=\"3\"\n"
  672. << "\t\t\t\tPreprocessorDefinitions=\"WIN32,_DEBUG,_WINDOWS";
  673. }
  674. else if(strcmp(configName, "Release") == 0)
  675. {
  676. fout << "\t\t\t\tOptimization=\"2\"\n"
  677. << "\t\t\t\tRuntimeLibrary=\"0\"\n"
  678. << "\t\t\t\tInlineFunctionExpansion=\"1\"\n"
  679. << "\t\t\t\tPreprocessorDefinitions=\"WIN32,NDEBUG,_WINDOWS";
  680. }
  681. else if(strcmp(configName, "MinSizeRel") == 0)
  682. {
  683. fout << "\t\t\t\tOptimization=\"1\"\n"
  684. << "\t\t\t\tRuntimeLibrary=\"0\"\n"
  685. << "\t\t\t\tInlineFunctionExpansion=\"1\"\n"
  686. << "\t\t\t\tPreprocessorDefinitions=\"WIN32,NDEBUG,_WINDOWS";
  687. }
  688. else if(strcmp(configName, "RelWithDebInfo") == 0)
  689. {
  690. fout << "\t\t\t\tOptimization=\"2\"\n"
  691. << "\t\t\t\tInlineFunctionExpansion=\"1\"\n"
  692. << "\t\t\t\tPreprocessorDefinitions=\"WIN32,NDEBUG,_WINDOWS";
  693. }
  694. this->OutputDefineFlags(fout);
  695. fout << "\"\n";
  696. fout << "\t\t\t\tRuntimeTypeInfo=\"TRUE\"\n";
  697. fout << "\t\t\t\tAssemblerListingLocation=\"" << configName << "\"\n";
  698. fout << "\t\t\t\tObjectFile=\"" << configName << "\\\"\n";
  699. fout << "\t\t\t\tProgramDataBaseFileName=\"" << configName << "\"\n";
  700. fout << "\t\t\t\tWarningLevel=\"3\"\n";
  701. fout << "\t\t\t\tDetect64BitPortabilityProblems=\"TRUE\"\n"
  702. << "\t\t\t\tDebugInformationFormat=\"3\"";
  703. fout << "/>\n"; // end of <Tool Name=VCCLCompilerTool
  704. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCCustomBuildTool\"/>\n";
  705. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCMIDLTool\"/>\n";
  706. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPostBuildEventTool\"";
  707. this->OutputTargetRules(fout, target, libName);
  708. fout << "/>\n";
  709. fout << "\t\t\t<Tool\n\t\t\t\tName=\"VCPreBuildEventTool\"/>\n";
  710. this->OutputBuildTool(fout, configName, libName, target);
  711. fout << "\t\t</Configuration>\n";
  712. }
  713. void cmMSDotNETGenerator::OutputBuildTool(std::ostream& fout,
  714. const char* configName,
  715. const char *libName,
  716. const cmTarget &target)
  717. {
  718. switch(target.GetType())
  719. {
  720. case cmTarget::STATIC_LIBRARY:
  721. fout << "\t\t\t<Tool\n"
  722. << "\t\t\t\tName=\"VCLibrarianTool\"\n"
  723. << "\t\t\t\t\tOutputFile=\"" << m_LibraryOutputPath << configName
  724. << "/" << libName << ".lib\"/>\n";
  725. break;
  726. case cmTarget::SHARED_LIBRARY:
  727. case cmTarget::MODULE_LIBRARY:
  728. break;
  729. case cmTarget::EXECUTABLE:
  730. fout << "\t\t\t<Tool\n"
  731. << "\t\t\t\tName=\"VCLinkerTool\"\n"
  732. << "\t\t\t\tAdditionalOptions=\"/MACHINE:I386\"\n"
  733. << "\t\t\t\tAdditionalDependencies=\" odbc32.lib odbccp32.lib ";
  734. this->OutputLibraries(fout, configName, libName, target);
  735. fout << "\"\n";
  736. fout << "\t\t\t\tOutputFile=\"" << m_ExecutableOutputPath <<
  737. configName << "/" << libName << ".exe\"\n";
  738. fout << "\t\t\t\tLinkIncremental=\"1\"\n";
  739. fout << "\t\t\t\tSuppressStartupBanner=\"TRUE\"\n";
  740. fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
  741. this->OutputLibraryDirectories(fout, configName, libName, target);
  742. fout << "\"\n";
  743. fout << "\t\t\t\tProgramDatabaseFile=\"" << m_LibraryOutputPath << libName << ".pdb\"\n";
  744. fout << "\t\t\t\tSubSystem=\"1\"\n";
  745. fout << "\t\t\t\tStackReserveSize=\"10000000\"/>\n";
  746. break;
  747. case cmTarget::WIN32_EXECUTABLE:
  748. fout << "\t\t\t<Tool\n"
  749. << "\t\t\t\tName=\"VCLinkerTool\"\n"
  750. << "\t\t\t\tAdditionalOptions=\"/MACHINE:I386\"\n"
  751. << "\t\t\t\tAdditionalDependencies=\" odbc32.lib odbccp32.lib ";
  752. this->OutputLibraries(fout, configName, libName, target);
  753. fout << "\"\n";
  754. fout << "\t\t\t\tOutputFile=\"" << m_ExecutableOutputPath <<
  755. configName << "/" << libName << ".exe\"\n";
  756. fout << "\t\t\t\tLinkIncremental=\"1\"\n";
  757. fout << "\t\t\t\tSuppressStartupBanner=\"TRUE\"\n";
  758. fout << "\t\t\t\tAdditionalLibraryDirectories=\"";
  759. this->OutputLibraryDirectories(fout, configName, libName, target);
  760. fout << "\"\n";
  761. fout << "\t\t\t\tProgramDatabaseFile=\"" << m_LibraryOutputPath << libName << ".pdb\"\n";
  762. fout << "\t\t\t\tSubSystem=\"2\"\n";
  763. fout << "\t\t\t\tStackReserveSize=\"10000000\"/>\n";
  764. break;
  765. case cmTarget::UTILITY:
  766. break;
  767. }
  768. }
  769. void cmMSDotNETGenerator::OutputLibraryDirectories(std::ostream& fout,
  770. const char* configName,
  771. const char* libName,
  772. const cmTarget &target)
  773. {
  774. bool hasone = false;
  775. if(m_LibraryOutputPath.size())
  776. {
  777. hasone = true;
  778. fout << m_LibraryOutputPath << "$(INTDIR)," << m_LibraryOutputPath;
  779. }
  780. if(m_ExecutableOutputPath.size())
  781. {
  782. hasone = true;
  783. fout << m_ExecutableOutputPath << "$(INTDIR)," << m_ExecutableOutputPath;
  784. }
  785. std::set<std::string> pathEmitted;
  786. std::vector<std::string>::iterator i;
  787. std::vector<std::string>& libdirs = m_Makefile->GetLinkDirectories();
  788. for(i = libdirs.begin(); i != libdirs.end(); ++i)
  789. {
  790. std::string lpath = cmSystemTools::ConvertToOutputPath(i->c_str());
  791. if(lpath[lpath.size()-1] != '/')
  792. {
  793. lpath += "/";
  794. }
  795. if(pathEmitted.insert(lpath).second)
  796. {
  797. if(hasone)
  798. {
  799. fout << ",";
  800. }
  801. fout << lpath << "\\$(INTDIR)," << lpath;
  802. hasone = true;
  803. }
  804. }
  805. }
  806. void cmMSDotNETGenerator::OutputLibraries(std::ostream& fout,
  807. const char* configName,
  808. const char* libName,
  809. const cmTarget &target)
  810. {
  811. const cmTarget::LinkLibraries& libs = target.GetLinkLibraries();
  812. cmTarget::LinkLibraries::const_iterator j;
  813. for(j = libs.begin(); j != libs.end(); ++j)
  814. {
  815. std::string lib = j->first;
  816. if(j->first.find(".lib") == std::string::npos)
  817. {
  818. lib += ".lib";
  819. }
  820. lib = cmSystemTools::ConvertToOutputPath(lib.c_str());
  821. if (j->second == cmTarget::GENERAL
  822. || (j->second == cmTarget::DEBUG && strcmp(configName, "DEBUG") == 0)
  823. || (j->second == cmTarget::OPTIMIZED && strcmp(configName, "DEBUG") != 0))
  824. {
  825. fout << lib << " ";
  826. }
  827. }
  828. }
  829. void cmMSDotNETGenerator::OutputDefineFlags(std::ostream& fout)
  830. {
  831. std::string defs = m_Makefile->GetDefineFlags();
  832. std::string::size_type pos = defs.find("-D");
  833. bool done = pos == std::string::npos;
  834. if(!done)
  835. {
  836. fout << ",";
  837. }
  838. while(!done)
  839. {
  840. std::string::size_type nextpos = defs.find("-D", pos+2);
  841. std::string define;
  842. if(nextpos != std::string::npos)
  843. {
  844. define = defs.substr(pos+2, nextpos - pos -3);
  845. }
  846. else
  847. {
  848. define = defs.substr(pos+2);
  849. done = true;
  850. }
  851. fout << define << ",";
  852. if(!done)
  853. {
  854. pos = defs.find("-D", nextpos);
  855. }
  856. }
  857. }
  858. void cmMSDotNETGenerator::WriteVCProjFile(std::ostream& fout,
  859. const char *libName,
  860. cmTarget &target)
  861. {
  862. // We may be modifying the source groups temporarily, so make a copy.
  863. std::vector<cmSourceGroup> sourceGroups = m_Makefile->GetSourceGroups();
  864. // get the classes from the source lists then add them to the groups
  865. std::vector<cmSourceFile> classes = target.GetSourceFiles();
  866. for(std::vector<cmSourceFile>::iterator i = classes.begin();
  867. i != classes.end(); i++)
  868. {
  869. // Add the file to the list of sources.
  870. std::string source = i->GetFullPath();
  871. cmSourceGroup& sourceGroup = m_Makefile->FindSourceGroup(source.c_str(),
  872. sourceGroups);
  873. sourceGroup.AddSource(source.c_str());
  874. }
  875. // add any custom rules to the source groups
  876. for (std::vector<cmCustomCommand>::const_iterator cr =
  877. target.GetCustomCommands().begin();
  878. cr != target.GetCustomCommands().end(); ++cr)
  879. {
  880. cmSourceGroup& sourceGroup =
  881. m_Makefile->FindSourceGroup(cr->GetSourceName().c_str(),
  882. sourceGroups);
  883. cmCustomCommand cc(*cr);
  884. cc.ExpandVariables(*m_Makefile);
  885. sourceGroup.AddCustomCommand(cc);
  886. }
  887. // open the project
  888. this->WriteProjectStart(fout, libName, target, sourceGroups);
  889. // write the configuration information
  890. this->WriteConfigurations(fout, libName, target);
  891. fout << "\t<Files>\n";
  892. // Find the group in which the CMakeLists.txt source belongs, and add
  893. // the rule to generate this VCProj file.
  894. for(std::vector<cmSourceGroup>::reverse_iterator sg = sourceGroups.rbegin();
  895. sg != sourceGroups.rend(); ++sg)
  896. {
  897. if(sg->Matches("CMakeLists.txt"))
  898. {
  899. this->AddVCProjBuildRule(*sg);
  900. break;
  901. }
  902. }
  903. // Loop through every source group.
  904. for(std::vector<cmSourceGroup>::const_iterator sg = sourceGroups.begin();
  905. sg != sourceGroups.end(); ++sg)
  906. {
  907. const cmSourceGroup::BuildRules& buildRules = sg->GetBuildRules();
  908. // If the group is empty, don't write it at all.
  909. if(buildRules.empty())
  910. { continue; }
  911. // If the group has a name, write the header.
  912. std::string name = sg->GetName();
  913. if(name != "")
  914. {
  915. this->WriteVCProjBeginGroup(fout, name.c_str(), "");
  916. }
  917. // Loop through each build rule in the source group.
  918. for(cmSourceGroup::BuildRules::const_iterator cc =
  919. buildRules.begin(); cc != buildRules.end(); ++ cc)
  920. {
  921. std::string source = cc->first;
  922. const cmSourceGroup::Commands& commands = cc->second;
  923. if (source != libName || target.GetType() == cmTarget::UTILITY)
  924. {
  925. fout << "\t\t\t<File\n";
  926. std::string d = cmSystemTools::ConvertToOutputPath(source.c_str());
  927. // Tell MS-Dev what the source is. If the compiler knows how to
  928. // build it, then it will.
  929. fout << "\t\t\t\tRelativePath=\"" << d << "\">\n";
  930. if (!commands.empty())
  931. {
  932. cmSourceGroup::CommandFiles totalCommand;
  933. std::string totalCommandStr;
  934. totalCommandStr = this->CombineCommands(commands, totalCommand,
  935. source.c_str());
  936. this->WriteCustomRule(fout, source.c_str(), totalCommandStr.c_str(),
  937. totalCommand.m_Depends,
  938. totalCommand.m_Outputs);
  939. }
  940. fout << "\t\t\t</File>\n";
  941. }
  942. }
  943. // If the group has a name, write the footer.
  944. if(name != "")
  945. {
  946. this->WriteVCProjEndGroup(fout);
  947. }
  948. }
  949. fout << "\t</Files>\n";
  950. // Write the VCProj file's footer.
  951. this->WriteVCProjFooter(fout);
  952. }
  953. void cmMSDotNETGenerator::WriteCustomRule(std::ostream& fout,
  954. const char* source,
  955. const char* command,
  956. const std::set<std::string>& depends,
  957. const std::set<std::string>& outputs)
  958. {
  959. std::string cmd = command;
  960. cmSystemTools::ReplaceString(cmd, "\"", "&quot;");
  961. std::vector<std::string>::iterator i;
  962. for(i = m_Configurations.begin(); i != m_Configurations.end(); ++i)
  963. {
  964. fout << "\t\t\t\t<FileConfiguration\n";
  965. fout << "\t\t\t\t\tName=\"" << *i << "|Win32\">\n";
  966. fout << "\t\t\t\t\t<Tool\n"
  967. << "\t\t\t\t\tName=\"VCCustomBuildTool\"\n"
  968. << "\t\t\t\t\tCommandLine=\"" << cmd << "\n\"\n"
  969. << "\t\t\t\t\tAdditionalDependencies=\"";
  970. // Write out the dependencies for the rule.
  971. std::string temp;
  972. for(std::set<std::string>::const_iterator d = depends.begin();
  973. d != depends.end(); ++d)
  974. {
  975. fout << cmSystemTools::ConvertToOutputPath(d->c_str())
  976. << ";";
  977. }
  978. fout << "\"\n";
  979. fout << "\t\t\t\t\tOutputs=\"";
  980. if(outputs.size() == 0)
  981. {
  982. fout << source << "_force";
  983. }
  984. bool first = true;
  985. // Write a rule for every output generated by this command.
  986. for(std::set<std::string>::const_iterator output = outputs.begin();
  987. output != outputs.end(); ++output)
  988. {
  989. if(!first)
  990. {
  991. fout << ";";
  992. }
  993. else
  994. {
  995. first = true;
  996. }
  997. fout << output->c_str();
  998. }
  999. fout << "\"/>\n";
  1000. fout << "\t\t\t\t</FileConfiguration>\n";
  1001. }
  1002. }
  1003. void cmMSDotNETGenerator::WriteVCProjBeginGroup(std::ostream& fout,
  1004. const char* group,
  1005. const char* filter)
  1006. {
  1007. fout << "\t\t<Filter\n"
  1008. << "\t\t\tName=\"" << group << "\"\n"
  1009. << "\t\t\tFilter=\"\">\n";
  1010. }
  1011. void cmMSDotNETGenerator::WriteVCProjEndGroup(std::ostream& fout)
  1012. {
  1013. fout << "\t\t</Filter>\n";
  1014. }
  1015. std::string
  1016. cmMSDotNETGenerator::CombineCommands(const cmSourceGroup::Commands &commands,
  1017. cmSourceGroup::CommandFiles &totalCommand,
  1018. const char *source)
  1019. {
  1020. // Loop through every custom command generating code from the
  1021. // current source.
  1022. // build up the depends and outputs and commands
  1023. std::string totalCommandStr = "";
  1024. std::string temp;
  1025. for(cmSourceGroup::Commands::const_iterator c = commands.begin();
  1026. c != commands.end(); ++c)
  1027. {
  1028. temp=
  1029. cmSystemTools::ConvertToOutputPath(c->second.m_Command.c_str());
  1030. totalCommandStr += temp;
  1031. totalCommandStr += " ";
  1032. totalCommandStr += c->second.m_Arguments;
  1033. totalCommand.Merge(c->second);
  1034. }
  1035. // Create a dummy file with the name of the source if it does
  1036. // not exist
  1037. if(totalCommand.m_Outputs.empty())
  1038. {
  1039. std::string dummyFile = m_Makefile->GetStartOutputDirectory();
  1040. dummyFile += "/";
  1041. dummyFile += source;
  1042. if(!cmSystemTools::FileExists(dummyFile.c_str()))
  1043. {
  1044. std::ofstream fout(dummyFile.c_str());
  1045. fout << "Dummy file created by cmake as unused source for utility command.\n";
  1046. }
  1047. }
  1048. return totalCommandStr;
  1049. }
  1050. // look for custom rules on a target and collect them together
  1051. void cmMSDotNETGenerator::OutputTargetRules(std::ostream& fout,
  1052. const cmTarget &target,
  1053. const char *libName)
  1054. {
  1055. if (target.GetType() >= cmTarget::UTILITY)
  1056. {
  1057. return;
  1058. }
  1059. // Find the group in which the lix exe custom rules belong
  1060. bool init = false;
  1061. for (std::vector<cmCustomCommand>::const_iterator cr =
  1062. target.GetCustomCommands().begin();
  1063. cr != target.GetCustomCommands().end(); ++cr)
  1064. {
  1065. cmCustomCommand cc(*cr);
  1066. cc.ExpandVariables(*m_Makefile);
  1067. if (cc.GetSourceName() == libName)
  1068. {
  1069. if(!init)
  1070. {
  1071. fout << "\nCommandLine=\"";
  1072. init = true;
  1073. }
  1074. fout << cc.GetCommand() << " " << cc.GetArguments() << "\n";
  1075. }
  1076. }
  1077. if (init)
  1078. {
  1079. fout << "\"";
  1080. }
  1081. }
  1082. void cmMSDotNETGenerator::WriteProjectStart(std::ostream& fout, const char *libName,
  1083. const cmTarget &target,
  1084. std::vector<cmSourceGroup> &)
  1085. {
  1086. fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
  1087. << "<VisualStudioProject\n"
  1088. << "\tProjectType=\"Visual C++\"\n"
  1089. << "\tVersion=\"7.00\"\n"
  1090. << "\tName=\"" << libName << "\"\n"
  1091. << "\tSccProjectName=\"\"\n"
  1092. << "\tSccLocalPath=\"\"\n"
  1093. << "\tKeyword=\"Win32Proj\">\n"
  1094. << "\t<Platforms>\n"
  1095. << "\t\t<Platform\n\t\t\tName=\"Win32\"/>\n"
  1096. << "\t</Platforms>\n";
  1097. }
  1098. void cmMSDotNETGenerator::WriteVCProjFooter(std::ostream& fout)
  1099. {
  1100. fout << "\t<Globals>\n"
  1101. << "\t</Globals>\n"
  1102. << "</VisualStudioProject>\n";
  1103. }