Imported Upstream version 2.8.12.2
[platform/upstream/cmake.git] / Source / cmGlobalVisualStudio12Generator.cxx
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #include "cmGlobalVisualStudio12Generator.h"
13 #include "cmLocalVisualStudio10Generator.h"
14 #include "cmMakefile.h"
15
16 static const char vs12Win32generatorName[] = "Visual Studio 12";
17 static const char vs12Win64generatorName[] = "Visual Studio 12 Win64";
18 static const char vs12ARMgeneratorName[] = "Visual Studio 12 ARM";
19
20 class cmGlobalVisualStudio12Generator::Factory
21   : public cmGlobalGeneratorFactory
22 {
23 public:
24   virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const {
25     if(!strcmp(name, vs12Win32generatorName))
26       {
27       return new cmGlobalVisualStudio12Generator(
28         name, NULL, NULL);
29       }
30     if(!strcmp(name, vs12Win64generatorName))
31       {
32       return new cmGlobalVisualStudio12Generator(
33         name, "x64", "CMAKE_FORCE_WIN64");
34       }
35     if(!strcmp(name, vs12ARMgeneratorName))
36       {
37       return new cmGlobalVisualStudio12Generator(
38         name, "ARM", NULL);
39       }
40     return 0;
41   }
42
43   virtual void GetDocumentation(cmDocumentationEntry& entry) const {
44     entry.Name = "Visual Studio 12";
45     entry.Brief = "Generates Visual Studio 12 (2013) project files.";
46     entry.Full =
47       "It is possible to append a space followed by the platform name "
48       "to create project files for a specific target platform. E.g. "
49       "\"Visual Studio 12 Win64\" will create project files for "
50       "the x64 processor; \"Visual Studio 12 ARM\" for ARM.";
51   }
52
53   virtual void GetGenerators(std::vector<std::string>& names) const {
54     names.push_back(vs12Win32generatorName);
55     names.push_back(vs12Win64generatorName);
56     names.push_back(vs12ARMgeneratorName); }
57 };
58
59 //----------------------------------------------------------------------------
60 cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory()
61 {
62   return new Factory;
63 }
64
65 //----------------------------------------------------------------------------
66 cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator(
67   const char* name, const char* platformName,
68   const char* additionalPlatformDefinition)
69   : cmGlobalVisualStudio11Generator(name, platformName,
70                                    additionalPlatformDefinition)
71 {
72   this->FindMakeProgramFile = "CMakeVS12FindMake.cmake";
73   std::string vc12Express;
74   this->ExpressEdition = cmSystemTools::ReadRegistryValue(
75     "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VCExpress\\12.0\\Setup\\VC;"
76     "ProductDir", vc12Express, cmSystemTools::KeyWOW64_32);
77   this->PlatformToolset = "v120";
78 }
79
80 //----------------------------------------------------------------------------
81 void cmGlobalVisualStudio12Generator::WriteSLNHeader(std::ostream& fout)
82 {
83   fout << "Microsoft Visual Studio Solution File, Format Version 12.00\n";
84   if (this->ExpressEdition)
85     {
86     fout << "# Visual Studio Express 2013 for Windows Desktop\n";
87     }
88   else
89     {
90     fout << "# Visual Studio 2013\n";
91     }
92 }
93
94 //----------------------------------------------------------------------------
95 cmLocalGenerator *cmGlobalVisualStudio12Generator::CreateLocalGenerator()
96 {
97   cmLocalVisualStudio10Generator* lg =
98     new cmLocalVisualStudio10Generator(cmLocalVisualStudioGenerator::VS12);
99   lg->SetPlatformName(this->GetPlatformName());
100   lg->SetGlobalGenerator(this);
101   return lg;
102 }