summaryrefslogtreecommitdiffstats
path: root/mkspecs
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-02-14 13:40:57 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-04-21 09:05:14 +0000
commit591edbb11c73a51d5d6657ef4e3b585d556d7c68 (patch)
treec5245c29efe823715054569b3de23e32b9c58255 /mkspecs
parent17ae9305afb0c7f12bc8108bb12cf2f213272173 (diff)
Detect C standard and try using the most recent one (take 2)
Fixes the default C version used with gcc < 5 Change-Id: I948dece961caed8e6b181e1c6e6b9dc43c46583e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Diffstat (limited to 'mkspecs')
-rw-r--r--mkspecs/common/android-base-tail.conf2
-rw-r--r--mkspecs/common/clang.conf2
-rw-r--r--mkspecs/common/g++-base.conf2
-rw-r--r--mkspecs/common/gcc-base.conf3
-rw-r--r--mkspecs/features/default_post.prf13
-rw-r--r--mkspecs/features/qt_common.prf2
-rw-r--r--mkspecs/features/qt_configure.prf13
7 files changed, 35 insertions, 2 deletions
diff --git a/mkspecs/common/android-base-tail.conf b/mkspecs/common/android-base-tail.conf
index 7c3ae9566a..e239fa01c5 100644
--- a/mkspecs/common/android-base-tail.conf
+++ b/mkspecs/common/android-base-tail.conf
@@ -30,6 +30,8 @@ QMAKE_CFLAGS_THREAD = -D_REENTRANT
QMAKE_CFLAGS_HIDESYMS = -fvisibility=hidden
QMAKE_CFLAGS_NEON = -mfpu=neon
+QMAKE_CFLAGS_GNUC99 = -std=gnu99
+QMAKE_CFLAGS_GNUC11 = -std=gnu11
QMAKE_CXXFLAGS_CXX11 = -std=c++11
QMAKE_CXXFLAGS_CXX14 = -std=c++14
QMAKE_CXXFLAGS_CXX1Z = -std=c++1z
diff --git a/mkspecs/common/clang.conf b/mkspecs/common/clang.conf
index e003b947aa..6122a37213 100644
--- a/mkspecs/common/clang.conf
+++ b/mkspecs/common/clang.conf
@@ -21,6 +21,8 @@ QMAKE_CFLAGS_PRECOMPILE = -x c-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_
QMAKE_CFLAGS_USE_PRECOMPILE = -Xclang -include-pch -Xclang ${QMAKE_PCH_OUTPUT}
QMAKE_CFLAGS_LTCG = -flto
QMAKE_CFLAGS_DISABLE_LTCG = -fno-lto
+QMAKE_CFLAGS_GNUC99 = -std=gnu99
+QMAKE_CFLAGS_GNUC11 = -std=gnu11
QMAKE_CXXFLAGS_PRECOMPILE = -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
diff --git a/mkspecs/common/g++-base.conf b/mkspecs/common/g++-base.conf
index c42c46b0ec..fa0f0c391d 100644
--- a/mkspecs/common/g++-base.conf
+++ b/mkspecs/common/g++-base.conf
@@ -27,6 +27,8 @@ QMAKE_CFLAGS_USE_PRECOMPILE = -include ${QMAKE_PCH_OUTPUT_BASE}
QMAKE_CXXFLAGS_PRECOMPILE = -x c++-header -c ${QMAKE_PCH_INPUT} -o ${QMAKE_PCH_OUTPUT}
QMAKE_CXXFLAGS_USE_PRECOMPILE = $$QMAKE_CFLAGS_USE_PRECOMPILE
+QMAKE_CFLAGS_GNUC99 = -std=gnu99
+QMAKE_CFLAGS_GNUC11 = -std=gnu11
QMAKE_CXXFLAGS_CXX11 = -std=c++11
QMAKE_CXXFLAGS_CXX14 = -std=c++1y
QMAKE_CXXFLAGS_CXX1Z = -std=c++1z
diff --git a/mkspecs/common/gcc-base.conf b/mkspecs/common/gcc-base.conf
index 234f71d495..0407ba9724 100644
--- a/mkspecs/common/gcc-base.conf
+++ b/mkspecs/common/gcc-base.conf
@@ -81,6 +81,9 @@ QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO +=
QMAKE_LFLAGS_EXCEPTIONS_OFF +=
QMAKE_LFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG -fuse-linker-plugin
+QMAKE_CFLAGS_C99 = -std=c99
+QMAKE_CFLAGS_C11 = -std=c11
+
QMAKE_CFLAGS_SSE2 += -msse2
QMAKE_CFLAGS_SSE3 += -msse3
QMAKE_CFLAGS_SSSE3 += -mssse3
diff --git a/mkspecs/features/default_post.prf b/mkspecs/features/default_post.prf
index 5367b17973..ad4a5f6365 100644
--- a/mkspecs/features/default_post.prf
+++ b/mkspecs/features/default_post.prf
@@ -143,6 +143,19 @@ c++11|c++14|c++1z {
unset(cxxstd)
}
+c99|c11 {
+ c11: cstd = C11
+ else: cstd = C99
+
+ !isEmpty(QMAKE_CFLAGS_GNU$$cstd) {
+ !strict_c|isEmpty(QMAKE_CFLAGS_$$cstd): cstd = GNU$$cstd
+ }
+
+ QMAKE_CFLAGS += $$eval(QMAKE_CFLAGS_$$cstd)
+
+ unset(cstd)
+}
+
utf8_source {
QMAKE_CFLAGS += $$QMAKE_CFLAGS_UTF8_SOURCE
QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_UTF8_SOURCE
diff --git a/mkspecs/features/qt_common.prf b/mkspecs/features/qt_common.prf
index 93f9a2429d..638fbf38be 100644
--- a/mkspecs/features/qt_common.prf
+++ b/mkspecs/features/qt_common.prf
@@ -17,6 +17,8 @@ DEFINES *= QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
qtConfig(c++11): CONFIG += c++11 strict_c++
qtConfig(c++14): CONFIG += c++14
qtConfig(c++1z): CONFIG += c++1z
+qtConfig(c99): CONFIG += c99
+qtConfig(c11): CONFIG += c11
qtConfig(stack-protector-strong): CONFIG += stack_protector_strong
contains(TEMPLATE, .*lib) {
# module and plugins
diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf
index 6e29eaa2b7..70c763a2c3 100644
--- a/mkspecs/features/qt_configure.prf
+++ b/mkspecs/features/qt_configure.prf
@@ -870,6 +870,15 @@ defineTest(qtConfTestPrepare_compile) {
defineTest(qtConfPrepareCompileTestSource) {
test_dir = $$2
+ test_lang = $$eval($${1}.lang)
+ isEmpty(test_lang): test_lang = "c++"
+
+ equals(test_lang, "c++"): suffix = "cpp"
+ else: equals(test_lang, "c"): suffix = "c"
+ else: equals(test_lang, "objc"): suffix = "m"
+ else: equals(test_lang, "objc++"): suffix = "mm"
+ else: error("Unknown language '$$test_lang' in compile test $$1")
+
# Create source code
contents = "/* Generated by configure */"
# Custom code before includes
@@ -893,10 +902,10 @@ defineTest(qtConfPrepareCompileTestSource) {
" /* END TEST */" \
" return 0;" \
"}"
- write_file($$test_dir/main.cpp, contents)|error()
+ write_file($$test_dir/main.$$suffix, contents)|error()
# Create stub .pro file
- contents = "SOURCES = main.cpp"
+ contents = "SOURCES = main.$$suffix"
# Custom project code
for (ent, $$qtConfScalarOrList($${1}.qmake)): \
contents += $$ent