cmGlobalVisualStudio7Generator.cxx 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668
  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(std::vector<cmLocalGenerator*>& generators)
  247. {
  248. if(generators.size() == 0)
  249. {
  250. return;
  251. }
  252. std::string fname = generators[0]->GetMakefile()->GetStartOutputDirectory();
  253. fname += "/";
  254. fname += generators[0]->GetMakefile()->GetProjectName();
  255. fname += ".sln";
  256. std::ofstream fout(fname.c_str());
  257. if(!fout)
  258. {
  259. cmSystemTools::Error("Error can not open DSW file for write: ",
  260. fname.c_str());
  261. return;
  262. }
  263. this->WriteSLNFile(fout, generators);
  264. }
  265. // output the SLN file
  266. void cmGlobalVisualStudio7Generator::OutputSLNFile()
  267. {
  268. std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
  269. for(it = m_SubProjectMap.begin(); it!= m_SubProjectMap.end(); ++it)
  270. {
  271. this->OutputSLNFile(it->second);
  272. }
  273. }
  274. // Write a SLN file to the stream
  275. void cmGlobalVisualStudio7Generator::WriteSLNFile(std::ostream& fout,
  276. std::vector<cmLocalGenerator*>& generators)
  277. {
  278. // Write out the header for a SLN file
  279. this->WriteSLNHeader(fout);
  280. // Get the home directory with the trailing slash
  281. std::string homedir = m_CMakeInstance->GetHomeDirectory();
  282. homedir += "/";
  283. bool doneAllBuild = false;
  284. bool doneRunTests = false;
  285. // For each cmMakefile, create a VCProj for it, and
  286. // add it to this SLN file
  287. unsigned int i;
  288. for(i = 0; i < generators.size(); ++i)
  289. {
  290. cmMakefile* mf = generators[i]->GetMakefile();
  291. // Get the source directory from the makefile
  292. std::string dir = mf->GetStartDirectory();
  293. // remove the home directory and / from the source directory
  294. // this gives a relative path
  295. cmSystemTools::ReplaceString(dir, homedir.c_str(), "");
  296. // Get the list of create dsp files names from the cmVCProjWriter, more
  297. // than one dsp could have been created per input CMakeLists.txt file
  298. // for each target
  299. std::vector<std::string> dspnames =
  300. static_cast<cmLocalVisualStudio7Generator *>(generators[i])
  301. ->GetCreatedProjectNames();
  302. cmTargets &tgts = generators[i]->GetMakefile()->GetTargets();
  303. cmTargets::iterator l = tgts.begin();
  304. for(std::vector<std::string>::iterator si = dspnames.begin();
  305. l != tgts.end(); ++l)
  306. {
  307. // special handling for the current makefile
  308. if(mf == generators[0]->GetMakefile())
  309. {
  310. dir = "."; // no subdirectory for project generated
  311. // if this is the special ALL_BUILD utility, then
  312. // make it depend on every other non UTILITY project.
  313. // This is done by adding the names to the GetUtilities
  314. // vector on the makefile
  315. if(l->first == "ALL_BUILD" && !doneAllBuild)
  316. {
  317. unsigned int j;
  318. for(j = 0; j < generators.size(); ++j)
  319. {
  320. const cmTargets &atgts =
  321. generators[j]->GetMakefile()->GetTargets();
  322. for(cmTargets::const_iterator al = atgts.begin();
  323. al != atgts.end(); ++al)
  324. {
  325. if (al->second.IsInAll())
  326. {
  327. if (al->second.GetType() == cmTarget::UTILITY)
  328. {
  329. l->second.AddUtility(al->first.c_str());
  330. }
  331. else
  332. {
  333. l->second.AddLinkLibrary(al->first,cmTarget::GENERAL);
  334. }
  335. }
  336. }
  337. }
  338. }
  339. }
  340. // Write the project into the SLN file
  341. if (strncmp(l->first.c_str(), "INCLUDE_EXTERNAL_MSPROJECT", 26) == 0)
  342. {
  343. cmCustomCommand cc = l->second.GetPreLinkCommands()[0];
  344. // dodgy use of the cmCustomCommand's members to store the
  345. // arguments from the INCLUDE_EXTERNAL_MSPROJECT command
  346. std::vector<std::string> stuff = cc.GetDepends();
  347. std::vector<std::string> depends;
  348. depends.push_back(cc.GetOutput());
  349. this->WriteExternalProject(fout, stuff[0].c_str(),
  350. stuff[1].c_str(), depends);
  351. ++si;
  352. }
  353. else
  354. {
  355. if ((l->second.GetType() != cmTarget::INSTALL_FILES)
  356. && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
  357. {
  358. bool skip = false;
  359. if(l->first == "ALL_BUILD" )
  360. {
  361. if(doneAllBuild)
  362. {
  363. skip = true;
  364. }
  365. else
  366. {
  367. doneAllBuild = true;
  368. }
  369. }
  370. if(l->first == "RUN_TESTS")
  371. {
  372. if(doneRunTests)
  373. {
  374. skip = true;
  375. }
  376. else
  377. {
  378. doneRunTests = true;
  379. }
  380. }
  381. if(!skip)
  382. {
  383. this->WriteProject(fout, si->c_str(), dir.c_str(),l->second);
  384. }
  385. ++si;
  386. }
  387. }
  388. }
  389. }
  390. fout << "Global\n"
  391. << "\tGlobalSection(SolutionConfiguration) = preSolution\n";
  392. int c = 0;
  393. for(std::vector<std::string>::iterator i = m_Configurations.begin();
  394. i != m_Configurations.end(); ++i)
  395. {
  396. fout << "\t\tConfigName." << c << " = " << *i << "\n";
  397. c++;
  398. }
  399. fout << "\tEndGlobalSection\n"
  400. << "\tGlobalSection(ProjectDependencies) = postSolution\n";
  401. // loop over again and compute the depends
  402. for(i = 0; i < generators.size(); ++i)
  403. {
  404. cmMakefile* mf = generators[i]->GetMakefile();
  405. cmLocalVisualStudio7Generator* pg =
  406. static_cast<cmLocalVisualStudio7Generator*>(generators[i]);
  407. // Get the list of create dsp files names from the cmVCProjWriter, more
  408. // than one dsp could have been created per input CMakeLists.txt file
  409. // for each target
  410. std::vector<std::string> dspnames =
  411. pg->GetCreatedProjectNames();
  412. cmTargets &tgts = pg->GetMakefile()->GetTargets();
  413. cmTargets::iterator l = tgts.begin();
  414. std::string dir = mf->GetStartDirectory();
  415. for(std::vector<std::string>::iterator si = dspnames.begin();
  416. l != tgts.end(); ++l)
  417. {
  418. if ((l->second.GetType() != cmTarget::INSTALL_FILES)
  419. && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
  420. {
  421. this->WriteProjectDepends(fout, si->c_str(), dir.c_str(),l->second);
  422. ++si;
  423. }
  424. }
  425. }
  426. fout << "\tEndGlobalSection\n";
  427. fout << "\tGlobalSection(ProjectConfiguration) = postSolution\n";
  428. // loop over again and compute the depends
  429. for(i = 0; i < generators.size(); ++i)
  430. {
  431. cmMakefile* mf = generators[i]->GetMakefile();
  432. cmLocalVisualStudio7Generator* pg =
  433. static_cast<cmLocalVisualStudio7Generator*>(generators[i]);
  434. // Get the list of create dsp files names from the cmVCProjWriter, more
  435. // than one dsp could have been created per input CMakeLists.txt file
  436. // for each target
  437. std::vector<std::string> dspnames =
  438. pg->GetCreatedProjectNames();
  439. cmTargets &tgts = pg->GetMakefile()->GetTargets();
  440. cmTargets::iterator l = tgts.begin();
  441. std::string dir = mf->GetStartDirectory();
  442. for(std::vector<std::string>::iterator si = dspnames.begin();
  443. l != tgts.end(); ++l)
  444. {
  445. if ((l->second.GetType() != cmTarget::INSTALL_FILES)
  446. && (l->second.GetType() != cmTarget::INSTALL_PROGRAMS))
  447. {
  448. this->WriteProjectConfigurations(fout, si->c_str(), l->second.IsInAll());
  449. ++si;
  450. }
  451. }
  452. }
  453. fout << "\tEndGlobalSection\n";
  454. // Write the footer for the SLN file
  455. this->WriteSLNFooter(fout);
  456. }
  457. // Write a dsp file into the SLN file,
  458. // Note, that dependencies from executables to
  459. // the libraries it uses are also done here
  460. void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout,
  461. const char* dspname,
  462. const char* dir,
  463. const cmTarget&)
  464. {
  465. std::string d = cmSystemTools::ConvertToOutputPath(dir);
  466. fout << "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \""
  467. << dspname << "\", \""
  468. << d << "\\" << dspname << ".vcproj\", \"{"
  469. << this->CreateGUID(dspname) << "}\"\nEndProject\n";
  470. }
  471. // Write a dsp file into the SLN file,
  472. // Note, that dependencies from executables to
  473. // the libraries it uses are also done here
  474. void cmGlobalVisualStudio7Generator::WriteProjectDepends(std::ostream& fout,
  475. const char* dspname,
  476. const char* ,
  477. const cmTarget& target
  478. )
  479. {
  480. int depcount = 0;
  481. // insert Begin Project Dependency Project_Dep_Name project stuff here
  482. if (target.GetType() != cmTarget::STATIC_LIBRARY)
  483. {
  484. cmTarget::LinkLibraries::const_iterator j, jend;
  485. j = target.GetLinkLibraries().begin();
  486. jend = target.GetLinkLibraries().end();
  487. for(;j!= jend; ++j)
  488. {
  489. if(j->first != dspname)
  490. {
  491. // is the library part of this SLN ? If so add dependency
  492. std::string libPath = j->first + "_CMAKE_PATH";
  493. const char* cacheValue
  494. = m_CMakeInstance->GetCacheDefinition(libPath.c_str());
  495. if(cacheValue && *cacheValue)
  496. {
  497. fout << "\t\t{" << this->CreateGUID(dspname) << "}." << depcount << " = {"
  498. << this->CreateGUID(j->first.c_str()) << "}\n";
  499. depcount++;
  500. }
  501. }
  502. }
  503. }
  504. std::set<cmStdString>::const_iterator i, end;
  505. // write utility dependencies.
  506. i = target.GetUtilities().begin();
  507. end = target.GetUtilities().end();
  508. for(;i!= end; ++i)
  509. {
  510. if(*i != dspname)
  511. {
  512. fout << "\t\t{" << this->CreateGUID(dspname) << "}." << depcount << " = {"
  513. << this->CreateGUID(i->c_str()) << "}\n";
  514. depcount++;
  515. }
  516. }
  517. }
  518. // Write a dsp file into the SLN file,
  519. // Note, that dependencies from executables to
  520. // the libraries it uses are also done here
  521. void
  522. cmGlobalVisualStudio7Generator::WriteProjectConfigurations(std::ostream& fout,
  523. const char* name,
  524. bool in_all_build)
  525. {
  526. std::string guid = this->CreateGUID(name);
  527. for(std::vector<std::string>::iterator i = m_Configurations.begin();
  528. i != m_Configurations.end(); ++i)
  529. {
  530. fout << "\t\t{" << guid << "}." << *i << ".ActiveCfg = " << *i << "|Win32\n";
  531. if (in_all_build)
  532. {
  533. fout << "\t\t{" << guid << "}." << *i << ".Build.0 = " << *i << "|Win32\n";
  534. }
  535. }
  536. }
  537. // Write a dsp file into the SLN file,
  538. // Note, that dependencies from executables to
  539. // the libraries it uses are also done here
  540. void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& ,
  541. const char* ,
  542. const char* ,
  543. const std::vector<std::string>& )
  544. {
  545. cmSystemTools::Error("WriteExternalProject not implemented for Visual Studio 7");
  546. }
  547. // Standard end of dsw file
  548. void cmGlobalVisualStudio7Generator::WriteSLNFooter(std::ostream& fout)
  549. {
  550. fout << "\tGlobalSection(ExtensibilityGlobals) = postSolution\n"
  551. << "\tEndGlobalSection\n"
  552. << "\tGlobalSection(ExtensibilityAddIns) = postSolution\n"
  553. << "\tEndGlobalSection\n"
  554. << "EndGlobal\n";
  555. }
  556. // ouput standard header for dsw file
  557. void cmGlobalVisualStudio7Generator::WriteSLNHeader(std::ostream& fout)
  558. {
  559. fout << "Microsoft Visual Studio Solution File, Format Version 7.00\n";
  560. }
  561. std::string cmGlobalVisualStudio7Generator::CreateGUID(const char* name)
  562. {
  563. std::map<cmStdString, cmStdString>::iterator i = m_GUIDMap.find(name);
  564. if(i != m_GUIDMap.end())
  565. {
  566. return i->second;
  567. }
  568. std::string ret;
  569. UUID uid;
  570. unsigned char *uidstr;
  571. UuidCreate(&uid);
  572. UuidToString(&uid,&uidstr);
  573. ret = reinterpret_cast<char*>(uidstr);
  574. RpcStringFree(&uidstr);
  575. ret = cmSystemTools::UpperCase(ret);
  576. m_GUIDMap[name] = ret;
  577. return ret;
  578. }
  579. void cmGlobalVisualStudio7Generator::LocalGenerate()
  580. {
  581. this->cmGlobalGenerator::LocalGenerate();
  582. }
  583. std::vector<std::string> *cmGlobalVisualStudio7Generator::GetConfigurations()
  584. {
  585. return &m_Configurations;
  586. };
  587. //----------------------------------------------------------------------------
  588. void cmGlobalVisualStudio7Generator::GetDocumentation(cmDocumentationEntry& entry) const
  589. {
  590. entry.name = this->GetName();
  591. entry.brief = "Generates Visual Studio .NET 2002 project files.";
  592. entry.full = "";
  593. }
  594. // populate the m_SubProjectMap
  595. void cmGlobalVisualStudio7Generator::CollectSubprojects()
  596. {
  597. unsigned int i;
  598. for(i = 0; i < m_LocalGenerators.size(); ++i)
  599. {
  600. std::string name = m_LocalGenerators[i]->GetMakefile()->GetProjectName();
  601. m_SubProjectMap[name].push_back(m_LocalGenerators[i]);
  602. std::vector<std::string> const& pprojects
  603. = m_LocalGenerators[i]->GetMakefile()->GetParentProjects();
  604. for(unsigned int k =0; k < pprojects.size(); ++k)
  605. {
  606. m_SubProjectMap[pprojects[k]].push_back(m_LocalGenerators[i]);
  607. }
  608. }
  609. }