cmGlobalVisualStudio9Generator.cxx 4.5 KB

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