cmGlobalVisualStudio9Generator.cxx 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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 "cmMessageType.h"
  8. #include "cmVisualStudioWCEPlatformParser.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. std::vector<std::string> GetGeneratorNames() const override
  51. {
  52. std::vector<std::string> names;
  53. names.push_back(vs9generatorName);
  54. return names;
  55. }
  56. std::vector<std::string> GetGeneratorNamesWithPlatform() const override
  57. {
  58. std::vector<std::string> names;
  59. names.push_back(vs9generatorName + std::string(" Win64"));
  60. names.push_back(vs9generatorName + std::string(" IA64"));
  61. cmVisualStudioWCEPlatformParser parser;
  62. parser.ParseVersion("9.0");
  63. const std::vector<std::string>& availablePlatforms =
  64. parser.GetAvailablePlatforms();
  65. for (std::string const& i : availablePlatforms) {
  66. names.push_back("Visual Studio 9 2008 " + i);
  67. }
  68. return names;
  69. }
  70. bool SupportsToolset() const override { return false; }
  71. bool SupportsPlatform() const override { return true; }
  72. std::vector<std::string> GetKnownPlatforms() const override
  73. {
  74. std::vector<std::string> platforms;
  75. platforms.emplace_back("x64");
  76. platforms.emplace_back("Win32");
  77. platforms.emplace_back("Itanium");
  78. cmVisualStudioWCEPlatformParser parser;
  79. parser.ParseVersion("9.0");
  80. const std::vector<std::string>& availablePlatforms =
  81. parser.GetAvailablePlatforms();
  82. for (std::string const& i : availablePlatforms) {
  83. platforms.emplace_back(i);
  84. }
  85. return platforms;
  86. }
  87. };
  88. cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory()
  89. {
  90. return new Factory;
  91. }
  92. cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(
  93. cmake* cm, const std::string& name,
  94. std::string const& platformInGeneratorName)
  95. : cmGlobalVisualStudio8Generator(cm, name, platformInGeneratorName)
  96. {
  97. this->Version = VS9;
  98. std::string vc9Express;
  99. this->ExpressEdition = cmSystemTools::ReadRegistryValue(
  100. "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\9.0\\Setup\\VC;"
  101. "ProductDir",
  102. vc9Express, cmSystemTools::KeyWOW64_32);
  103. }
  104. std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory()
  105. {
  106. std::string base;
  107. std::string path;
  108. // base begins with the VisualStudioProjectsLocation reg value...
  109. if (cmSystemTools::ReadRegistryValue(
  110. "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\9.0;"
  111. "VisualStudioProjectsLocation",
  112. base)) {
  113. cmSystemTools::ConvertToUnixSlashes(base);
  114. // 9.0 macros folder:
  115. path = base + "/VSMacros80";
  116. // *NOT* a typo; right now in Visual Studio 2008 beta the macros
  117. // folder is VSMacros80... They may change it to 90 before final
  118. // release of 2008 or they may not... we'll have to keep our eyes
  119. // on it
  120. }
  121. // path is (correctly) still empty if we did not read the base value from
  122. // the Registry value
  123. return path;
  124. }
  125. std::string cmGlobalVisualStudio9Generator::GetUserMacrosRegKeyBase()
  126. {
  127. return "Software\\Microsoft\\VisualStudio\\9.0\\vsmacros";
  128. }