cmGlobalVisualStudio7Generator.cxx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html 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 "cmGlobalVisualStudio7Generator.h"
  14. #include "cmLocalVisualStudio7Generator.h"
  15. #include "cmMakefile.h"
  16. #include "cmake.h"
  17. #include "windows.h"
  18. cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator()
  19. {
  20. m_FindMakeProgramFile = "CMakeVS7FindMake.cmake";
  21. }
  22. void cmGlobalVisualStudio7Generator::EnableLanguage(const char* lang,
  23. cmMakefile *mf)
  24. {
  25. mf->AddDefinition("CMAKE_CFG_INTDIR","$(IntDir)");
  26. mf->AddDefinition("CMAKE_GENERATOR_CC", "cl");
  27. mf->AddDefinition("CMAKE_GENERATOR_CXX", "cl");
  28. // Create list of configurations requested by user's cache, if any.
  29. this->GenerateConfigurations(mf);
  30. this->cmGlobalGenerator::EnableLanguage(lang, mf);
  31. }
  32. int cmGlobalVisualStudio7Generator::TryCompile(const char *,
  33. const char *bindir,
  34. const char *projectName,
  35. const char *targetName,
  36. std::string *output)
  37. {
  38. // now build the test
  39. std::string makeCommand =
  40. m_CMakeInstance->GetCacheManager()->GetCacheValue("CMAKE_MAKE_PROGRAM");
  41. if(makeCommand.size() == 0)
  42. {
  43. cmSystemTools::Error(
  44. "Generator cannot find the appropriate make command.");
  45. return 1;
  46. }
  47. makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str());
  48. std::string lowerCaseCommand = makeCommand;
  49. cmSystemTools::LowerCase(lowerCaseCommand);
  50. /**
  51. * Run an executable command and put the stdout in output.
  52. */
  53. std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
  54. cmSystemTools::ChangeDirectory(bindir);
  55. // if there are spaces in the makeCommand, assume a full path
  56. // and convert it to a path with no spaces in it as the
  57. // RunSingleCommand does not like spaces
  58. #if defined(_WIN32) && !defined(__CYGWIN__)
  59. if(makeCommand.find(' ') != std::string::npos)
  60. {
  61. cmSystemTools::GetShortPath(makeCommand.c_str(), makeCommand);
  62. }
  63. #endif
  64. makeCommand += " ";
  65. makeCommand += projectName;
  66. makeCommand += ".sln /build ";
  67. if ( m_LocalGenerators[0]->GetMakefile()->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION") )
  68. {
  69. makeCommand +=
  70. m_LocalGenerators[0]->GetMakefile()->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
  71. }
  72. else
  73. {
  74. makeCommand += "Debug";
  75. }
  76. makeCommand += " /project ";
  77. if (targetName)
  78. {
  79. makeCommand += targetName;
  80. }
  81. else
  82. {
  83. makeCommand += "ALL_BUILD";
  84. }
  85. int retVal;
  86. int timeout = cmGlobalGenerator::s_TryCompileTimeout;
  87. if (!cmSystemTools::RunSingleCommand(makeCommand.c_str(), output, &retVal,
  88. 0, false, timeout))
  89. {
  90. cmSystemTools::Error("Generator: execution of devenv failed.");
  91. // return to the original directory
  92. cmSystemTools::ChangeDirectory(cwd.c_str());
  93. return 1;
  94. }
  95. cmSystemTools::ChangeDirectory(cwd.c_str());
  96. return retVal;
  97. }
  98. ///! Create a local generator appropriate to this Global Generator
  99. cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator()
  100. {
  101. cmLocalGenerator *lg = new cmLocalVisualStudio7Generator;
  102. lg->SetGlobalGenerator(this);
  103. return lg;
  104. }
  105. void cmGlobalVisualStudio7Generator::SetupTests()
  106. {
  107. std::string ctest =
  108. m_LocalGenerators[0]->GetMakefile()->GetDefinition("CMAKE_COMMAND");
  109. ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
  110. ctest += "/";
  111. ctest += "ctest";
  112. ctest += cmSystemTools::GetExecutableExtension();
  113. if(!cmSystemTools::FileExists(ctest.c_str()))
  114. {
  115. ctest =
  116. m_LocalGenerators[0]->GetMakefile()->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 =
  125. m_LocalGenerators[0]->GetMakefile()->GetDefinition("CMAKE_COMMAND");
  126. ctest = cmSystemTools::GetFilenamePath(ctest.c_str());
  127. ctest += "/Release/";
  128. ctest += "ctest";
  129. ctest += cmSystemTools::GetExecutableExtension();
  130. }
  131. // if we found ctest
  132. if (cmSystemTools::FileExists(ctest.c_str()))
  133. {
  134. // Create a full path filename for output Testfile
  135. std::string fname;
  136. fname = m_CMakeInstance->GetStartOutputDirectory();
  137. fname += "/";
  138. fname += "DartTestfile.txt";
  139. // If the file doesn't exist, then ENABLE_TESTING hasn't been run
  140. if (cmSystemTools::FileExists(fname.c_str()))
  141. {
  142. std::vector<std::string> srcs;
  143. std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
  144. for(it = m_SubProjectMap.begin(); it!= m_SubProjectMap.end(); ++it)
  145. {
  146. std::vector<cmLocalGenerator*>& gen = it->second;
  147. // add the ALL_BUILD to the first local generator of each project
  148. if(gen.size())
  149. {
  150. gen[0]->GetMakefile()->
  151. AddUtilityCommand("RUN_TESTS", ctest.c_str(), "-D $(IntDir)",false,srcs);
  152. }
  153. }
  154. }
  155. }
  156. }
  157. void cmGlobalVisualStudio7Generator::GenerateConfigurations(cmMakefile* mf)
  158. {
  159. // process the configurations
  160. const char* ct
  161. = m_CMakeInstance->GetCacheDefinition("CMAKE_CONFIGURATION_TYPES");
  162. if ( ct )
  163. {
  164. std::string configTypes = ct;
  165. std::string::size_type start = 0;
  166. std::string::size_type endpos = 0;
  167. while(endpos != std::string::npos)
  168. {
  169. endpos = configTypes.find_first_of(" ;", start);
  170. std::string config;
  171. std::string::size_type len;
  172. if(endpos != std::string::npos)
  173. {
  174. len = endpos - start;
  175. }
  176. else
  177. {
  178. len = configTypes.size() - start;
  179. }
  180. config = configTypes.substr(start, len);
  181. if(config == "Debug" || config == "Release" ||
  182. config == "MinSizeRel" || config == "RelWithDebInfo")
  183. {
  184. // only add unique configurations
  185. if(std::find(m_Configurations.begin(),
  186. m_Configurations.end(), config) == m_Configurations.end())
  187. {
  188. m_Configurations.push_back(config);
  189. }
  190. }
  191. else
  192. {
  193. cmSystemTools::Error(
  194. "Invalid configuration type in CMAKE_CONFIGURATION_TYPES: ",
  195. config.c_str(),
  196. " (Valid types are Debug,Release,MinSizeRel,RelWithDebInfo)");
  197. }
  198. start = endpos+1;
  199. }
  200. }
  201. if(m_Configurations.size() == 0)
  202. {
  203. m_Configurations.push_back("Debug");
  204. m_Configurations.push_back("Release");
  205. }
  206. // Reset the entry to have a semi-colon separated list.
  207. std::string configs = m_Configurations[0];
  208. for(unsigned int i=1; i < m_Configurations.size(); ++i)
  209. {
  210. configs += ";";
  211. configs += m_Configurations[i];
  212. }
  213. mf->AddCacheDefinition(
  214. "CMAKE_CONFIGURATION_TYPES",
  215. configs.c_str(),
  216. "Semicolon separated list of supported configuration types, "
  217. "only supports Debug, Release, MinSizeRel, and RelWithDebInfo, "
  218. "anything else will be ignored.",
  219. cmCacheManager::STRING);
  220. }
  221. void cmGlobalVisualStudio7Generator::Generate()
  222. {
  223. // collect sub-projects
  224. this->CollectSubprojects();
  225. // add a special target that depends on ALL projects for easy build
  226. // of Debug only
  227. std::vector<std::string> srcs;
  228. std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
  229. for(it = m_SubProjectMap.begin(); it!= m_SubProjectMap.end(); ++it)
  230. {
  231. std::vector<cmLocalGenerator*>& gen = it->second;
  232. // add the ALL_BUILD to the first local generator of each project
  233. if(gen.size())
  234. {
  235. gen[0]->GetMakefile()->
  236. AddUtilityCommand("ALL_BUILD", "echo","\"Build all projects\"",false,srcs);
  237. }
  238. }
  239. // add the Run Tests command
  240. this->SetupTests();
  241. // first do the superclass method
  242. this->cmGlobalGenerator::Generate();
  243. // Now write out the DSW
  244. this->OutputSLNFile();
  245. }
  246. void cmGlobalVisualStudio7Generator::OutputSLNFile(cmLocalGenerator* root,
  247. std::vector<cmLocalGenerator*>& generators)
  248. {
  249. if(generators.size() == 0)
  250. {
  251. return;
  252. }
  253. std::string fname = root->GetMakefile()->GetStartOutputDirectory();
  254. fname += "/";
  255. fname += root->GetMakefile()->GetProjectName();
  256. fname += ".sln";
  257. std::ofstream fout(fname.c_str());
  258. if(!fout)
  259. {
  260. cmSystemTools::Error("Error can not open DSW file for write: ",
  261. fname.c_str());
  262. return;
  263. }
  264. this->WriteSLNFile(fout, root, generators);
  265. }
  266. // output the SLN file
  267. void cmGlobalVisualStudio7Generator::OutputSLNFile()
  268. {
  269. std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
  270. for(it = m_SubProjectMap.begin(); it!= m_SubProjectMap.end(); ++it)
  271. {
  272. this->OutputSLNFile(it->second[0], it->second);
  273. }
  274. }
  275. // Write a SLN file to the stream
  276. void cmGlobalVisualStudio7Generator::WriteSLNFile(std::ostream& fout,
  277. cmLocalGenerator* root,
  278. std::vector<cmLocalGenerator*>& generators)
  279. {
  280. // Write out the header for a SLN file
  281. this->WriteSLNHeader(fout);
  282. // Get the home directory with the trailing slash
  283. std::string homedir = m_CMakeInstance->GetHomeDirectory();
  284. homedir += "/";
  285. bool doneAllBuild = false;
  286. bool doneRunTests = false;
  287. // For each cmMakefile, create a VCProj for it, and
  288. // add it to this SLN file
  289. unsigned int i;
  290. for(i = 0; i < generators.size(); ++i)
  291. {
  292. if(this->IsExcluded(root, generators[i]))
  293. {
  294. continue;
  295. }
  296. cmMakefile* mf = generators[i]->GetMakefile();
  297. // Get the source directory from the makefile
  298. std::string dir = mf->GetStartDirectory();
  299. // remove the home directory and / from the source directory
  300. // this gives a relative path
  301. cmSystemTools::ReplaceString(dir, homedir.c_str(), "");
  302. // Get the list of create dsp files names from the cmVCProjWriter, more
  303. // than one dsp could have been created per input CMakeLists.txt file
  304. // for each target
  305. std::vector<std::string> dspnames =
  306. static_cast<cmLocalVisualStudio7Generator *>(generators[i])
  307. ->GetCreatedProjectNames();
  308. cmTargets &tgts = generators[i]->GetMakefile()->GetTargets();
  309. cmTargets::iterator l = tgts.begin();
  310. for(std::vector<std::string>::iterator si = dspnames.begin();
  311. l != tgts.end(); ++l)
  312. {
  313. // special handling for the current makefile
  314. if(mf == generators[0]->GetMakefile())
  315. {
  316. dir = "."; // no subdirectory for project generated
  317. // if this is the special ALL_BUILD utility, then
  318. // make it depend on every other non UTILITY project.
  319. // This is done by adding the names to the GetUtilities
  320. // vector on the makefile
  321. if(l->first == "ALL_BUILD" && !doneAllBuild)
  322. {
  323. unsigned int j;
  324. for(j = 0; j < generators.size(); ++j)
  325. {
  326. const cmTargets &atgts =
  327. generators[j]->GetMakefile()->GetTargets();
  328. for(cmTargets::const_iterator al = atgts.begin();
  329. al != atgts.end(); ++al)
  330. {
  331. if (al->second.IsInAll())
  332. {
  333. if (al->second.GetType() == cmTarget::UTILITY)
  334. {
  335. l->second.AddUtility(al->first.c_str());
  336. }
  337. else
  338. {
  339. l->second.AddLinkLibrary(al->first,cmTarget::GENERAL);
  340. }
  341. }
  342. }
  343. }
  344. }
  345. }
  346. // Write the project into the SLN file
  347. if (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
  348. {
  349. cmCustomCommand cc = l->second.GetPreLinkCommands()[0];
  350. // dodgy use of the cmCustomCommand's members to store the
  351. // arguments from the INCLUDE_EXTERNAL_MSPROJECT command
  352. std::vector<std::string> stuff = cc.GetDepends();
  353. std::vector<std::string> depends;
  354. depends.push_back(cc.GetOutput());
  355. this->WriteExternalProject(fout, stuff[0].c_str(),
  356. stuff[1].c_str(), depends);
  357. ++si;
  358. }
  359. else
  360. {
  361. if ((l->second.GetType() != cmTarget::INSTALL_FILES)
  362. && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
  363. {
  364. bool skip = false;
  365. if(l->first == "ALL_BUILD" )
  366. {
  367. if(doneAllBuild)
  368. {
  369. skip = true;
  370. }
  371. else
  372. {
  373. doneAllBuild = true;
  374. }
  375. }
  376. if(l->first == "RUN_TESTS")
  377. {
  378. if(doneRunTests)
  379. {
  380. skip = true;
  381. }
  382. else
  383. {
  384. doneRunTests = true;
  385. }
  386. }
  387. if(!skip)
  388. {
  389. this->WriteProject(fout, si->c_str(), dir.c_str(),l->second);
  390. }
  391. ++si;
  392. }
  393. }
  394. }
  395. }
  396. fout << "Global\n"
  397. << "\tGlobalSection(SolutionConfiguration) = preSolution\n";
  398. int c = 0;
  399. for(std::vector<std::string>::iterator i = m_Configurations.begin();
  400. i != m_Configurations.end(); ++i)
  401. {
  402. fout << "\t\tConfigName." << c << " = " << *i << "\n";
  403. c++;
  404. }
  405. fout << "\tEndGlobalSection\n"
  406. << "\tGlobalSection(ProjectDependencies) = postSolution\n";
  407. // loop over again and compute the depends
  408. for(i = 0; i < generators.size(); ++i)
  409. {
  410. cmMakefile* mf = generators[i]->GetMakefile();
  411. cmLocalVisualStudio7Generator* pg =
  412. static_cast<cmLocalVisualStudio7Generator*>(generators[i]);
  413. // Get the list of create dsp files names from the cmVCProjWriter, more
  414. // than one dsp could have been created per input CMakeLists.txt file
  415. // for each target
  416. std::vector<std::string> dspnames =
  417. pg->GetCreatedProjectNames();
  418. cmTargets &tgts = pg->GetMakefile()->GetTargets();
  419. cmTargets::iterator l = tgts.begin();
  420. std::string dir = mf->GetStartDirectory();
  421. for(std::vector<std::string>::iterator si = dspnames.begin();
  422. l != tgts.end(); ++l)
  423. {
  424. if ((l->second.GetType() != cmTarget::INSTALL_FILES)
  425. && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
  426. {
  427. this->WriteProjectDepends(fout, si->c_str(), dir.c_str(),l->second);
  428. ++si;
  429. }
  430. }
  431. }
  432. fout << "\tEndGlobalSection\n";
  433. fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n";
  434. // loop over again and compute the depends
  435. for(i = 0; i < generators.size(); ++i)
  436. {
  437. cmMakefile* mf = generators[i]->GetMakefile();
  438. cmLocalVisualStudio7Generator* pg =
  439. static_cast<cmLocalVisualStudio7Generator*>(generators[i]);
  440. // Get the list of create dsp files names from the cmVCProjWriter, more
  441. // than one dsp could have been created per input CMakeLists.txt file
  442. // for each target
  443. std::vector<std::string> dspnames =
  444. pg->GetCreatedProjectNames();
  445. cmTargets &tgts = pg->GetMakefile()->GetTargets();
  446. cmTargets::iterator l = tgts.begin();
  447. std::string dir = mf->GetStartDirectory();
  448. for(std::vector<std::string>::iterator si = dspnames.begin();
  449. l != tgts.end(); ++l)
  450. {
  451. if ((l->second.GetType() != cmTarget::INSTALL_FILES)
  452. && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
  453. {
  454. this->WriteProjectConfigurations(fout, si->c_str(), l->second.IsInAll());
  455. ++si;
  456. }
  457. }
  458. }
  459. fout << "\tEndGlobalSection\n";
  460. // Write the footer for the SLN file
  461. this->WriteSLNFooter(fout);
  462. }
  463. // Write a dsp file into the SLN file,
  464. // Note, that dependencies from executables to
  465. // the libraries it uses are also done here
  466. void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout,
  467. const char* dspname,
  468. const char* dir,
  469. const cmTarget&)
  470. {
  471. std::string d = cmSystemTools::ConvertToOutputPath(dir);
  472. fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
  473. << dspname << "\", \""
  474. << d << "\\" << dspname << ".vcproj\", \"{"
  475. << this->CreateGUID(dspname) << "}\"\nEndProject\n";
  476. }
  477. // Write a dsp file into the SLN file,
  478. // Note, that dependencies from executables to
  479. // the libraries it uses are also done here
  480. void cmGlobalVisualStudio7Generator::WriteProjectDepends(std::ostream& fout,
  481. const char* dspname,
  482. const char* ,
  483. const cmTarget& target
  484. )
  485. {
  486. int depcount = 0;
  487. // insert Begin Project Dependency Project_Dep_Name project stuff here
  488. if (target.GetType() != cmTarget::STATIC_LIBRARY)
  489. {
  490. cmTarget::LinkLibraries::const_iterator j, jend;
  491. j = target.GetLinkLibraries().begin();
  492. jend = target.GetLinkLibraries().end();
  493. for(;j!= jend; ++j)
  494. {
  495. if(j->first != dspname)
  496. {
  497. // is the library part of this SLN ? If so add dependency
  498. std::string libPath = j->first + "_CMAKE_PATH";
  499. const char* cacheValue
  500. = m_CMakeInstance->GetCacheDefinition(libPath.c_str());
  501. if(cacheValue && *cacheValue)
  502. {
  503. fout << "\t\t{" << this->CreateGUID(dspname) << "}." << depcount << " = {"
  504. << this->CreateGUID(j->first.c_str()) << "}\n";
  505. depcount++;
  506. }
  507. }
  508. }
  509. }
  510. std::set<cmStdString>::const_iterator i, end;
  511. // write utility dependencies.
  512. i = target.GetUtilities().begin();
  513. end = target.GetUtilities().end();
  514. for(;i!= end; ++i)
  515. {
  516. if(*i != dspname)
  517. {
  518. fout << "\t\t{" << this->CreateGUID(dspname) << "}." << depcount << " = {"
  519. << this->CreateGUID(i->c_str()) << "}\n";
  520. depcount++;
  521. }
  522. }
  523. }
  524. // Write a dsp file into the SLN file,
  525. // Note, that dependencies from executables to
  526. // the libraries it uses are also done here
  527. void
  528. cmGlobalVisualStudio7Generator::WriteProjectConfigurations(std::ostream& fout,
  529. const char* name,
  530. bool in_all_build)
  531. {
  532. std::string guid = this->CreateGUID(name);
  533. for(std::vector<std::string>::iterator i = m_Configurations.begin();
  534. i != m_Configurations.end(); ++i)
  535. {
  536. fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << *i << "|Win32\n";
  537. if (in_all_build)
  538. {
  539. fout << "\t\t{" << guid << "}." << *i << ".Build.0 = " << *i << "|Win32\n";
  540. }
  541. }
  542. }
  543. // Write a dsp file into the SLN file,
  544. // Note, that dependencies from executables to
  545. // the libraries it uses are also done here
  546. void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& ,
  547. const char* ,
  548. const char* ,
  549. const std::vector<std::string>& )
  550. {
  551. cmSystemTools::Error("WriteExternalProject not implemented for Visual Studio 7");
  552. }
  553. // Standard end of dsw file
  554. void cmGlobalVisualStudio7Generator::WriteSLNFooter(std::ostream& fout)
  555. {
  556. fout << "\tGlobalSection(ExtensibilityGlobals) = postSolution\n"
  557. << "\tEndGlobalSection\n"
  558. << "\tGlobalSection(ExtensibilityAddIns) = postSolution\n"
  559. << "\tEndGlobalSection\n"
  560. << "EndGlobal\n";
  561. }
  562. // ouput standard header for dsw file
  563. void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout)
  564. {
  565. fout << "Microsoft Visual Studio Solution File, Format Version 7.00\n";
  566. }
  567. std::string cmGlobalVisualStudio7Generator::CreateGUID(const char* name)
  568. {
  569. std::map<cmStdString, cmStdString>::iterator i = m_GUIDMap.find(name);
  570. if(i != m_GUIDMap.end())
  571. {
  572. return i->second;
  573. }
  574. std::string ret;
  575. UUID uid;
  576. unsigned char *uidstr;
  577. UuidCreate(&uid);
  578. UuidToString(&uid,&uidstr);
  579. ret = reinterpret_cast<char*>(uidstr);
  580. RpcStringFree(&uidstr);
  581. ret = cmSystemTools::UpperCase(ret);
  582. m_GUIDMap[name] = ret;
  583. return ret;
  584. }
  585. void cmGlobalVisualStudio7Generator::LocalGenerate()
  586. {
  587. this->cmGlobalGenerator::LocalGenerate();
  588. }
  589. std::vector<std::string> *cmGlobalVisualStudio7Generator::GetConfigurations()
  590. {
  591. return &m_Configurations;
  592. };
  593. //----------------------------------------------------------------------------
  594. void cmGlobalVisualStudio7Generator::GetDocumentation(cmDocumentationEntry& entry) const
  595. {
  596. entry.name = this->GetName();
  597. entry.brief = "Generates Visual Studio .NET 2002 project files.";
  598. entry.full = "";
  599. }
  600. // populate the m_SubProjectMap
  601. void cmGlobalVisualStudio7Generator::CollectSubprojects()
  602. {
  603. unsigned int i;
  604. for(i = 0; i < m_LocalGenerators.size(); ++i)
  605. {
  606. std::string name = m_LocalGenerators[i]->GetMakefile()->GetProjectName();
  607. m_SubProjectMap[name].push_back(m_LocalGenerators[i]);
  608. std::vector<std::string> const& pprojects
  609. = m_LocalGenerators[i]->GetMakefile()->GetParentProjects();
  610. for(unsigned int k =0; k < pprojects.size(); ++k)
  611. {
  612. m_SubProjectMap[pprojects[k]].push_back(m_LocalGenerators[i]);
  613. }
  614. }
  615. }