summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMichael Weghorn <m.weghorn@posteo.de>2023-10-16 14:39:42 +0200
committerMichael Weghorn <m.weghorn@posteo.de>2023-10-16 18:29:23 +0200
commitf8be1b73847514bb8e2054dc6d8a62e00682ab78 (patch)
tree03ab2ca35df28b862626637458d43232342662d1 /bin
parentf26bf09a0e93449ea85269a09a8a073a20903349 (diff)
qtcreator: Specify C++ std version using CONFIG qmake var
Extract the C++ standard version to use that is specified by a `-std=<version>` or `-std:<version>` compiler flag, and set that via "CONFIG += <version>" in the .pro files used by Qt Creator. This makes the Clang Code Model use the correct mode and no longer complain about `char8_t` after the switch to C++20 in my Windows development setup in Qt Creator: > accessibletabbarpagelist.hxx:22:10: In included file: use of undeclared identifier 'char8_t' > stringutils.hxx:252:31: error occurred here The previous way of specifying this via `QMAKE_CXXFLAGS` as introduced in commit 92c03d9bf644b0f10de52ce0da09f97056e46247 Author: Michael Weghorn <m.weghorn@posteo.de> Date: Fri Jun 7 21:44:03 2019 +0200 qtcreator: Take over '-std=...' from CXXFLAGS appears to not (no longer?) work at least with Qt Creator 11.0.3 on Windows. On the contrary however, setting only `CONFIG` and not `QMAKE_CXXFLAGS` causes the exact same problem in my Linux setup. Therefore, set both qmake variables. Note that there is a specific set of accepted values for the the `CONFIG` variable in .pro files [1], but at least "c++20" and "c++latest" are accepted and have the expected meaning, so that should be fine for now. [1] https://doc.qt.io/qt-6/qmake-variable-reference.html#config Change-Id: Idc75b74300c7bdd0f6193fcfc1758b536728b887 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158053 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/gbuild-to-ide21
1 files changed, 12 insertions, 9 deletions
diff --git a/bin/gbuild-to-ide b/bin/gbuild-to-ide
index b56cff8585ea..f428f451e990 100755
--- a/bin/gbuild-to-ide
+++ b/bin/gbuild-to-ide
@@ -1718,11 +1718,11 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator):
if path:
headers_list.append(lopath(path))
- cxxflags_list = []
+ cxxstdversionflag = ''
for cxxflag in lib.cxxflags:
# extract flag for C++ standard version
if cxxflag.startswith('-std'):
- cxxflags_list.append(cxxflag)
+ cxxstdversionflag = cxxflag
# List all include paths
for hdir in (lib.include + lib.include_sys):
@@ -1749,14 +1749,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]['cxxstdversionflag'] = cxxstdversionflag
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),
+ 'cxxstdversionflag': cxxstdversionflag,
'includepath': set(includepath_list),
'defines': set(defines_list),
'loc': lib.location,
@@ -1779,7 +1779,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'])
+ cxxstdversionflag = self.data_libs[lib_folder]['cxxstdversionflag']
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']
@@ -1787,16 +1787,18 @@ 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)
+ # strip '-std=' or '-std:' prefix
+ assert(isinstance(cxxstdversionflag, str) and cxxstdversionflag.startswith('-std'))
+ cxxstdversion = cxxstdversionflag[5:]
# create .pro file
subdirs_meta_pro.append(lib_name)
qt_pro_file = os.path.join(self.base_folder, lib_name, lib_name + '.pro')
try:
- content = QtCreatorIntegrationGenerator.pro_template % {'sources': sources, 'headers': headers,
- 'cxxflags': cxxflags, 'includepath': includepath, 'defines': defines}
+ content = QtCreatorIntegrationGenerator.pro_template % {'sources': sources, 'headers': headers, 'cxxstdversionflag': cxxstdversionflag,
+ 'cxxstdversion': cxxstdversion, 'includepath': includepath, 'defines': defines}
with open(qt_pro_file, mode) as fpro:
fpro.write(content)
self._log("created %s\n" % qt_pro_file)
@@ -1857,8 +1859,9 @@ class QtCreatorIntegrationGenerator(IdeIntegrationGenerator):
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
+CONFIG += %(cxxstdversion)s
-QMAKE_CXXFLAGS += %(cxxflags)s
+QMAKE_CXXFLAGS += %(cxxstdversionflag)s
INCLUDEPATH += %(includepath)s