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>
This commit is contained in:
parent
f64694647a
commit
3568ad58f5
@ -366,6 +366,15 @@
|
|||||||
"main": "std::mt19937 mt(0);"
|
"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": {
|
"eventfd": {
|
||||||
"label": "eventfd",
|
"label": "eventfd",
|
||||||
"type": "compile",
|
"type": "compile",
|
||||||
@ -613,6 +622,13 @@
|
|||||||
"condition": "tests.cxx11_future",
|
"condition": "tests.cxx11_future",
|
||||||
"output": [ "publicFeature" ]
|
"output": [ "publicFeature" ]
|
||||||
},
|
},
|
||||||
|
"cxx17_filesystem": {
|
||||||
|
"label": "C++17 <filesystem>",
|
||||||
|
"condition": "tests.cxx17_filesystem",
|
||||||
|
"output": [
|
||||||
|
"publicFeature"
|
||||||
|
]
|
||||||
|
},
|
||||||
"eventfd": {
|
"eventfd": {
|
||||||
"label": "eventfd",
|
"label": "eventfd",
|
||||||
"condition": "!config.wasm && tests.eventfd",
|
"condition": "!config.wasm && tests.eventfd",
|
||||||
|
@ -79,6 +79,7 @@
|
|||||||
#define QT_FEATURE_cborstreamwriter 1
|
#define QT_FEATURE_cborstreamwriter 1
|
||||||
#define QT_CRYPTOGRAPHICHASH_ONLY_SHA1
|
#define QT_CRYPTOGRAPHICHASH_ONLY_SHA1
|
||||||
#define QT_FEATURE_cxx11_random (__has_include(<random>) ? 1 : -1)
|
#define QT_FEATURE_cxx11_random (__has_include(<random>) ? 1 : -1)
|
||||||
|
#define QT_FEATURE_cxx17_filesystem -1
|
||||||
#define QT_NO_DATASTREAM
|
#define QT_NO_DATASTREAM
|
||||||
#define QT_FEATURE_datestring 1
|
#define QT_FEATURE_datestring 1
|
||||||
#define QT_FEATURE_datetimeparser -1
|
#define QT_FEATURE_datetimeparser -1
|
||||||
|
@ -44,11 +44,7 @@
|
|||||||
|
|
||||||
#include "qfilesystemiterator.h"
|
#include "qfilesystemiterator.h"
|
||||||
|
|
||||||
#if QT_HAS_INCLUDE(<filesystem>) && defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L
|
#if QT_CONFIG(cxx17_filesystem)
|
||||||
#define HAS_STD_FILESYSTEM
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef HAS_STD_FILESYSTEM
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -248,7 +244,7 @@ void tst_qdiriterator::fsiterator()
|
|||||||
|
|
||||||
void tst_qdiriterator::stdRecursiveDirectoryIterator()
|
void tst_qdiriterator::stdRecursiveDirectoryIterator()
|
||||||
{
|
{
|
||||||
#ifdef HAS_STD_FILESYSTEM
|
#if QT_CONFIG(cxx17_filesystem)
|
||||||
QFETCH(QByteArray, dirpath);
|
QFETCH(QByteArray, dirpath);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -4,7 +4,11 @@ QT = core testlib
|
|||||||
|
|
||||||
CONFIG += release
|
CONFIG += release
|
||||||
# Enable c++17 support for std::filesystem
|
# 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
|
SOURCES += main.cpp qfilesystemiterator.cpp
|
||||||
HEADERS += qfilesystemiterator.h
|
HEADERS += qfilesystemiterator.h
|
||||||
|
Loading…
x
Reference in New Issue
Block a user