cmGlobalVisualStudio9Generator.cxx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmGlobalVisualStudio9Generator.h"
  4. #include "cmDocumentationEntry.h"
  5. #include "cmLocalVisualStudio7Generator.h"
  6. #include "cmMakefile.h"
  7. #include "cmVisualStudioWCEPlatformParser.h"
  8. #include "cmake.h"
  9. static const char vs9generatorName[] = "Visual Studio 9 2008";
  10. class cmGlobalVisualStudio9Generator::Factory : public cmGlobalGeneratorFactory
  11. {
  12. public:
  13. cmGlobalGenerator* CreateGlobalGenerator(const std::string& name,
  14. cmake* cm) const override
  15. {
  16. if (strncmp(name.c_str(), vs9generatorName,
  17. sizeof(vs9generatorName) - 1) != 0) {
  18. return 0;
  19. }
  20. const char* p = name.c_str() + sizeof(vs9generatorName) - 1;
  21. if (p[0] == '\0') {
  22. return new cmGlobalVisualStudio9Generator(cm, name, "");
  23. }
  24. if (p[0] != ' ') {
  25. return 0;
  26. }
  27. ++p;
  28. if (!strcmp(p, "IA64")) {
  29. return new cmGlobalVisualStudio9Generator(cm, name, "Itanium");
  30. }
  31. if (!strcmp(p, "Win64")) {
  32. return new cmGlobalVisualStudio9Generator(cm, name, "x64");
  33. }
  34. cmVisualStudioWCEPlatformParser parser(p);
  35. parser.ParseVersion("9.0");
  36. if (!parser.Found()) {
  37. return 0;
  38. }
  39. cmGlobalVisualStudio9Generator* ret =
  40. new cmGlobalVisualStudio9Generator(cm, name, p);
  41. ret->WindowsCEVersion = parser.GetOSVersion();
  42. return ret;
  43. }
  44. void GetDocumentation(cmDocumentationEntry& entry) const override
  45. {
  46. entry.Name = std::string(vs9generatorName) + " [arch]";
  47. entry.Brief = "Generates Visual Studio 2008 project files. "
  48. "Optional [arch] can be \"Win64\" or \"IA64\".";
  49. }
  50. void GetGenerators(std::vector<std::string>& names) const override
  51. {
  52. names.push_back(vs9generatorName);
  53. names.push_back(vs9generatorName + std::string(" Win64"));
  54. names.push_back(vs9generatorName + std::string(" IA64"));
  55. cmVisualStudioWCEPlatformParser parser;
  56. parser.ParseVersion("9.0");
  57. const std::vector<std::string>& availablePlatforms =
  58. parser.GetAvailablePlatforms();
  59. for (std::string const& i : availablePlatforms) {
  60. names.push_back("Visual Studio 9 2008 " + i);
  61. }
  62. }
  63. bool SupportsToolset() const override { return false; }
  64. bool SupportsPlatform() const override { return true; }
  65. };
  66. cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory()
  67. {
  68. return new Factory;
  69. }
  70. cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(
  71. cmake* cm, const std::string& name, const std::string& platformName)
  72. : cmGlobalVisualStudio8Generator(cm, name, platformName)
  73. {
  74. this->Version = VS9;
  75. std::string vc9Express;
  76. this->ExpressEdition = cmSystemTools::ReadRegistryValue(
  77. "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\9.0\\Setup\\VC;"
  78. "ProductDir",
  79. vc9Express, cmSystemTools::KeyWOW64_32);
  80. }
  81. void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout)
  82. {
  83. fout << "Microsoft Visual Studio Solution File, Format Version 10.00\n";
  84. fout << "# Visual Studio 2008\n";
  85. }
  86. std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory()
  87. {
  88. std::string base;
  89. std::string path;
  90. // base begins with the VisualStudioProjectsLocation reg value...
  91. if (cmSystemTools::ReadRegistryValue(
  92. "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\9.0;"
  93. "VisualStudioProjectsLocation",
  94. base)) {
  95. cmSystemTools::ConvertToUnixSlashes(base);
  96. // 9.0 macros folder:
  97. path = base + "/VSMacros80";
  98. // *NOT* a typo; right now in Visual Studio 2008 beta the macros
  99. // folder is VSMacros80... They may change it to 90 before final
  100. // release of 2008 or they may not... we'll have to keep our eyes
  101. // on it
  102. }
  103. // path is (correctly) still empty if we did not read the base value from
  104. // the Registry value
  105. return path;
  106. }
  107. std::string cmGlobalVisualStudio9Generator::GetUserMacrosRegKeyBase()
  108. {
  109. return "Software\\Microsoft\\VisualStudio\\9.0\\vsmacros";
  110. }