logic: only use precompiled headers for compilation database commands that specify the "-include-pch" flag (issue #719)
This commit is contained in:
@@ -1,8 +1,13 @@
|
||||
#include "QtProjectWizardContentPathCxxPch.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "IndexerCommandCxx.h"
|
||||
#include "SourceGroupSettingsCxxCdb.h"
|
||||
#include "SourceGroupSettingsWithCxxPchOptions.h"
|
||||
#include "utility.h"
|
||||
#include "utilityFile.h"
|
||||
#include "utilitySourceGroupCxx.h"
|
||||
|
||||
QtProjectWizardContentPathCxxPch::QtProjectWizardContentPathCxxPch(
|
||||
std::shared_ptr<SourceGroupSettings> settings,
|
||||
@@ -40,6 +45,44 @@ void QtProjectWizardContentPathCxxPch::save()
|
||||
m_settingsCxxPch->setPchInputFilePathFilePath(FilePath(m_picker->getText().toStdWString()));
|
||||
}
|
||||
|
||||
bool QtProjectWizardContentPathCxxPch::check()
|
||||
{
|
||||
if (std::shared_ptr<SourceGroupSettingsCxxCdb> cdbSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxxCdb>(m_settings))
|
||||
{
|
||||
const FilePath cdbPath = cdbSettings->getCompilationDatabasePathExpandedAndAbsolute();
|
||||
std::shared_ptr<clang::tooling::JSONCompilationDatabase> cdb = IndexerCommandCxx::loadCDB(cdbPath);
|
||||
if (!cdb)
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Unable to open and read the provided compilation database file.");
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (utility::containsIncludePchFlags(cdb))
|
||||
{
|
||||
if (m_settingsCxxPch->getPchInputFilePath().empty())
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("The provided compilation database file uses precompiled headers. Please specify a Precompiled Header input file.");
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_settingsCxxPch->getPchInputFilePath().empty())
|
||||
{
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("The provided compilation database file does not use precompiled headers. Please do not specify a Precompiled Header input file.");
|
||||
msgBox.exec();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<SourceGroupSettings> QtProjectWizardContentPathCxxPch::getSourceGroupSettings()
|
||||
{
|
||||
return m_settings;
|
||||
|
||||
@@ -22,6 +22,7 @@ public:
|
||||
|
||||
void load() override;
|
||||
void save() override;
|
||||
bool check() override;
|
||||
|
||||
private:
|
||||
std::shared_ptr<SourceGroupSettings> getSourceGroupSettings() override;
|
||||
|
||||
Reference in New Issue
Block a user