cmGlobalVisualStudio9Generator.cxx 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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->PlatformName = p;
  56. ret->WindowsCEVersion = parser.GetOSVersion();
  57. return ret;
  58. }
  59. virtual void GetDocumentation(cmDocumentationEntry& entry) const {
  60. entry.Name = vs9generatorName;
  61. entry.Brief = "Generates Visual Studio 9 2008 project files.";
  62. entry.Full =
  63. "It is possible to append a space followed by the platform name "
  64. "to create project files for a specific target platform. E.g. "
  65. "\"Visual Studio 9 2008 Win64\" will create project files for "
  66. "the x64 processor; \"Visual Studio 9 2008 IA64\" for Itanium.";
  67. }
  68. virtual void GetGenerators(std::vector<std::string>& names) const {
  69. names.push_back(vs9generatorName);
  70. names.push_back(vs9generatorName + std::string(" Win64"));
  71. names.push_back(vs9generatorName + std::string(" IA64"));
  72. cmVisualStudioWCEPlatformParser parser;
  73. parser.ParseVersion("9.0");
  74. const std::vector<std::string>& availablePlatforms =
  75. parser.GetAvailablePlatforms();
  76. for(std::vector<std::string>::const_iterator i =
  77. availablePlatforms.begin(); i != availablePlatforms.end(); ++i)
  78. {
  79. names.push_back("Visual Studio 9 2008 " + *i);
  80. }
  81. }
  82. };
  83. //----------------------------------------------------------------------------
  84. cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory()
  85. {
  86. return new Factory;
  87. }
  88. //----------------------------------------------------------------------------
  89. cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(
  90. const char* name, const char* architectureId,
  91. const char* additionalPlatformDefinition)
  92. : cmGlobalVisualStudio8Generator(name, architectureId,
  93. additionalPlatformDefinition)
  94. {
  95. this->FindMakeProgramFile = "CMakeVS9FindMake.cmake";
  96. }
  97. //----------------------------------------------------------------------------
  98. void cmGlobalVisualStudio9Generator::WriteSLNHeader(std::ostream& fout)
  99. {
  100. fout << "Microsoft Visual Studio Solution File, Format Version 10.00\n";
  101. fout << "# Visual Studio 2008\n";
  102. }
  103. ///! Create a local generator appropriate to this Global Generator
  104. cmLocalGenerator *cmGlobalVisualStudio9Generator::CreateLocalGenerator()
  105. {
  106. cmLocalVisualStudio7Generator *lg
  107. = new cmLocalVisualStudio7Generator(cmLocalVisualStudioGenerator::VS9);
  108. lg->SetPlatformName(this->GetPlatformName());
  109. lg->SetExtraFlagTable(this->GetExtraFlagTableVS8());
  110. lg->SetGlobalGenerator(this);
  111. return lg;
  112. }
  113. //----------------------------------------------------------------------------
  114. void cmGlobalVisualStudio9Generator
  115. ::EnableLanguage(std::vector<std::string>const & lang,
  116. cmMakefile *mf, bool optional)
  117. {
  118. cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional);
  119. }
  120. //----------------------------------------------------------------------------
  121. std::string cmGlobalVisualStudio9Generator::GetUserMacrosDirectory()
  122. {
  123. std::string base;
  124. std::string path;
  125. // base begins with the VisualStudioProjectsLocation reg value...
  126. if (cmSystemTools::ReadRegistryValue(
  127. "HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\9.0;"
  128. "VisualStudioProjectsLocation",
  129. base))
  130. {
  131. cmSystemTools::ConvertToUnixSlashes(base);
  132. // 9.0 macros folder:
  133. path = base + "/VSMacros80";
  134. // *NOT* a typo; right now in Visual Studio 2008 beta the macros
  135. // folder is VSMacros80... They may change it to 90 before final
  136. // release of 2008 or they may not... we'll have to keep our eyes
  137. // on it
  138. }
  139. // path is (correctly) still empty if we did not read the base value from
  140. // the Registry value
  141. return path;
  142. }
  143. //----------------------------------------------------------------------------
  144. std::string cmGlobalVisualStudio9Generator::GetUserMacrosRegKeyBase()
  145. {
  146. return "Software\\Microsoft\\VisualStudio\\9.0\\vsmacros";
  147. }