cmGlobalVisualStudio9Generator.cxx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 = std::string(vs9generatorName) + " [arch]";
  62. entry.Brief =
  63. "Generates Visual Studio 2008 project files. "
  64. "Optional [arch] can be \"Win64\" or \"IA64\"."
  65. ;
  66. }
  67. virtual void GetGenerators(std::vector<std::string>& names) const {
  68. names.push_back(vs9generatorName);
  69. names.push_back(vs9generatorName + std::string(" Win64"));
  70. names.push_back(vs9generatorName + std::string(" IA64"));
  71. cmVisualStudioWCEPlatformParser parser;
  72. parser.ParseVersion("9.0");
  73. const std::vector<std::string>& availablePlatforms =
  74. parser.GetAvailablePlatforms();
  75. for(std::vector<std::string>::const_iterator i =
  76. availablePlatforms.begin(); i != availablePlatforms.end(); ++i)
  77. {
  78. names.push_back("Visual Studio 9 2008 " + *i);
  79. }
  80. }
  81. };
  82. //----------------------------------------------------------------------------
  83. cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory()
  84. {
  85. return new Factory;
  86. }
  87. //----------------------------------------------------------------------------
  88. cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(
  89. const std::string& name, const std::string& platformName)
  90. : cmGlobalVisualStudio8Generator(name, platformName)
  91. {
  92. }
  93. //----------------------------------------------------------------------------
  94. void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout)
  95. {
  96. fout << "Microsoft Visual Studio Solution File, Format Version 10.00\n";
  97. fout << "# Visual Studio 2008\n";
  98. }
  99. ///! Create a local generator appropriate to this Global Generator
  100. cmLocalGenerator *
  101. cmGlobalVisualStudio9Generator::CreateLocalGenerator(cmLocalGenerator* parent)
  102. {
  103. cmLocalVisualStudio7Generator *lg
  104. = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9,
  105. this, parent);
  106. return lg;
  107. }
  108. //----------------------------------------------------------------------------
  109. std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory()
  110. {
  111. std::string base;
  112. std::string path;
  113. // base begins with the VisualStudioProjectsLocation reg value...
  114. if (cmSystemTools::ReadRegistryValue(
  115. "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\9.0;"
  116. "VisualStudioProjectsLocation",
  117. base))
  118. {
  119. cmSystemTools::ConvertToUnixSlashes(base);
  120. // 9.0 macros folder:
  121. path = base + "/VSMacros80";
  122. // *NOT* a typo; right now in Visual Studio 2008 beta the macros
  123. // folder is VSMacros80... They may change it to 90 before final
  124. // release of 2008 or they may not... we'll have to keep our eyes
  125. // on it
  126. }
  127. // path is (correctly) still empty if we did not read the base value from
  128. // the Registry value
  129. return path;
  130. }
  131. //----------------------------------------------------------------------------
  132. std::string cmGlobalVisualStudio9Generator::GetUserMacrosRegKeyBase()
  133. {
  134. return "Software\\Microsoft\\VisualStudio\\9.0\\vsmacros";
  135. }