cmGlobalVisualStudio14Generator.cxx 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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";
  14. class cmGlobalVisualStudio14Generator::Factory
  15. : public cmGlobalGeneratorFactory
  16. {
  17. public:
  18. virtual cmGlobalGenerator* CreateGlobalGenerator(
  19. const std::string& genName) const
  20. {
  21. if(strncmp(genName.c_str(), vs14generatorName,
  22. sizeof(vs14generatorName) - 1) != 0)
  23. {
  24. return 0;
  25. }
  26. const char* p = genName.c_str() + sizeof(vs14generatorName) - 1;
  27. if(!*p)
  28. {
  29. return new cmGlobalVisualStudio14Generator(
  30. genName, "");
  31. }
  32. if(*p++ != ' ')
  33. { return 0; }
  34. if(strcmp(p, "Win64") == 0)
  35. {
  36. return new cmGlobalVisualStudio14Generator(
  37. genName, "x64");
  38. }
  39. if(strcmp(p, "ARM") == 0)
  40. {
  41. return new cmGlobalVisualStudio14Generator(
  42. genName, "ARM");
  43. }
  44. return 0;
  45. }
  46. virtual void GetDocumentation(cmDocumentationEntry& entry) const
  47. {
  48. entry.Name = vs14generatorName;
  49. entry.Brief = "Generates Visual Studio 14 project files.";
  50. }
  51. virtual void GetGenerators(std::vector<std::string>& names) const
  52. {
  53. names.push_back(vs14generatorName);
  54. names.push_back(vs14generatorName + std::string(" ARM"));
  55. names.push_back(vs14generatorName + std::string(" Win64"));
  56. }
  57. };
  58. //----------------------------------------------------------------------------
  59. cmGlobalGeneratorFactory* cmGlobalVisualStudio14Generator::NewFactory()
  60. {
  61. return new Factory;
  62. }
  63. //----------------------------------------------------------------------------
  64. cmGlobalVisualStudio14Generator::cmGlobalVisualStudio14Generator(
  65. const std::string& name, const std::string& platformName)
  66. : cmGlobalVisualStudio12Generator(name, platformName)
  67. {
  68. std::string vc14Express;
  69. this->ExpressEdition = cmSystemTools::ReadRegistryValue(
  70. "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\14.0\\Setup\\VC;"
  71. "ProductDir", vc14Express, cmSystemTools::KeyWOW64_32);
  72. this->DefaultPlatformToolset = "v140";
  73. }
  74. //----------------------------------------------------------------------------
  75. bool
  76. cmGlobalVisualStudio14Generator::MatchesGeneratorName(
  77. const std::string& name) const
  78. {
  79. return name == this->GetName();
  80. }
  81. //----------------------------------------------------------------------------
  82. void cmGlobalVisualStudio14Generator::WriteSLNHeader(std::ostream& fout)
  83. {
  84. // Visual Studio 14 writes .sln format 12.00
  85. fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
  86. if (this->ExpressEdition)
  87. {
  88. fout << "# Visual Studio Express 14 for Windows Desktop\n";
  89. }
  90. else
  91. {
  92. fout << "# Visual Studio 14\n";
  93. }
  94. }
  95. //----------------------------------------------------------------------------
  96. cmLocalGenerator *cmGlobalVisualStudio14Generator::CreateLocalGenerator()
  97. {
  98. cmLocalVisualStudio10Generator* lg =
  99. new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS14);
  100. lg->SetGlobalGenerator(this);
  101. return lg;
  102. }