cmGlobalVisualStudio12Generator.cxx 4.1 KB

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