Initial commit.
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / cmGlobalMSYSMakefileGenerator.cxx
blobbf2c53c3f8ab06334fa63f95ee2a37e1939e0ed6
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmGlobalMSYSMakefileGenerator.cxx,v $
5 Language: C++
6 Date: $Date: 2007/10/22 16:48:39 $
7 Version: $Revision: 1.14 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmGlobalMSYSMakefileGenerator.h"
18 #include "cmLocalUnixMakefileGenerator3.h"
19 #include "cmMakefile.h"
20 #include "cmake.h"
22 cmGlobalMSYSMakefileGenerator::cmGlobalMSYSMakefileGenerator()
24 this->FindMakeProgramFile = "CMakeMSYSFindMake.cmake";
25 this->ForceUnixPaths = true;
26 this->ToolSupportsColor = true;
27 this->UseLinkScript = false;
30 std::string
31 cmGlobalMSYSMakefileGenerator::FindMinGW(std::string const& makeloc)
33 std::string fstab = makeloc;
34 fstab += "/../etc/fstab";
35 std::ifstream fin(fstab.c_str());
36 std::string path;
37 std::string mount;
38 std::string mingwBin;
39 while(fin)
41 fin >> path;
42 fin >> mount;
43 if(mount == "/mingw")
45 mingwBin = path;
46 mingwBin += "/bin";
49 return mingwBin;
52 void cmGlobalMSYSMakefileGenerator
53 ::EnableLanguage(std::vector<std::string>const& l,
54 cmMakefile *mf,
55 bool optional)
57 this->FindMakeProgram(mf);
58 std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
59 std::vector<std::string> locations;
60 std::string makeloc = cmSystemTools::GetProgramPath(makeProgram.c_str());
61 locations.push_back(this->FindMinGW(makeloc));
62 locations.push_back(makeloc);
63 locations.push_back("/mingw/bin");
64 locations.push_back("c:/mingw/bin");
65 std::string tgcc = cmSystemTools::FindProgram("gcc", locations);
66 std::string gcc = "gcc.exe";
67 if(tgcc.size())
69 gcc = tgcc;
71 std::string tgxx = cmSystemTools::FindProgram("g++", locations);
72 std::string gxx = "g++.exe";
73 if(tgxx.size())
75 gxx = tgxx;
77 mf->AddDefinition("MSYS", "1");
78 mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str());
79 mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str());
80 this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
81 if(!mf->IsSet("CMAKE_AR") && !this->CMakeInstance->GetIsInTryCompile())
83 cmSystemTools::Error
84 ("CMAKE_AR was not found, please set to archive program. ",
85 mf->GetDefinition("CMAKE_AR"));
89 ///! Create a local generator appropriate to this Global Generator
90 cmLocalGenerator *cmGlobalMSYSMakefileGenerator::CreateLocalGenerator()
92 cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3;
93 lg->SetWindowsShell(false);
94 lg->SetMSYSShell(true);
95 lg->SetGlobalGenerator(this);
96 lg->SetIgnoreLibPrefix(true);
97 lg->SetPassMakeflags(false);
98 lg->SetUnixCD(true);
99 return lg;
102 //----------------------------------------------------------------------------
103 void cmGlobalMSYSMakefileGenerator
104 ::GetDocumentation(cmDocumentationEntry& entry) const
106 entry.Name = this->GetName();
107 entry.Brief = "Generates MSYS makefiles.";
108 entry.Full = "The makefiles use /bin/sh as the shell. "
109 "They require msys to be installed on the machine.";