Commit 410e31c6 authored by Ivan Donchevskii's avatar Ivan Donchevskii

CppTools: set default -std=c++11 for Qt4

qmake from Qt4 does not provide C++ standard and
clang can't properly compile Qt4.8.6 and earlier
with c++1z. Behavior in this commit mimics qmake
from Qt5 which also provides c++11 as a default
standard.

Task-number: QTCREATORBUG-16441
Change-Id: I3d29891d6e47f2367f2b3b2bf4be4d86661924e9
Reviewed-by: Nikolai Kosjar's avatarNikolai Kosjar <nikolai.kosjar@qt.io>
parent 58e8cf83
......@@ -275,8 +275,10 @@ void AutotoolsProject::updateCppCodeModel()
CppTools::ProjectPart::QtVersion activeQtVersion = CppTools::ProjectPart::NoQt;
if (QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(k)) {
if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
activeQtVersion = CppTools::ProjectPart::Qt4;
if (qtVersion->qtVersion() <= QtSupport::QtVersionNumber(4,8,6))
activeQtVersion = CppTools::ProjectPart::Qt4_8_6AndOlder;
else if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
activeQtVersion = CppTools::ProjectPart::Qt4Latest;
else
activeQtVersion = CppTools::ProjectPart::Qt5;
}
......
......@@ -164,8 +164,10 @@ void CMakeProject::updateProjectData(CMakeBuildConfiguration *bc)
CppTools::ProjectPart::QtVersion activeQtVersion = CppTools::ProjectPart::NoQt;
if (QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(k)) {
if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
activeQtVersion = CppTools::ProjectPart::Qt4;
if (qtVersion->qtVersion() <= QtSupport::QtVersionNumber(4,8,6))
activeQtVersion = CppTools::ProjectPart::Qt4_8_6AndOlder;
else if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
activeQtVersion = CppTools::ProjectPart::Qt4Latest;
else
activeQtVersion = CppTools::ProjectPart::Qt5;
}
......
......@@ -144,7 +144,8 @@ QString Utils::toString(ProjectPart::QtVersion qtVersion)
switch (qtVersion) {
CASE_QTVERSION(UnknownQt);
CASE_QTVERSION(NoQt);
CASE_QTVERSION(Qt4);
CASE_QTVERSION(Qt4_8_6AndOlder);
CASE_QTVERSION(Qt4Latest);
CASE_QTVERSION(Qt5);
// no default to get a compiler warning if anything is added
}
......
......@@ -205,12 +205,15 @@ void ProjectInfoGenerator::createProjectParts(const RawProjectPart &rawProjectPa
const ProjectPart::Ptr part = projectPartFromRawProjectPart(rawProjectPart,
m_projectUpdateInfo.project);
ProjectPart::LanguageVersion defaultVersion = ProjectPart::LatestCxxVersion;
if (rawProjectPart.qtVersion == ProjectPart::Qt4_8_6AndOlder)
defaultVersion = ProjectPart::CXX11;
if (cat.hasCxxSources()) {
createProjectPart(rawProjectPart,
part,
cat.cxxSources(),
cat.partName("C++"),
ProjectPart::LatestCxxVersion,
defaultVersion,
ProjectPart::NoExtensions);
}
......@@ -219,7 +222,7 @@ void ProjectInfoGenerator::createProjectParts(const RawProjectPart &rawProjectPa
part,
cat.objcxxSources(),
cat.partName("Obj-C++"),
ProjectPart::LatestCxxVersion,
defaultVersion,
ProjectPart::ObjectiveCExtensions);
}
......
......@@ -80,7 +80,8 @@ public:
enum QtVersion {
UnknownQt = -1,
NoQt,
Qt4,
Qt4_8_6AndOlder,
Qt4Latest,
Qt5
};
......
......@@ -432,8 +432,10 @@ void GenericProject::refreshCppCodeModel()
CppTools::ProjectPart::QtVersion activeQtVersion = CppTools::ProjectPart::NoQt;
if (QtSupport::BaseQtVersion *qtVersion =
QtSupport::QtKitInformation::qtVersion(activeTarget()->kit())) {
if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
activeQtVersion = CppTools::ProjectPart::Qt4;
if (qtVersion->qtVersion() <= QtSupport::QtVersionNumber(4,8,6))
activeQtVersion = CppTools::ProjectPart::Qt4_8_6AndOlder;
else if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
activeQtVersion = CppTools::ProjectPart::Qt4Latest;
else
activeQtVersion = CppTools::ProjectPart::Qt5;
}
......
......@@ -906,8 +906,10 @@ void QbsProject::updateCppCodeModel()
CppTools::ProjectPart::QtVersion qtVersionFromKit = CppTools::ProjectPart::NoQt;
if (qtVersion) {
if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
qtVersionFromKit = CppTools::ProjectPart::Qt4;
if (qtVersion->qtVersion() <= QtSupport::QtVersionNumber(4,8,6))
qtVersionFromKit = CppTools::ProjectPart::Qt4_8_6AndOlder;
else if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
qtVersionFromKit = CppTools::ProjectPart::Qt4Latest;
else
qtVersionFromKit = CppTools::ProjectPart::Qt5;
}
......
......@@ -271,8 +271,10 @@ void QmakeProject::updateCppCodeModel()
QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(k);
ProjectPart::QtVersion qtVersionForPart = ProjectPart::NoQt;
if (qtVersion) {
if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
qtVersionForPart = ProjectPart::Qt4;
if (qtVersion->qtVersion() <= QtSupport::QtVersionNumber(4,8,6))
qtVersionForPart = ProjectPart::Qt4_8_6AndOlder;
else if (qtVersion->qtVersion() < QtSupport::QtVersionNumber(5,0,0))
qtVersionForPart = ProjectPart::Qt4Latest;
else
qtVersionForPart = ProjectPart::Qt5;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment