2016-01-11 21:09:06 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2016-01-11 21:09:06 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-15 14:57:40 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2016-01-11 21:09:06 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
2016-01-11 21:09:06 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2016-01-11 21:09:06 +01:00
|
|
|
|
|
|
|
|
#include "cpptools_global.h"
|
|
|
|
|
|
|
|
|
|
#include "projectpart.h"
|
|
|
|
|
|
|
|
|
|
namespace CppTools {
|
|
|
|
|
|
|
|
|
|
class CPPTOOLS_EXPORT CompilerOptionsBuilder
|
|
|
|
|
{
|
|
|
|
|
public:
|
2016-11-02 12:21:54 +03:00
|
|
|
enum class PchUsage {
|
|
|
|
|
None,
|
|
|
|
|
Use
|
|
|
|
|
};
|
|
|
|
|
|
2017-09-27 10:32:52 +02:00
|
|
|
CompilerOptionsBuilder(const ProjectPart &projectPart,
|
|
|
|
|
const QString &clangVersion = QString(),
|
|
|
|
|
const QString &clangResourceDirectory = QString());
|
2016-01-11 21:09:06 +01:00
|
|
|
virtual ~CompilerOptionsBuilder() {}
|
|
|
|
|
|
2017-09-27 10:32:52 +02:00
|
|
|
virtual void addTargetTriple();
|
2017-12-15 15:28:13 +01:00
|
|
|
virtual void addExtraCodeModelFlags();
|
2017-09-27 10:32:52 +02:00
|
|
|
virtual void enableExceptions();
|
|
|
|
|
virtual void addPredefinedHeaderPathsOptions();
|
|
|
|
|
virtual void addLanguageOption(ProjectFile::Kind fileKind);
|
|
|
|
|
virtual void addOptionsForLanguage(bool checkForBorlandExtensions = true);
|
|
|
|
|
|
|
|
|
|
virtual void addExtraOptions() {}
|
|
|
|
|
|
|
|
|
|
QStringList build(ProjectFile::Kind fileKind,
|
|
|
|
|
PchUsage pchUsage);
|
2016-01-11 21:09:06 +01:00
|
|
|
QStringList options() const;
|
|
|
|
|
|
|
|
|
|
// Add custom options
|
|
|
|
|
void add(const QString &option);
|
2017-02-07 15:00:38 +01:00
|
|
|
void addDefine(const ProjectExplorer::Macro &marco);
|
2016-01-11 21:09:06 +01:00
|
|
|
|
|
|
|
|
// Add options based on project part
|
2016-10-17 17:15:15 +02:00
|
|
|
void addWordWidth();
|
2016-10-17 13:20:29 +02:00
|
|
|
void addHeaderPathOptions();
|
2016-11-02 12:21:54 +03:00
|
|
|
void addPrecompiledHeaderOptions(PchUsage pchUsage);
|
2017-11-20 13:30:36 +01:00
|
|
|
virtual void addToolchainAndProjectMacros();
|
2017-02-07 15:00:38 +01:00
|
|
|
void addMacros(const ProjectExplorer::Macros ¯os);
|
2016-01-11 21:09:06 +01:00
|
|
|
|
2016-04-11 11:53:50 +02:00
|
|
|
void addMsvcCompatibilityVersion();
|
2016-04-11 17:34:02 +02:00
|
|
|
void undefineCppLanguageFeatureMacrosForMsvc2015();
|
2017-11-21 12:18:28 +01:00
|
|
|
void addDefineFunctionMacrosMsvc();
|
2016-04-11 11:53:50 +02:00
|
|
|
|
2017-09-27 10:32:52 +02:00
|
|
|
void addProjectConfigFileInclude();
|
|
|
|
|
void undefineClangVersionMacrosForMsvc();
|
2016-10-17 11:51:13 +02:00
|
|
|
|
2016-01-11 21:09:06 +01:00
|
|
|
protected:
|
2017-02-07 15:00:38 +01:00
|
|
|
virtual bool excludeDefineDirective(const ProjectExplorer::Macro ¯o) const;
|
2016-01-11 21:09:06 +01:00
|
|
|
virtual bool excludeHeaderPath(const QString &headerPath) const;
|
|
|
|
|
|
|
|
|
|
virtual QString defineOption() const;
|
2016-10-17 15:12:05 +02:00
|
|
|
virtual QString undefineOption() const;
|
2016-01-11 21:09:06 +01:00
|
|
|
virtual QString includeOption() const;
|
2016-11-02 12:21:54 +03:00
|
|
|
virtual QString includeDirOption() const;
|
2016-01-11 21:09:06 +01:00
|
|
|
|
|
|
|
|
const ProjectPart m_projectPart;
|
|
|
|
|
|
|
|
|
|
private:
|
2017-02-07 15:00:38 +01:00
|
|
|
QByteArray macroOption(const ProjectExplorer::Macro ¯o) const;
|
|
|
|
|
QByteArray toDefineOption(const ProjectExplorer::Macro ¯o) const;
|
|
|
|
|
QString defineDirectiveToDefineOption(const ProjectExplorer::Macro &marco) const;
|
2017-11-17 14:13:55 +01:00
|
|
|
void addClangIncludeFolder();
|
2016-01-11 21:09:06 +01:00
|
|
|
|
|
|
|
|
QStringList m_options;
|
2017-09-27 10:32:52 +02:00
|
|
|
QString m_clangVersion;
|
|
|
|
|
QString m_clangResourceDirectory;
|
2016-01-11 21:09:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace CppTools
|