summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMårten Nordheim <marten.nordheim@qt.io>2020-02-07 14:01:18 +0100
committerMårten Nordheim <marten.nordheim@qt.io>2020-02-07 23:51:06 +0100
commit3568ad58f5e273d60f089a1b2d8c91c9535c8cad (patch)
tree36b1b8e8c5a90f21785be571f726bcad154268fb
parentf64694647a9a3d54fa5ecdaf2570e8c7404271a6 (diff)
Introduce a configure-time check for C++17 filesystem
Various compilers have various fun ways of failing to compile when it is used so let's check if they will work properly during configure rather than much later. Change-Id: Ia93d4b91b3d269b4cab2a5f677c3c89e06b44ce3 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
-rw-r--r--src/corelib/configure.json16
-rw-r--r--src/corelib/global/qconfig-bootstrapped.h1
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/main.cpp8
-rw-r--r--tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro6
4 files changed, 24 insertions, 7 deletions
diff --git a/src/corelib/configure.json b/src/corelib/configure.json
index b607c300dd..667f6e2104 100644
--- a/src/corelib/configure.json
+++ b/src/corelib/configure.json
@@ -366,6 +366,15 @@
"main": "std::mt19937 mt(0);"
}
},
+ "cxx17_filesystem": {
+ "label": "C++17 <filesystem>",
+ "type": "compile",
+ "test": {
+ "include": "filesystem",
+ "main": "std::filesystem::path p(\"./file\");",
+ "qmake": "CONFIG += c++17"
+ }
+ },
"eventfd": {
"label": "eventfd",
"type": "compile",
@@ -613,6 +622,13 @@
"condition": "tests.cxx11_future",
"output": [ "publicFeature" ]
},
+ "cxx17_filesystem": {
+ "label": "C++17 <filesystem>",
+ "condition": "tests.cxx17_filesystem",
+ "output": [
+ "publicFeature"
+ ]
+ },
"eventfd": {
"label": "eventfd",
"condition": "!config.wasm && tests.eventfd",
diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h
index 4a8a4598a0..5733864459 100644
--- a/src/corelib/global/qconfig-bootstrapped.h
+++ b/src/corelib/global/qconfig-bootstrapped.h
@@ -79,6 +79,7 @@
#define QT_FEATURE_cborstreamwriter 1
#define QT_CRYPTOGRAPHICHASH_ONLY_SHA1
#define QT_FEATURE_cxx11_random (__has_include(<random>) ? 1 : -1)
+#define QT_FEATURE_cxx17_filesystem -1
#define QT_NO_DATASTREAM
#define QT_FEATURE_datestring 1
#define QT_FEATURE_datetimeparser -1
diff --git a/tests/benchmarks/corelib/io/qdiriterator/main.cpp b/tests/benchmarks/corelib/io/qdiriterator/main.cpp
index 60c75ead4d..5b10a4a689 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/main.cpp
+++ b/tests/benchmarks/corelib/io/qdiriterator/main.cpp
@@ -44,11 +44,7 @@
#include "qfilesystemiterator.h"
-#if QT_HAS_INCLUDE(<filesystem>) && defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L
-#define HAS_STD_FILESYSTEM
-#endif
-
-#ifdef HAS_STD_FILESYSTEM
+#if QT_CONFIG(cxx17_filesystem)
#include <filesystem>
#endif
@@ -248,7 +244,7 @@ void tst_qdiriterator::fsiterator()
void tst_qdiriterator::stdRecursiveDirectoryIterator()
{
-#ifdef HAS_STD_FILESYSTEM
+#if QT_CONFIG(cxx17_filesystem)
QFETCH(QByteArray, dirpath);
int count = 0;
diff --git a/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro b/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro
index 4b28946f18..609a578321 100644
--- a/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro
+++ b/tests/benchmarks/corelib/io/qdiriterator/qdiriterator.pro
@@ -4,7 +4,11 @@ QT = core testlib
CONFIG += release
# Enable c++17 support for std::filesystem
-qtConfig(c++1z): CONFIG += c++17
+qtConfig(cxx17_filesystem) {
+ CONFIG += c++17
+ gcc:lessThan(QMAKE_GCC_MAJOR_VERSION, 9): \
+ QMAKE_LFLAGS += -lstdc++fs
+}
SOURCES += main.cpp qfilesystemiterator.cpp
HEADERS += qfilesystemiterator.h