1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
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 "cmGlobalMSYSMakefileGenerator.h"
13 #include "cmLocalUnixMakefileGenerator3.h"
14 #include "cmMakefile.h"
17 cmGlobalMSYSMakefileGenerator::cmGlobalMSYSMakefileGenerator()
19 this->FindMakeProgramFile = "CMakeMSYSFindMake.cmake";
20 this->ForceUnixPaths = true;
21 this->ToolSupportsColor = true;
22 this->UseLinkScript = false;
26 cmGlobalMSYSMakefileGenerator::FindMinGW(std::string const& makeloc)
28 std::string fstab = makeloc;
29 fstab += "/../etc/fstab";
30 std::ifstream fin(fstab.c_str());
47 void cmGlobalMSYSMakefileGenerator
48 ::EnableLanguage(std::vector<std::string>const& l,
52 this->FindMakeProgram(mf);
53 std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
54 std::vector<std::string> locations;
55 std::string makeloc = cmSystemTools::GetProgramPath(makeProgram.c_str());
56 locations.push_back(this->FindMinGW(makeloc));
57 locations.push_back(makeloc);
58 locations.push_back("/mingw/bin");
59 locations.push_back("c:/mingw/bin");
60 std::string tgcc = cmSystemTools::FindProgram("gcc", locations);
61 std::string gcc = "gcc.exe";
66 std::string tgxx = cmSystemTools::FindProgram("g++", locations);
67 std::string gxx = "g++.exe";
72 std::string trc = cmSystemTools::FindProgram("windres", locations);
73 std::string rc = "windres.exe";
78 mf->AddDefinition("MSYS", "1");
79 mf->AddDefinition("CMAKE_GENERATOR_CC", gcc.c_str());
80 mf->AddDefinition("CMAKE_GENERATOR_CXX", gxx.c_str());
81 mf->AddDefinition("CMAKE_GENERATOR_RC", rc.c_str());
82 this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
84 if(!mf->IsSet("CMAKE_AR") &&
85 !this->CMakeInstance->GetIsInTryCompile() &&
86 !(1==l.size() && l[0]=="NONE"))
89 ("CMAKE_AR was not found, please set to archive program. ",
90 mf->GetDefinition("CMAKE_AR"));
94 ///! Create a local generator appropriate to this Global Generator
95 cmLocalGenerator *cmGlobalMSYSMakefileGenerator::CreateLocalGenerator()
97 cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3;
98 lg->SetWindowsShell(false);
99 lg->SetMSYSShell(true);
100 lg->SetGlobalGenerator(this);
101 lg->SetIgnoreLibPrefix(true);
102 lg->SetPassMakeflags(false);
107 //----------------------------------------------------------------------------
108 void cmGlobalMSYSMakefileGenerator
109 ::GetDocumentation(cmDocumentationEntry& entry)
111 entry.Name = cmGlobalMSYSMakefileGenerator::GetActualName();
112 entry.Brief = "Generates MSYS makefiles.";
113 entry.Full = "The makefiles use /bin/sh as the shell. "
114 "They require msys to be installed on the machine.";