summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2019-06-07 21:44:03 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2019-06-08 03:58:00 +0200
commit92c03d9bf644b0f10de52ce0da09f97056e46247 (patch)
tree367945c52ef0847070ca79de14debcaaeba4a0cd /bin
parent5fca7ba2fd6031515636842b44996bac74287568 (diff)
qtcreator: Take over '-std=...' from CXXFLAGS
If the '-std=' compiler flag is set in CXXFLAGS, take that over into the .pro files used by Qt Creator. This makes ClangCodeModel use the correct std version, and e.g. know about 'std::string_view' if '-std=gnu++2a' (or anything else indicating C++17 or higher is supported) is used and thus avoids unnecessary errors/warnings from being displayed. Use a list, so other flags can easily be added later. (It currently doesn't seem reasonable to me to just pass all cxxflags though, since .pro files are currently only generated per top-level module, while C++ flags can differ between different targets in the same module). Change-Id: Id3f3e2b9ba77e5220a17fd4796937c816979959a Reviewed-on: https://gerrit.libreoffice.org/73677 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/gbuild-to-ide15
1 files changed, 14 insertions, 1 deletions
diff --git a/bin/gbuild-to-ide b/bin/gbuild-to-ide
index 1365c548c218..e012c08c0828 100755
--- a/bin/gbuild-to-ide
+++ b/bin/gbuild-to-ide
@@ -1671,6 +1671,12 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator):
if ext:
headers_list.append(lopath(file_ + ext))
+ cxxflags_list = []
+ for cxxflag in lib.cxxflags:
+ # extract flag for C++ standard version
+ if cxxflag.startswith('-std'):
+ cxxflags_list.append(cxxflag)
+
# List all include paths
for hdir in (lib.include + lib.include_sys):
hf_lopath = lopath(hdir)
@@ -1695,12 +1701,14 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator):
if lib_folder in self.data_libs:
self.data_libs[lib_folder]['sources'] |= set(sources_list)
self.data_libs[lib_folder]['headers'] |= set(headers_list)
+ self.data_libs[lib_folder]['cxxflags'] |= set(cxxflags_list)
self.data_libs[lib_folder]['includepath'] |= set(includepath_list)
self.data_libs[lib_folder]['defines'] |= set(defines_list)
else:
self.data_libs[lib_folder] = {
'sources': set(sources_list),
'headers': set(headers_list),
+ 'cxxflags': set(cxxflags_list),
'includepath': set(includepath_list),
'defines': set(defines_list),
'loc': lib.location,
@@ -1723,6 +1731,7 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator):
for lib_folder in subdirs_list:
sources_list = sorted(self.data_libs[lib_folder]['sources'])
headers_list = sorted(self.data_libs[lib_folder]['headers'])
+ cxxflags_list = sorted(self.data_libs[lib_folder]['cxxflags'])
includepath_list = sorted(self.data_libs[lib_folder]['includepath'])
defines_list = sorted(self.data_libs[lib_folder]['defines'])
lib_loc = self.data_libs[lib_folder]['loc']
@@ -1730,13 +1739,15 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator):
sources = " \\\n".join(sources_list)
headers = " \\\n".join(headers_list)
+ cxxflags = " \\\n".join(cxxflags_list)
includepath = " \\\n".join(includepath_list)
defines = " \\\n".join(defines_list)
# create .pro file
qt_pro_file = '%s/%s.pro' % (lib_loc, lib_name)
try:
- content = QtCreatorIntegrationGenerator.pro_template % {'sources': sources, 'headers': headers, 'includepath': includepath, 'defines': defines}
+ content = QtCreatorIntegrationGenerator.pro_template % {'sources': sources, 'headers': headers,
+ 'cxxflags': cxxflags, 'includepath': includepath, 'defines': defines}
mode = 'w+'
with open(qt_pro_file, mode) as fpro:
fpro.write(content)
@@ -1799,6 +1810,8 @@ CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
+QMAKE_CXXFLAGS += %(cxxflags)s
+
INCLUDEPATH += %(includepath)s
SOURCES += %(sources)s