Imported Upstream version 2.8.9
[platform/upstream/cmake.git] / Source / cmGlobalMinGWMakefileGenerator.cxx
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 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 "cmGlobalMinGWMakefileGenerator.h"
13 #include "cmLocalUnixMakefileGenerator3.h"
14 #include "cmMakefile.h"
15
16 cmGlobalMinGWMakefileGenerator::cmGlobalMinGWMakefileGenerator()
17 {
18   this->FindMakeProgramFile = "CMakeMinGWFindMake.cmake";
19   this->ForceUnixPaths = true;
20   this->ToolSupportsColor = true;
21   this->UseLinkScript = true;
22 }
23
24 void cmGlobalMinGWMakefileGenerator
25 ::EnableLanguage(std::vector<std::string>const& l, 
26                  cmMakefile *mf, 
27                  bool optional)
28
29   this->FindMakeProgram(mf);
30   std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
31   std::vector<std::string> locations;
32   locations.push_back(cmSystemTools::GetProgramPath(makeProgram.c_str()));
33   locations.push_back("/mingw/bin");
34   locations.push_back("c:/mingw/bin");
35   std::string tgcc = cmSystemTools::FindProgram("gcc", locations);
36   std::string gcc = "gcc.exe";
37   if(tgcc.size())
38     {
39     gcc = tgcc;
40     }
41   std::string tgxx = cmSystemTools::FindProgram("g++", locations);
42   std::string gxx = "g++.exe";
43   if(tgxx.size())
44     {
45     gxx = tgxx;
46     }
47   std::string trc = cmSystemTools::FindProgram("windres", locations);
48   std::string rc = "windres.exe";
49   if(trc.size())
50     {
51     rc = trc;
52     }
53   mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str());
54   mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str());
55   mf->AddDefinition("CMAKE_GENERATOR_RC", rc.c_str());
56   this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
57 }
58
59 ///! Create a local generator appropriate to this Global Generator
60 cmLocalGenerator *cmGlobalMinGWMakefileGenerator::CreateLocalGenerator()
61 {
62   cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3;
63   lg->SetWindowsShell(true);
64   lg->SetGlobalGenerator(this);
65   lg->SetIgnoreLibPrefix(true);
66   lg->SetPassMakeflags(false);
67   lg->SetUnixCD(true);
68   lg->SetMinGWMake(true);
69   return lg;
70 }
71
72 //----------------------------------------------------------------------------
73 void cmGlobalMinGWMakefileGenerator
74 ::GetDocumentation(cmDocumentationEntry& entry) const
75 {
76   entry.Name = this->GetName();
77   entry.Brief = "Generates a make file for use with mingw32-make.";
78   entry.Full = "The makefiles generated use cmd.exe as the shell.  "
79     "They do not require msys or a unix shell.";
80 }