summaryrefslogtreecommitdiffstats
path: root/mkspecs/features
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-03-21 13:52:10 +0000
commita47cb146809e32f43449dcfe9932833c2f0ab987 (patch)
treeeea6a33781db5aa4aa303c04b77ca66734e8c78a /mkspecs/features
parent5f66486cc254e1483f776d3058f96db493fd26e5 (diff)
Detect C standard and try using the most recent
Fixes the default C version used with gcc < 5 Change-Id: I948dece961caed8e6b181e1c6e6b9dc43c46583f Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Diffstat (limited to 'mkspecs/features')
-rw-r--r--mkspecs/features/default_post.prf15
-rw-r--r--mkspecs/features/qt_common.prf2
-rw-r--r--mkspecs/features/qt_configure.prf13
3 files changed, 28 insertions, 2 deletions
diff --git a/mkspecs/features/default_post.prf b/mkspecs/features/default_post.prf
index 9eba5bcf00..bf5acdefc4 100644
--- a/mkspecs/features/default_post.prf
+++ b/mkspecs/features/default_post.prf
@@ -143,6 +143,21 @@ c++11|c++14|c++1z {
unset(cxxstd)
}
+c99|c11 {
+ c11: cstd = C11
+ else: cstd = C99
+
+ # Check if we should disable compiler extensions or not
+ !isEmpty(QMAKE_CFLAGS_GNU$$cstd) {
+ # Let strict C++ imply strict C
+ !strict_c++: 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 f4ae5bde80..40f03d2186 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 98fff59ea1..a7da26c745 100644
--- a/mkspecs/features/qt_configure.prf
+++ b/mkspecs/features/qt_configure.prf
@@ -866,6 +866,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
@@ -889,10 +898,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