KWSys Nightly Date Stamp
[cmake.git] / Source / cmGlobalMSYSMakefileGenerator.cxx
blobf0a6e7d0c884ee8bf55a18d09a5ec6497f41aa57
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmGlobalMSYSMakefileGenerator.cxx,v $
5 Language: C++
6 Date: $Date: 2008-12-01 19:41:47 $
7 Version: $Revision: 1.15 $
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);
82 if(!mf->IsSet("CMAKE_AR") &&
83 !this->CMakeInstance->GetIsInTryCompile() &&
84 !(1==l.size() && l[0]=="NONE"))
86 cmSystemTools::Error
87 ("CMAKE_AR was not found, please set to archive program. ",
88 mf->GetDefinition("CMAKE_AR"));
92 ///! Create a local generator appropriate to this Global Generator
93 cmLocalGenerator *cmGlobalMSYSMakefileGenerator::CreateLocalGenerator()
95 cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3;
96 lg->SetWindowsShell(false);
97 lg->SetMSYSShell(true);
98 lg->SetGlobalGenerator(this);
99 lg->SetIgnoreLibPrefix(true);
100 lg->SetPassMakeflags(false);
101 lg->SetUnixCD(true);
102 return lg;
105 //----------------------------------------------------------------------------
106 void cmGlobalMSYSMakefileGenerator
107 ::GetDocumentation(cmDocumentationEntry& entry) const
109 entry.Name = this->GetName();
110 entry.Brief = "Generates MSYS makefiles.";
111 entry.Full = "The makefiles use /bin/sh as the shell. "
112 "They require msys to be installed on the machine.";