cmGlobalVisualStudio14Generator.cxx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2014 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 "cmGlobalVisualStudio14Generator.h"
  11. #include "cmLocalVisualStudio10Generator.h"
  12. #include "cmMakefile.h"
  13. static const char vs14generatorName[] = "Visual Studio 14 2015";
  14. // Map generator name without year to name with year.
  15. static const char* cmVS14GenName(const std::string& name, std::string& genName)
  16. {
  17. if(strncmp(name.c_str(), vs14generatorName,
  18. sizeof(vs14generatorName)-6) != 0)
  19. {
  20. return 0;
  21. }
  22. const char* p = name.c_str() + sizeof(vs14generatorName) - 6;
  23. if(cmHasLiteralPrefix(p, " 2015"))
  24. {
  25. p += 5;
  26. }
  27. genName = std::string(vs14generatorName) + p;
  28. return p;
  29. }
  30. class cmGlobalVisualStudio14Generator::Factory
  31. : public cmGlobalGeneratorFactory
  32. {
  33. public:
  34. virtual cmGlobalGenerator* CreateGlobalGenerator(
  35. const std::string& name) const
  36. {
  37. std::string genName;
  38. const char* p = cmVS14GenName(name, genName);
  39. if(!p)
  40. { return 0; }
  41. if(!*p)
  42. {
  43. return new cmGlobalVisualStudio14Generator(
  44. genName, "");
  45. }
  46. if(*p++ != ' ')
  47. { return 0; }
  48. if(strcmp(p, "Win64") == 0)
  49. {
  50. return new cmGlobalVisualStudio14Generator(
  51. genName, "x64");
  52. }
  53. if(strcmp(p, "ARM") == 0)
  54. {
  55. return new cmGlobalVisualStudio14Generator(
  56. genName, "ARM");
  57. }
  58. return 0;
  59. }
  60. virtual void GetDocumentation(cmDocumentationEntry& entry) const
  61. {
  62. entry.Name = vs14generatorName;
  63. entry.Brief = "Generates Visual Studio 14 (VS 2015) project files.";
  64. }
  65. virtual void GetGenerators(std::vector<std::string>& names) const
  66. {
  67. names.push_back(vs14generatorName);
  68. names.push_back(vs14generatorName + std::string(" ARM"));
  69. names.push_back(vs14generatorName + std::string(" Win64"));
  70. }
  71. };
  72. //----------------------------------------------------------------------------
  73. cmGlobalGeneratorFactory* cmGlobalVisualStudio14Generator::NewFactory()
  74. {
  75. return new Factory;
  76. }
  77. //----------------------------------------------------------------------------
  78. cmGlobalVisualStudio14Generator::cmGlobalVisualStudio14Generator(
  79. const std::string& name, const std::string& platformName)
  80. : cmGlobalVisualStudio12Generator(name, platformName)
  81. {
  82. std::string vc14Express;
  83. this->ExpressEdition = cmSystemTools::ReadRegistryValue(
  84. "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\14.0\\Setup\\VC;"
  85. "ProductDir", vc14Express, cmSystemTools::KeyWOW64_32);
  86. this->DefaultPlatformToolset = "v140";
  87. }
  88. //----------------------------------------------------------------------------
  89. bool
  90. cmGlobalVisualStudio14Generator::MatchesGeneratorName(
  91. const std::string& name) const
  92. {
  93. std::string genName;
  94. if(cmVS14GenName(name, genName))
  95. {
  96. return genName == this->GetName();
  97. }
  98. return false;
  99. }
  100. //----------------------------------------------------------------------------
  101. void cmGlobalVisualStudio14Generator::WriteSLNHeader(std::ostream& fout)
  102. {
  103. // Visual Studio 14 writes .sln format 12.00
  104. fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
  105. if (this->ExpressEdition)
  106. {
  107. fout << "# Visual Studio Express 14 for Windows Desktop\n";
  108. }
  109. else
  110. {
  111. fout << "# Visual Studio 14\n";
  112. }
  113. }
  114. //----------------------------------------------------------------------------
  115. cmLocalGenerator *cmGlobalVisualStudio14Generator::CreateLocalGenerator()
  116. {
  117. cmLocalVisualStudio10Generator* lg =
  118. new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS14);
  119. lg->SetGlobalGenerator(this);
  120. return lg;
  121. }