logic: Added PCH support to CDB source groups (issue #311)
* added PCH Flags list and checkbox to reuse compiler flags and cdb flags to source group setup * added UI tests for C++ and CDB source groups
This commit is contained in:
@@ -190,6 +190,8 @@ add_files(
|
||||
qt/project_wizard/content/QtProjectWizardContentCStandard.h
|
||||
qt/project_wizard/content/QtProjectWizardContentCustomCommand.cpp
|
||||
qt/project_wizard/content/QtProjectWizardContentCustomCommand.h
|
||||
qt/project_wizard/content/QtProjectWizardContentCxxPchFlags.cpp
|
||||
qt/project_wizard/content/QtProjectWizardContentCxxPchFlags.h
|
||||
qt/project_wizard/content/QtProjectWizardContentExtensions.cpp
|
||||
qt/project_wizard/content/QtProjectWizardContentExtensions.h
|
||||
qt/project_wizard/content/QtProjectWizardContentFlags.cpp
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "QtProjectWizardContentCrossCompilationOptions.h"
|
||||
#include "QtProjectWizardContentCStandard.h"
|
||||
#include "QtProjectWizardContentCustomCommand.h"
|
||||
#include "QtProjectWizardContentCxxPchFlags.h"
|
||||
#include "QtProjectWizardContentExtensions.h"
|
||||
#include "QtProjectWizardContentFlags.h"
|
||||
#include "QtProjectWizardContentGroup.h"
|
||||
@@ -147,6 +148,7 @@ namespace
|
||||
return new QtProjectWizardContentPathCxxPch(settings, settings, window);
|
||||
}
|
||||
);
|
||||
page.addContentCreatorWithSettings<QtProjectWizardContentCxxPchFlags>(WIZARD_CONTENT_CONTEXT_ALL, false);
|
||||
pages.push_back(page);
|
||||
}
|
||||
|
||||
@@ -193,6 +195,7 @@ namespace
|
||||
return new QtProjectWizardContentPathCxxPch(settings, settings, window);
|
||||
}
|
||||
);
|
||||
page.addContentCreatorWithSettings<QtProjectWizardContentCxxPchFlags>(WIZARD_CONTENT_CONTEXT_ALL, false);
|
||||
pages.push_back(page);
|
||||
}
|
||||
|
||||
@@ -226,6 +229,14 @@ namespace
|
||||
{
|
||||
QtSourceGroupWizardPage<SourceGroupSettingsCxxCdb> page("Advanced (optional)");
|
||||
page.addContentCreatorWithSettings<QtProjectWizardContentFlags>(WIZARD_CONTENT_CONTEXT_SUMMARY, true);
|
||||
page.addContentCreator(
|
||||
WIZARD_CONTENT_CONTEXT_ALL,
|
||||
[](std::shared_ptr<SourceGroupSettingsCxxCdb> settings, QtProjectWizardWindow* window)
|
||||
{
|
||||
return new QtProjectWizardContentPathCxxPch(settings, settings, window);
|
||||
}
|
||||
);
|
||||
page.addContentCreatorWithSettings<QtProjectWizardContentCxxPchFlags>(WIZARD_CONTENT_CONTEXT_ALL, true);
|
||||
pages.push_back(page);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
#include "QtProjectWizardContentCxxPchFlags.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "QtStringListBox.h"
|
||||
#include "SourceGroupSettingsWithCxxPchOptions.h"
|
||||
|
||||
QtProjectWizardContentCxxPchFlags::QtProjectWizardContentCxxPchFlags(
|
||||
std::shared_ptr<SourceGroupSettingsWithCxxPchOptions> settings,
|
||||
QtProjectWizardWindow* window,
|
||||
bool isCDB
|
||||
)
|
||||
: QtProjectWizardContent(window)
|
||||
, m_settings(settings)
|
||||
, m_isCDB(isCDB)
|
||||
{
|
||||
}
|
||||
|
||||
void QtProjectWizardContentCxxPchFlags::populate(QGridLayout* layout, int& row)
|
||||
{
|
||||
const QString labelText("Precompiled Header Flags");
|
||||
layout->addWidget(createFormLabel(labelText), row, QtProjectWizardWindow::FRONT_COL, 2, 1, Qt::AlignTop);
|
||||
|
||||
const QString optionText(m_isCDB ?
|
||||
"Use flags of first indexed file and 'Additional Compiler Flags'" : "Use 'Compiler Flags'");
|
||||
|
||||
const QString optionHelp(m_isCDB ?
|
||||
"Check <b>" + optionText + "</b> to use the flags specified "
|
||||
"in the first compile command of the Compilation Database and all flags specified at 'Additional Compiler Flags'." :
|
||||
"Check <b>" + optionText + "</b> to reuse the flags specified at 'Compiler Flags'.");
|
||||
|
||||
addHelpButton(
|
||||
"Precompiled Header Flags",
|
||||
"<p>Define compiler flags used during precompiled header file generation.</p>"
|
||||
"<p>" + optionHelp + "</p>"
|
||||
"<p>Additionally add compiler flags to the list for precompiled header generation only. Some examples:</p>"
|
||||
"<p>* use \"-DRELEASE\" to add a preprocessor #define for \"RELEASE\"</p>"
|
||||
"<p>* use \"-U__clang__\" to remove the preprocessor #define for \"__clang__\"</p>",
|
||||
layout, row
|
||||
);
|
||||
|
||||
m_useCompilerFlags = new QCheckBox(optionText);
|
||||
layout->addWidget(m_useCompilerFlags, row, QtProjectWizardWindow::BACK_COL);
|
||||
row++;
|
||||
|
||||
m_list = new QtStringListBox(this, labelText);
|
||||
layout->addWidget(m_list, row, QtProjectWizardWindow::BACK_COL);
|
||||
row++;
|
||||
}
|
||||
|
||||
void QtProjectWizardContentCxxPchFlags::load()
|
||||
{
|
||||
m_useCompilerFlags->setChecked(m_settings->getUseCompilerFlags());
|
||||
m_list->setStrings(m_settings->getPchFlags());
|
||||
}
|
||||
|
||||
void QtProjectWizardContentCxxPchFlags::save()
|
||||
{
|
||||
m_settings->setUseCompilerFlags(m_useCompilerFlags->isChecked());
|
||||
m_settings->setPchFlags(m_list->getStrings());
|
||||
}
|
||||
|
||||
bool QtProjectWizardContentCxxPchFlags::check()
|
||||
{
|
||||
std::wstring error;
|
||||
|
||||
for (const std::wstring& flag : m_list->getStrings())
|
||||
{
|
||||
if (utility::isPrefix<std::wstring>(L"-include ", flag) || utility::isPrefix<std::wstring>(L"--include ", flag))
|
||||
{
|
||||
error = L"The entered flag \"" + flag + L"\" contains an error. Please remove the intermediate space character.\n";
|
||||
}
|
||||
}
|
||||
|
||||
if (!error.empty())
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QString::fromStdWString(error));
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#ifndef QT_PROJECT_WIZARD_CONTENT_CXX_PCH_FLAGS_H
|
||||
#define QT_PROJECT_WIZARD_CONTENT_CXX_PCH_FLAGS_H
|
||||
|
||||
#include "QtProjectWizardContent.h"
|
||||
|
||||
class QCheckBox;
|
||||
class QtStringListBox;
|
||||
class SourceGroupSettingsWithCxxPchOptions;
|
||||
|
||||
class QtProjectWizardContentCxxPchFlags
|
||||
: public QtProjectWizardContent
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QtProjectWizardContentCxxPchFlags(
|
||||
std::shared_ptr<SourceGroupSettingsWithCxxPchOptions> settings,
|
||||
QtProjectWizardWindow* window,
|
||||
bool isCDB
|
||||
);
|
||||
|
||||
// QtProjectWizardContent implementation
|
||||
virtual void populate(QGridLayout* layout, int& row) override;
|
||||
|
||||
virtual void load() override;
|
||||
virtual void save() override;
|
||||
virtual bool check() override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<SourceGroupSettingsWithCxxPchOptions> m_settings;
|
||||
const bool m_isCDB;
|
||||
|
||||
QCheckBox* m_useCompilerFlags;
|
||||
QtStringListBox* m_list;
|
||||
};
|
||||
|
||||
#endif // QT_PROJECT_WIZARD_CONTENT_CXX_PCH_FLAGS_H
|
||||
@@ -15,12 +15,12 @@ QtProjectWizardContentPathCxxPch::QtProjectWizardContentPathCxxPch(
|
||||
{
|
||||
setTitleString("Precompiled Header File");
|
||||
setHelpString(
|
||||
"Specify the path to the input header file that should be used to generate a precompiled header during indexing.<br />"
|
||||
"Specify the path to the input header file that should be used to generate a precompiled header before indexing.<br />"
|
||||
"If the indexed source code is usually built using precompiled headers, using this option will speed up your indexing performance.<br />"
|
||||
"Leave blank to disable the use of precompiled headers. You can make use of environment variables with ${ENV_VAR}."
|
||||
);
|
||||
setAllowEmpty(true);
|
||||
setPlaceholderString("Not Using Precompiled Headers");
|
||||
setPlaceholderString("Not Using Precompiled Header");
|
||||
}
|
||||
|
||||
void QtProjectWizardContentPathCxxPch::populate(QGridLayout* layout, int& row)
|
||||
|
||||
Reference in New Issue
Block a user