1
0

cmGlobalVisualStudio11Generator.cxx 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2011 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 "cmGlobalVisualStudio11Generator.h"
  11. #include "cmLocalVisualStudio10Generator.h"
  12. #include "cmMakefile.h"
  13. static const char vs11generatorName[] = "Visual Studio 11";
  14. class cmGlobalVisualStudio11Generator::Factory
  15. : public cmGlobalGeneratorFactory
  16. {
  17. public:
  18. virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const {
  19. if(strstr(name, vs11generatorName) != name)
  20. {
  21. return 0;
  22. }
  23. const char* p = name + sizeof(vs11generatorName) - 1;
  24. if(p[0] == '\0')
  25. {
  26. return new cmGlobalVisualStudio11Generator(
  27. name, NULL, NULL);
  28. }
  29. if(p[0] != ' ')
  30. {
  31. return 0;
  32. }
  33. ++p;
  34. if(!strcmp(p, "ARM"))
  35. {
  36. return new cmGlobalVisualStudio11Generator(
  37. name, "ARM", NULL);
  38. }
  39. if(!strcmp(p, "Win64"))
  40. {
  41. return new cmGlobalVisualStudio11Generator(
  42. name, "x64", "CMAKE_FORCE_WIN64");
  43. }
  44. std::set<std::string> installedSDKs =
  45. cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs();
  46. if(installedSDKs.find(p) == installedSDKs.end())
  47. {
  48. return 0;
  49. }
  50. cmGlobalVisualStudio11Generator* ret =
  51. new cmGlobalVisualStudio11Generator(name, p, NULL);
  52. ret->WindowsCEVersion = "8.00";
  53. return ret;
  54. }
  55. virtual void GetDocumentation(cmDocumentationEntry& entry) const {
  56. entry.Name = "Visual Studio 11";
  57. entry.Brief = "Generates Visual Studio 11 (2012) project files.";
  58. entry.Full =
  59. "It is possible to append a space followed by the platform name "
  60. "to create project files for a specific target platform. E.g. "
  61. "\"Visual Studio 11 Win64\" will create project files for "
  62. "the x64 processor; \"Visual Studio 11 ARM\" for ARM.";
  63. }
  64. virtual void GetGenerators(std::vector<std::string>& names) const {
  65. names.push_back(vs11generatorName);
  66. names.push_back(vs11generatorName + std::string(" ARM"));
  67. names.push_back(vs11generatorName + std::string(" Win64"));
  68. std::set<std::string> installedSDKs =
  69. cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs();
  70. for(std::set<std::string>::const_iterator i =
  71. installedSDKs.begin(); i != installedSDKs.end(); ++i)
  72. {
  73. names.push_back("Visual Studio 11 " + *i);
  74. }
  75. }
  76. };
  77. //----------------------------------------------------------------------------
  78. cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory()
  79. {
  80. return new Factory;
  81. }
  82. //----------------------------------------------------------------------------
  83. cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator(
  84. const char* name, const char* platformName,
  85. const char* additionalPlatformDefinition)
  86. : cmGlobalVisualStudio10Generator(name, platformName,
  87. additionalPlatformDefinition)
  88. {
  89. this->FindMakeProgramFile = "CMakeVS11FindMake.cmake";
  90. std::string vc11Express;
  91. this->ExpressEdition = cmSystemTools::ReadRegistryValue(
  92. "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\11.0\\Setup\\VC;"
  93. "ProductDir", vc11Express, cmSystemTools::KeyWOW64_32);
  94. this->PlatformToolset = "v110";
  95. }
  96. //----------------------------------------------------------------------------
  97. void cmGlobalVisualStudio11Generator::WriteSLNHeader(std::ostream& fout)
  98. {
  99. fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
  100. if (this->ExpressEdition)
  101. {
  102. fout << "# Visual Studio Express 2012 for Windows Desktop\n";
  103. }
  104. else
  105. {
  106. fout << "# Visual Studio 2012\n";
  107. }
  108. }
  109. //----------------------------------------------------------------------------
  110. cmLocalGenerator *cmGlobalVisualStudio11Generator::CreateLocalGenerator()
  111. {
  112. cmLocalVisualStudio10Generator* lg =
  113. new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS11);
  114. lg->SetPlatformName(this->GetPlatformName());
  115. lg->SetGlobalGenerator(this);
  116. return lg;
  117. }
  118. //----------------------------------------------------------------------------
  119. bool cmGlobalVisualStudio11Generator::UseFolderProperty()
  120. {
  121. // Intentionally skip over the parent class implementation and call the
  122. // grand-parent class's implementation. Folders are not supported by the
  123. // Express editions in VS10 and earlier, but they are in VS11 Express.
  124. return cmGlobalVisualStudio8Generator::UseFolderProperty();
  125. }
  126. //----------------------------------------------------------------------------
  127. std::set<std::string>
  128. cmGlobalVisualStudio11Generator::GetInstalledWindowsCESDKs()
  129. {
  130. const char sdksKey[] = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\"
  131. "Windows CE Tools\\SDKs";
  132. std::vector<std::string> subkeys;
  133. cmSystemTools::GetRegistrySubKeys(sdksKey, subkeys,
  134. cmSystemTools::KeyWOW64_32);
  135. std::set<std::string> ret;
  136. for(std::vector<std::string>::const_iterator i =
  137. subkeys.begin(); i != subkeys.end(); ++i)
  138. {
  139. std::string key = sdksKey;
  140. key += '\\';
  141. key += *i;
  142. key += ';';
  143. std::string path;
  144. if(cmSystemTools::ReadRegistryValue(key.c_str(),
  145. path,
  146. cmSystemTools::KeyWOW64_32) &&
  147. !path.empty())
  148. {
  149. ret.insert(*i);
  150. }
  151. }
  152. return ret;
  153. }