cmGlobalVisualStudio14Generator.cxx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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", "CMAKE_FORCE_WIN64");
  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. const std::string& additionalPlatformDefinition)
  67. : cmGlobalVisualStudio12Generator(name, platformName,
  68. additionalPlatformDefinition)
  69. {
  70. std::string vc14Express;
  71. this->ExpressEdition = cmSystemTools::ReadRegistryValue(
  72. "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\14.0\\Setup\\VC;"
  73. "ProductDir", vc14Express, cmSystemTools::KeyWOW64_32);
  74. this->DefaultPlatformToolset = "v140";
  75. }
  76. //----------------------------------------------------------------------------
  77. bool
  78. cmGlobalVisualStudio14Generator::MatchesGeneratorName(
  79. const std::string& name) const
  80. {
  81. return name == this->GetName();
  82. }
  83. //----------------------------------------------------------------------------
  84. void cmGlobalVisualStudio14Generator::WriteSLNHeader(std::ostream& fout)
  85. {
  86. // Visual Studio 14 writes .sln format 12.00
  87. fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
  88. if (this->ExpressEdition)
  89. {
  90. fout << "# Visual Studio Express 14 for Windows Desktop\n";
  91. }
  92. else
  93. {
  94. fout << "# Visual Studio 14\n";
  95. }
  96. }
  97. //----------------------------------------------------------------------------
  98. cmLocalGenerator *cmGlobalVisualStudio14Generator::CreateLocalGenerator()
  99. {
  100. cmLocalVisualStudio10Generator* lg =
  101. new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS14);
  102. lg->SetPlatformName(this->GetPlatformName());
  103. lg->SetGlobalGenerator(this);
  104. return lg;
  105. }