cmGlobalVisualStudio9Generator.cxx 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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(const char* name) const {
  22. if(strstr(name, vs9generatorName) != name)
  23. {
  24. return 0;
  25. }
  26. const char* p = name + sizeof(vs9generatorName) - 1;
  27. if(p[0] == '\0')
  28. {
  29. return new cmGlobalVisualStudio9Generator(
  30. name, NULL, NULL);
  31. }
  32. if(p[0] != ' ')
  33. {
  34. return 0;
  35. }
  36. ++p;
  37. if(!strcmp(p, "IA64"))
  38. {
  39. return new cmGlobalVisualStudio9Generator(
  40. name, "Itanium", "CMAKE_FORCE_IA64");
  41. }
  42. if(!strcmp(p, "Win64"))
  43. {
  44. return new cmGlobalVisualStudio9Generator(
  45. name, "x64", "CMAKE_FORCE_WIN64");
  46. }
  47. cmVisualStudioWCEPlatformParser parser(p);
  48. parser.ParseVersion("9.0");
  49. if (!parser.Found())
  50. {
  51. return 0;
  52. }
  53. cmGlobalVisualStudio9Generator* ret = new cmGlobalVisualStudio9Generator(
  54. name, p, NULL);
  55. ret->WindowsCEVersion = parser.GetOSVersion();
  56. return ret;
  57. }
  58. virtual void GetDocumentation(cmDocumentationEntry& entry) const {
  59. entry.Name = vs9generatorName;
  60. entry.Brief = "Generates Visual Studio 9 2008 project files.";
  61. }
  62. virtual void GetGenerators(std::vector<std::string>& names) const {
  63. names.push_back(vs9generatorName);
  64. names.push_back(vs9generatorName + std::string(" Win64"));
  65. names.push_back(vs9generatorName + std::string(" IA64"));
  66. cmVisualStudioWCEPlatformParser parser;
  67. parser.ParseVersion("9.0");
  68. const std::vector<std::string>& availablePlatforms =
  69. parser.GetAvailablePlatforms();
  70. for(std::vector<std::string>::const_iterator i =
  71. availablePlatforms.begin(); i != availablePlatforms.end(); ++i)
  72. {
  73. names.push_back("Visual Studio 9 2008 " + *i);
  74. }
  75. }
  76. };
  77. //----------------------------------------------------------------------------
  78. cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory()
  79. {
  80. return new Factory;
  81. }
  82. //----------------------------------------------------------------------------
  83. cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(
  84. const char* name, const char* platformName,
  85. const char* additionalPlatformDefinition)
  86. : cmGlobalVisualStudio8Generator(name, platformName,
  87. additionalPlatformDefinition)
  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->SetPlatformName(this->GetPlatformName());
  102. lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
  103. lg->SetGlobalGenerator(this);
  104. return lg;
  105. }
  106. //----------------------------------------------------------------------------
  107. void cmGlobalVisualStudio9Generator
  108. ::EnableLanguage(std::vector<std::string>const & lang,
  109. cmMakefile *mf, bool optional)
  110. {
  111. cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional);
  112. }
  113. //----------------------------------------------------------------------------
  114. std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory()
  115. {
  116. std::string base;
  117. std::string path;
  118. // base begins with the VisualStudioProjectsLocation reg value...
  119. if (cmSystemTools::ReadRegistryValue(
  120. "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\9.0;"
  121. "VisualStudioProjectsLocation",
  122. base))
  123. {
  124. cmSystemTools::ConvertToUnixSlashes(base);
  125. // 9.0 macros folder:
  126. path = base + "/VSMacros80";
  127. // *NOT* a typo; right now in Visual Studio 2008 beta the macros
  128. // folder is VSMacros80... They may change it to 90 before final
  129. // release of 2008 or they may not... we'll have to keep our eyes
  130. // on it
  131. }
  132. // path is (correctly) still empty if we did not read the base value from
  133. // the Registry value
  134. return path;
  135. }
  136. //----------------------------------------------------------------------------
  137. std::string cmGlobalVisualStudio9Generator::GetUserMacrosRegKeyBase()
  138. {
  139. return "Software\\Microsoft\\VisualStudio\\9.0\\vsmacros";
  140. }