cmGlobalVisualStudio9Generator.cxx 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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
  18. : public cmGlobalGeneratorFactory
  19. {
  20. public:
  21. virtual cmGlobalGenerator* CreateGlobalGenerator(
  22. const std::string& name) const {
  23. if(strncmp(name.c_str(), vs9generatorName,
  24. sizeof(vs9generatorName) - 1) != 0)
  25. {
  26. return 0;
  27. }
  28. const char* p = name.c_str() + sizeof(vs9generatorName) - 1;
  29. if(p[0] == '\0')
  30. {
  31. return new cmGlobalVisualStudio9Generator(
  32. name, "");
  33. }
  34. if(p[0] != ' ')
  35. {
  36. return 0;
  37. }
  38. ++p;
  39. if(!strcmp(p, "IA64"))
  40. {
  41. return new cmGlobalVisualStudio9Generator(
  42. name, "Itanium");
  43. }
  44. if(!strcmp(p, "Win64"))
  45. {
  46. return new cmGlobalVisualStudio9Generator(
  47. name, "x64");
  48. }
  49. cmVisualStudioWCEPlatformParser parser(p);
  50. parser.ParseVersion("9.0");
  51. if (!parser.Found())
  52. {
  53. return 0;
  54. }
  55. cmGlobalVisualStudio9Generator* ret = new cmGlobalVisualStudio9Generator(
  56. name, p);
  57. ret->WindowsCEVersion = parser.GetOSVersion();
  58. return ret;
  59. }
  60. virtual void GetDocumentation(cmDocumentationEntry& entry) const {
  61. entry.Name = vs9generatorName;
  62. entry.Brief = "Generates Visual Studio 9 2008 project files.";
  63. }
  64. virtual void GetGenerators(std::vector<std::string>& names) const {
  65. names.push_back(vs9generatorName);
  66. names.push_back(vs9generatorName + std::string(" Win64"));
  67. names.push_back(vs9generatorName + std::string(" IA64"));
  68. cmVisualStudioWCEPlatformParser parser;
  69. parser.ParseVersion("9.0");
  70. const std::vector<std::string>& availablePlatforms =
  71. parser.GetAvailablePlatforms();
  72. for(std::vector<std::string>::const_iterator i =
  73. availablePlatforms.begin(); i != availablePlatforms.end(); ++i)
  74. {
  75. names.push_back("Visual Studio 9 2008 " + *i);
  76. }
  77. }
  78. };
  79. //----------------------------------------------------------------------------
  80. cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory()
  81. {
  82. return new Factory;
  83. }
  84. //----------------------------------------------------------------------------
  85. cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(
  86. const std::string& name, const std::string& platformName)
  87. : cmGlobalVisualStudio8Generator(name, platformName)
  88. {
  89. }
  90. //----------------------------------------------------------------------------
  91. void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout)
  92. {
  93. fout << "Microsoft Visual Studio Solution File, Format Version 10.00\n";
  94. fout << "# Visual Studio 2008\n";
  95. }
  96. ///! Create a local generator appropriate to this Global Generator
  97. cmLocalGenerator *cmGlobalVisualStudio9Generator::CreateLocalGenerator()
  98. {
  99. cmLocalVisualStudio7Generator *lg
  100. = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9);
  101. lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
  102. lg->SetGlobalGenerator(this);
  103. return lg;
  104. }
  105. //----------------------------------------------------------------------------
  106. std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory()
  107. {
  108. std::string base;
  109. std::string path;
  110. // base begins with the VisualStudioProjectsLocation reg value...
  111. if (cmSystemTools::ReadRegistryValue(
  112. "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\9.0;"
  113. "VisualStudioProjectsLocation",
  114. base))
  115. {
  116. cmSystemTools::ConvertToUnixSlashes(base);
  117. // 9.0 macros folder:
  118. path = base + "/VSMacros80";
  119. // *NOT* a typo; right now in Visual Studio 2008 beta the macros
  120. // folder is VSMacros80... They may change it to 90 before final
  121. // release of 2008 or they may not... we'll have to keep our eyes
  122. // on it
  123. }
  124. // path is (correctly) still empty if we did not read the base value from
  125. // the Registry value
  126. return path;
  127. }
  128. //----------------------------------------------------------------------------
  129. std::string cmGlobalVisualStudio9Generator::GetUserMacrosRegKeyBase()
  130. {
  131. return "Software\\Microsoft\\VisualStudio\\9.0\\vsmacros";
  132. }