ImportProject: Read --std settings from vcxproj file

This commit is contained in:
Daniel Marjamäki 2020-05-25 21:43:24 +02:00
parent 9edca82138
commit d70911c801
2 changed files with 26 additions and 0 deletions

View File

@ -334,6 +334,12 @@ unsigned int CppCheck::check(const std::string &path)
#endif
std::string flags(lang + " ");
if (mSettings.standards.cpp == Standards::CPP14)
flags += "-std=c++14 ";
else if (mSettings.standards.cpp == Standards::CPP17)
flags += "-std=c++17 ";
else if (mSettings.standards.cpp == Standards::CPP20)
flags += "-std=c++20 ";
for (const std::string &i: mSettings.includePaths)
flags += "-I" + i + " ";
@ -401,6 +407,12 @@ unsigned int CppCheck::check(const ImportProject::FileSettings &fs)
temp.mSettings.userDefines += fs.cppcheckDefines();
temp.mSettings.includePaths = fs.includePaths;
temp.mSettings.userUndefs = fs.undefs;
if (fs.standard == "c++14")
temp.mSettings.standards.cpp = Standards::CPP14;
else if (fs.standard == "c++17")
temp.mSettings.standards.cpp = Standards::CPP17;
else if (fs.standard == "c++20")
temp.mSettings.standards.cpp = Standards::CPP20;
if (fs.platformType != Settings::Unspecified)
temp.mSettings.platform(fs.platformType);
if (mSettings.clang) {

View File

@ -469,6 +469,11 @@ namespace {
if (!additionalIncludePaths.empty())
additionalIncludePaths += ';';
additionalIncludePaths += e->GetText();
} else if (std::strcmp(e->Name(), "LanguageStandard") == 0) {
if (std::strcmp(e->GetText(), "stdcpp14") == 0)
cppstd = Standards::CPP14;
else if (std::strcmp(e->GetText(), "stdcpp17") == 0)
cppstd = Standards::CPP17;
}
}
}
@ -508,6 +513,7 @@ namespace {
std::string condition;
std::string preprocessorDefinitions;
std::string additionalIncludePaths;
Standards::cppstd_t cppstd = Standards::CPPLatest;
};
}
@ -696,6 +702,14 @@ void ImportProject::importVcxproj(const std::string &filename, std::map<std::str
for (const ItemDefinitionGroup &i : itemDefinitionGroupList) {
if (!i.conditionIsTrue(p))
continue;
if (i.cppstd == Standards::CPP11)
fs.standard = "c++11";
else if (i.cppstd == Standards::CPP14)
fs.standard = "c++14";
else if (i.cppstd == Standards::CPP17)
fs.standard = "c++14";
else if (i.cppstd == Standards::CPP20)
fs.standard = "c++20";
fs.defines += ';' + i.preprocessorDefinitions;
additionalIncludePaths += ';' + i.additionalIncludePaths;
}