diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2016-09-28 18:54:29 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2016-10-10 16:59:10 +0000 |
commit | 310bf3f57c49ad0d05e479e088a62b06e7616ba8 (patch) | |
tree | 846a893f2bd4c2ad4a52f8b27dd8b48521e0f6d4 /mkspecs | |
parent | 33d748bb88676b69e596ae77badfeaf5a69a33d1 (diff) |
Make sure flags from library detections go to the right places
Split them and add -I flags to INCLUDEPATH and -D flags to
DEFINES. Anything else gets reported as a problem and dropped.
This has the benefit that qmake will automatically use -isystem for
those paths if they lie in a system directory. As a consequence of that,
we won't get any warnings in headers located there. There are multiple
cases of glib, gtk, etc. headers producing warnings (such as enums
ending in comma). This does not fix warnings produced by use of macros
declared in system headers, though...
Done-with: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Change-Id: I4b844cb518dbae5ea499811221f9015af985110a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'mkspecs')
-rw-r--r-- | mkspecs/common/linux.conf | 1 | ||||
-rw-r--r-- | mkspecs/features/qmake_use.prf | 9 | ||||
-rw-r--r-- | mkspecs/features/qt_configure.prf | 35 |
3 files changed, 28 insertions, 17 deletions
diff --git a/mkspecs/common/linux.conf b/mkspecs/common/linux.conf index 1a39c88425..13916a5646 100644 --- a/mkspecs/common/linux.conf +++ b/mkspecs/common/linux.conf @@ -36,7 +36,6 @@ QMAKE_LIBS_OPENGL_ES2 = -lGLESv2 QMAKE_LIBS_OPENVG = -lOpenVG QMAKE_LIBS_THREAD = -lpthread -QMAKE_CFLAGS_WAYLAND = QMAKE_INCDIR_WAYLAND = QMAKE_LIBS_WAYLAND_CLIENT = -lwayland-client QMAKE_LIBS_WAYLAND_SERVER = -lwayland-server diff --git a/mkspecs/features/qmake_use.prf b/mkspecs/features/qmake_use.prf index a8e2e6c417..81b841d457 100644 --- a/mkspecs/features/qmake_use.prf +++ b/mkspecs/features/qmake_use.prf @@ -10,16 +10,17 @@ for(ever) { else: \ libs = $$eval(QMAKE_LIBS_$${nu}_RELEASE) libs += $$eval(QMAKE_LIBS_$$nu) - cflags = $$eval(QMAKE_CFLAGS_$${nu}) + defines = $$eval(QMAKE_DEFINES_$${nu}) + includes = $$eval(QMAKE_INCDIR_$${nu}) - isEmpty(libs):isEmpty(cflags): \ + isEmpty(libs):isEmpty(defines):isEmpty(includes): \ error("Library '$$name' is not defined.") !contains(use, nolink): \ LIBS$${suffix} += $$libs !contains(use, linkonly) { - QMAKE_CFLAGS += $$cflags - QMAKE_CXXFLAGS += $$cflags + DEFINES += $$defines + INCLUDEPATH += $$includes } } !isEmpty(suffix): break() diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index 58e0b1c88e..7f575b8a1b 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -475,8 +475,6 @@ defineTest(qtConfLibrary_inline) { !isEmpty(prefix) { $${1}.includedir = $$prefix/include export($${1}.includedir) - $${1}.cflags = -I$$prefix/include - export($${1}.cflags) $${1}.libs = "-L$$prefix/lib $$eval($${1}.libs)" export($${1}.libs) } @@ -493,8 +491,6 @@ defineTest(qtConfLibrary_makeSpec) { $${1}.includedir = "$$val_escape(QMAKE_INCDIR_$$spec)" export($${1}.includedir) - $${1}.cflags = "$$val_escape(QMAKE_CFLAGS_$$spec)" - export($${1}.cflags) libs = for (l, QMAKE_LIBDIR_$$spec): \ libs += -L$$l @@ -522,15 +518,8 @@ defineTest(qtConfLibrary_pkgConfig) { qtRunLoggedCommand("$$pkg_config --modversion $$args", version)|return(false) qtRunLoggedCommand("$$pkg_config --libs-only-L --libs-only-l $$args", $${1}.libs)|return(false) qtRunLoggedCommand("$$pkg_config --cflags $$args", $${1}.cflags)|return(false) - qtRunLoggedCommand("$$pkg_config --cflags-only-I $$args", includes)|return(false) - eval(includes = $$includes) - includes ~= s/^-I//g - $${1}.includedir = "$$val_escape(includes)" version ~= s/[^0-9.].*$// $${1}.version = $$first(version) - export($${1}.libs) - export($${1}.cflags) - export($${1}.includedir) export($${1}.version) return(true) } @@ -562,6 +551,9 @@ defineReplace(qtConfLibraryArgs) { includedir = $$eval($${1}.includedir) !isEmpty(includedir): \ qmake_args += $$system_quote(INCLUDEPATH *= $$includedir) + cflags = $$eval($${1}.cflags) + !isEmpty(cflags): \ + qmake_args += $$system_quote(QMAKE_CFLAGS += $$cflags) $$system_quote(QMAKE_CXXFLAGS += $$cflags) return($$qmake_args) } @@ -588,12 +580,31 @@ defineTest(qtConfExportLibrary) { eval(includes = $$eval($${1}.includedir)) version = $$eval($${1}.version) + # Split $$cflags into stuff that goes into DEFINES, INCLUDEPATH, and other stuff. + defines = + ignored = + for (i, cflags) { + contains(i, "-I.*") { + i ~= s/^-I// + includes += $$i + } else: contains(i, "-D.*") { + i ~= s/^-D// + defines += $$i + } else { + # Sometimes, pkg-config files or *-config scripts include other flags + # we really don't need and shouldn't add (pg_config is really bad). + ignored += $$i + } + } + !isEmpty(ignored): \ + qtConfAddNote("Dropped compiler flags '$$ignored' when detecting library '$$2'.") + NAME = $$upper($$2) !isEmpty(libs): qtConfOutputVar(assign, $$output, QMAKE_LIBS_$$NAME, $$libs) for (b, $${1}.builds._KEYS_): \ qtConfOutputVar(assign, $$output, QMAKE_LIBS_$${NAME}_$$upper($$b), \ $$eval($${1}.builds.$${b})) - !isEmpty(cflags): qtConfOutputVar(assign, $$output, QMAKE_CFLAGS_$$NAME, $$cflags) + !isEmpty(defines): qtConfOutputVar(assign, $$output, QMAKE_DEFINES_$$NAME, $$defines) !isEmpty(includes): qtConfOutputVar(assign, $$output, QMAKE_INCDIR_$$NAME, $$includes) !isEmpty(version) { qtConfOutputVar(assign, $$output, QMAKE_$${NAME}_VERSION, $$version) |