2
* This file is part of the Code::Blocks IDE and licensed under the GNU General Public License, version 3
3
* http://www.gnu.org/licenses/gpl-3.0.html
11
#include "compilerMINGWgenerator.h"
13
#include "cbexception.h"
14
#include "cbproject.h"
15
#include "compilerfactory.h"
18
#include "configmanager.h"
19
#include "logmanager.h"
20
#include "macrosmanager.h"
21
#include "scriptingmanager.h"
23
CompilerMINGWGenerator::CompilerMINGWGenerator()
26
m_VerStr = wxEmptyString;
29
CompilerMINGWGenerator::~CompilerMINGWGenerator()
34
wxString CompilerMINGWGenerator::SetupIncludeDirs(Compiler* compiler, ProjectBuildTarget* target)
36
wxString result = CompilerCommandGenerator::SetupIncludeDirs(compiler, target);
37
m_VerStr = compiler->GetVersionString();
39
bool IsGcc4 = m_VerStr.Left(1).IsSameAs(_T("4"));
41
// for PCH to work, the very first include dir *must* be the object output dir
42
// *only* if PCH is generated in the object output dir
44
target->GetParentProject()->GetModeForPCH() == pchObjectDir)
46
wxArrayString includedDirs; // avoid adding duplicate dirs...
47
wxString sep = wxFILE_SEP_PATH;
48
// find all PCH in project
49
int count = target->GetParentProject()->GetFilesCount();
50
for (int i = 0; i < count; ++i)
52
ProjectFile* f = target->GetParentProject()->GetFile(i);
53
if (FileTypeOf(f->relativeFilename) == ftHeader &&
56
// it is a PCH; add it's object dir to includes
57
wxString dir = wxFileName(target->GetObjectOutput() + sep + f->GetObjName()).GetPath();
58
if (includedDirs.Index(dir) == wxNOT_FOUND)
60
includedDirs.Add(dir);
61
QuoteStringIfNeeded(dir);
63
pch_prepend << compiler->GetSwitches().includeDirs << dir << _T(' ');
65
pch_prepend << _T("-iquote") << dir << _T(' ');
69
// for gcc-4.0+, use the following:
70
// pch_prepend << _T("-iquote") << dir << _T(' ');
71
// for earlier versions, -I- must be used
73
pch_prepend << _T("-I- ");
74
count = (int)includedDirs.GetCount();
75
for (int i = 0; i < count; ++i)
77
QuoteStringIfNeeded(includedDirs[i]);
78
pch_prepend << compiler->GetSwitches().includeDirs << includedDirs[i] << _T(' ');
80
pch_prepend << _T("-I. ");
81
result.Prepend(pch_prepend);