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 {
|
|
|
|
|
|
2018-11-30 10:34:05 +01:00
|
|
|
enum class UsePrecompiledHeaders : char { Yes, No };
|
|
|
|
|
enum class UseSystemHeader : char { Yes, No };
|
2020-10-28 12:10:55 +01:00
|
|
|
enum class UseTweakedHeaderPaths : char { Yes, Tools, No };
|
2018-11-30 12:15:07 +01:00
|
|
|
enum class UseToolchainMacros : char { Yes, No };
|
2018-11-30 11:02:49 +01:00
|
|
|
enum class UseLanguageDefines : char { Yes, No };
|
2019-01-31 10:16:28 +01:00
|
|
|
enum class UseBuildSystemWarnings : char { Yes, No };
|
2018-09-17 09:26:56 +02:00
|
|
|
|
2019-01-11 15:32:12 +01:00
|
|
|
CPPTOOLS_EXPORT QStringList XclangArgs(const QStringList &args);
|
|
|
|
|
CPPTOOLS_EXPORT QStringList clangArgsForCl(const QStringList &args);
|
2019-03-13 10:22:16 +01:00
|
|
|
CPPTOOLS_EXPORT QStringList createLanguageOptionGcc(ProjectFile::Kind fileKind, bool objcExt);
|
2019-01-11 15:32:12 +01:00
|
|
|
|
2016-01-11 21:09:06 +01:00
|
|
|
class CPPTOOLS_EXPORT CompilerOptionsBuilder
|
|
|
|
|
{
|
|
|
|
|
public:
|
2020-08-24 10:46:58 +02:00
|
|
|
CompilerOptionsBuilder(const ProjectPart &projectPart,
|
2019-01-31 10:16:28 +01:00
|
|
|
UseSystemHeader useSystemHeader = UseSystemHeader::No,
|
|
|
|
|
UseTweakedHeaderPaths useTweakedHeaderPaths = UseTweakedHeaderPaths::No,
|
|
|
|
|
UseLanguageDefines useLanguageDefines = UseLanguageDefines::No,
|
|
|
|
|
UseBuildSystemWarnings useBuildSystemWarnings = UseBuildSystemWarnings::No,
|
|
|
|
|
const QString &clangVersion = QString(),
|
2020-08-24 10:46:58 +02:00
|
|
|
const QString &clangIncludeDirectory = QString());
|
2017-09-27 10:32:52 +02:00
|
|
|
|
2018-11-30 10:34:05 +01:00
|
|
|
QStringList build(ProjectFile::Kind fileKind, UsePrecompiledHeaders usePrecompiledHeaders);
|
|
|
|
|
QStringList options() const { return m_options; }
|
2016-01-11 21:09:06 +01:00
|
|
|
|
|
|
|
|
// Add options based on project part
|
2019-01-11 15:50:39 +01:00
|
|
|
virtual void addProjectMacros();
|
2019-01-11 15:32:12 +01:00
|
|
|
void addSyntaxOnly();
|
2016-10-17 17:15:15 +02:00
|
|
|
void addWordWidth();
|
2016-10-17 13:20:29 +02:00
|
|
|
void addHeaderPathOptions();
|
2018-11-30 10:34:05 +01:00
|
|
|
void addPrecompiledHeaderOptions(UsePrecompiledHeaders usePrecompiledHeaders);
|
2018-06-11 12:52:04 +02:00
|
|
|
void addIncludedFiles(const QStringList &files);
|
2017-02-07 15:00:38 +01:00
|
|
|
void addMacros(const ProjectExplorer::Macros ¯os);
|
2016-01-11 21:09:06 +01:00
|
|
|
|
2018-09-26 14:10:35 +02:00
|
|
|
void addTargetTriple();
|
|
|
|
|
void addExtraCodeModelFlags();
|
2018-12-17 12:06:57 +01:00
|
|
|
void addPicIfCompilerFlagsContainsIt();
|
2019-01-08 16:22:39 +01:00
|
|
|
void addCompilerFlags();
|
2020-08-29 23:34:18 +03:00
|
|
|
void addMsvcExceptions();
|
2019-12-19 11:58:24 +01:00
|
|
|
void enableExceptions();
|
2018-09-26 14:10:35 +02:00
|
|
|
void insertWrappedQtHeaders();
|
2020-07-09 09:44:39 +02:00
|
|
|
void insertWrappedMingwHeaders();
|
2019-01-09 13:56:00 +01:00
|
|
|
void addLanguageVersionAndExtensions();
|
|
|
|
|
void updateFileLanguage(ProjectFile::Kind fileKind);
|
2018-09-26 14:10:35 +02: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
|
|
|
|
2018-09-26 14:10:35 +02:00
|
|
|
// Add custom options
|
2019-01-11 15:32:12 +01:00
|
|
|
void add(const QString &arg, bool gccOnlyOption = false);
|
2021-07-01 17:12:55 +02:00
|
|
|
void prepend(const QString &arg);
|
2019-01-11 15:32:12 +01:00
|
|
|
void add(const QStringList &args, bool gccOnlyOptions = false);
|
2018-11-30 10:34:05 +01:00
|
|
|
virtual void addExtraOptions() {}
|
2018-09-26 14:10:35 +02:00
|
|
|
|
2018-12-05 09:23:29 +01:00
|
|
|
static UseToolchainMacros useToolChainMacros();
|
2018-12-11 18:05:28 +01:00
|
|
|
void reset();
|
2018-12-05 09:23:29 +01:00
|
|
|
|
2019-01-08 16:22:39 +01:00
|
|
|
void evaluateCompilerFlags();
|
2019-01-11 15:32:12 +01:00
|
|
|
bool isClStyle() const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void addIncludeDirOptionForPath(const ProjectExplorer::HeaderPath &path);
|
2018-11-30 10:34:05 +01:00
|
|
|
bool excludeDefineDirective(const ProjectExplorer::Macro ¯o) const;
|
2020-07-09 09:44:39 +02:00
|
|
|
void insertWrappedHeaders(const QStringList &paths);
|
|
|
|
|
QStringList wrappedQtHeadersIncludePath() const;
|
|
|
|
|
QStringList wrappedMingwHeadersIncludePath() const;
|
2019-01-08 16:22:39 +01:00
|
|
|
QByteArray msvcVersion() const;
|
2021-01-11 15:57:16 +01:00
|
|
|
void addIncludeFile(const QString &file);
|
2018-09-26 14:10:35 +02:00
|
|
|
|
2018-11-30 10:34:05 +01:00
|
|
|
private:
|
2018-09-26 14:10:35 +02:00
|
|
|
const ProjectPart &m_projectPart;
|
2016-01-11 21:09:06 +01:00
|
|
|
|
2018-11-30 10:34:05 +01:00
|
|
|
const UseSystemHeader m_useSystemHeader;
|
2018-11-30 12:15:07 +01:00
|
|
|
const UseTweakedHeaderPaths m_useTweakedHeaderPaths;
|
2018-11-30 11:02:49 +01:00
|
|
|
const UseLanguageDefines m_useLanguageDefines;
|
2019-01-31 10:16:28 +01:00
|
|
|
const UseBuildSystemWarnings m_useBuildSystemWarnings;
|
2016-01-11 21:09:06 +01:00
|
|
|
|
2018-11-30 10:34:05 +01:00
|
|
|
const QString m_clangVersion;
|
2020-08-24 10:46:58 +02:00
|
|
|
const QString m_clangIncludeDirectory;
|
2018-08-23 15:45:33 +02:00
|
|
|
|
2019-01-08 16:22:39 +01:00
|
|
|
struct {
|
|
|
|
|
QStringList flags;
|
|
|
|
|
bool isLanguageVersionSpecified = false;
|
|
|
|
|
} m_compilerFlags;
|
2019-01-10 11:41:26 +01:00
|
|
|
|
2016-01-11 21:09:06 +01:00
|
|
|
QStringList m_options;
|
2019-01-11 15:32:12 +01:00
|
|
|
bool m_clStyle = false;
|
2016-01-11 21:09:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace CppTools
|