cmGlobalVisualStudio9Generator.cxx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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, parser.GetArchitectureFamily(), 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. entry.Full =
  62. "It is possible to append a space followed by the platform name "
  63. "to create project files for a specific target platform. E.g. "
  64. "\"Visual Studio 9 2008 Win64\" will create project files for "
  65. "the x64 processor; \"Visual Studio 9 2008 IA64\" for Itanium.";
  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 char* name, const char* architectureId,
  90. const char* additionalPlatformDefinition)
  91. : cmGlobalVisualStudio8Generator(name, architectureId,
  92. additionalPlatformDefinition)
  93. {
  94. this->FindMakeProgramFile = "CMakeVS9FindMake.cmake";
  95. }
  96. //----------------------------------------------------------------------------
  97. void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout)
  98. {
  99. fout << "Microsoft Visual Studio Solution File, Format Version 10.00\n";
  100. fout << "# Visual Studio 2008\n";
  101. }
  102. ///! Create a local generator appropriate to this Global Generator
  103. cmLocalGenerator *cmGlobalVisualStudio9Generator::CreateLocalGenerator()
  104. {
  105. cmLocalVisualStudio7Generator *lg
  106. = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9);
  107. lg->SetPlatformName(this->GetPlatformName());
  108. lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
  109. lg->SetGlobalGenerator(this);
  110. return lg;
  111. }
  112. //----------------------------------------------------------------------------
  113. void cmGlobalVisualStudio9Generator
  114. ::EnableLanguage(std::vector<std::string>const & lang,
  115. cmMakefile *mf, bool optional)
  116. {
  117. cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional);
  118. }
  119. //----------------------------------------------------------------------------
  120. std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory()
  121. {
  122. std::string base;
  123. std::string path;
  124. // base begins with the VisualStudioProjectsLocation reg value...
  125. if (cmSystemTools::ReadRegistryValue(
  126. "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\9.0;"
  127. "VisualStudioProjectsLocation",
  128. base))
  129. {
  130. cmSystemTools::ConvertToUnixSlashes(base);
  131. // 9.0 macros folder:
  132. path = base + "/VSMacros80";
  133. // *NOT* a typo; right now in Visual Studio 2008 beta the macros
  134. // folder is VSMacros80... They may change it to 90 before final
  135. // release of 2008 or they may not... we'll have to keep our eyes
  136. // on it
  137. }
  138. // path is (correctly) still empty if we did not read the base value from
  139. // the Registry value
  140. return path;
  141. }
  142. //----------------------------------------------------------------------------
  143. std::string cmGlobalVisualStudio9Generator::GetUserMacrosRegKeyBase()
  144. {
  145. return "Software\\Microsoft\\VisualStudio\\9.0\\vsmacros";
  146. }