diff options
author | Ivan Komissarov <ABBAPOH@gmail.com> | 2021-10-12 09:24:54 +0200 |
---|---|---|
committer | Ivan Komissarov <ABBAPOH@gmail.com> | 2021-10-12 12:37:22 +0000 |
commit | f389314e8b685d7c3c6183a5ab4f86a6af922d4b (patch) | |
tree | f6dc38cd1fb32d0645fc690b33754199b6c9949e | |
parent | 2d50ed99524d9d9144a01be810ba3ecccad76a5f (diff) | |
download | qbs-f389314e8b685d7c3c6183a5ab4f86a6af922d4b.tar.gz |
Use experimental filesystem with GCC-7
Change-Id: I49a45cd48f861186cc55fcf304ed69e0481c2908
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r-- | src/lib/pkgconfig/CMakeLists.txt | 7 | ||||
-rw-r--r-- | src/lib/pkgconfig/pcparser.cpp | 10 | ||||
-rw-r--r-- | src/lib/pkgconfig/pkgconfig.cpp | 12 | ||||
-rw-r--r-- | src/lib/pkgconfig/pkgconfig.qbs | 5 | ||||
-rw-r--r-- | src/lib/pkgconfig/use_pkgconfig.pri | 10 |
5 files changed, 40 insertions, 4 deletions
diff --git a/src/lib/pkgconfig/CMakeLists.txt b/src/lib/pkgconfig/CMakeLists.txt index 3ab12e94e..551e2bfef 100644 --- a/src/lib/pkgconfig/CMakeLists.txt +++ b/src/lib/pkgconfig/CMakeLists.txt @@ -14,6 +14,11 @@ else() set(HAS_STD_FILESYSTEM "1") endif() +set(QBS_PKGCONFIG_PUBLIC_DEPENDS "") +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) + set(QBS_PKGCONFIG_PUBLIC_DEPENDS "stdc++fs") +endif() + add_qbs_library(qbspkgconfig STATIC DEFINES @@ -22,6 +27,6 @@ add_qbs_library(qbspkgconfig "HAS_STD_FILESYSTEM=${HAS_STD_FILESYSTEM}" PUBLIC_DEFINES "QBS_PC_WITH_QT_SUPPORT=1" - PUBLIC_DEPENDS Qt${QT_VERSION_MAJOR}::Core + PUBLIC_DEPENDS Qt${QT_VERSION_MAJOR}::Core ${QBS_PKGCONFIG_PUBLIC_DEPENDS} SOURCES ${SOURCES} ) diff --git a/src/lib/pkgconfig/pcparser.cpp b/src/lib/pkgconfig/pcparser.cpp index 7ce77618a..b72a984f5 100644 --- a/src/lib/pkgconfig/pcparser.cpp +++ b/src/lib/pkgconfig/pcparser.cpp @@ -42,7 +42,15 @@ #include "pkgconfig.h" #if HAS_STD_FILESYSTEM -#include <filesystem> +# if __has_include(<filesystem>) +# include <filesystem> +# else +# include <experimental/filesystem> +// We need the alias from std::experimental::filesystem to std::filesystem +namespace std { + namespace filesystem = experimental::filesystem; +} +# endif #else #include <QFileInfo> #endif diff --git a/src/lib/pkgconfig/pkgconfig.cpp b/src/lib/pkgconfig/pkgconfig.cpp index 871dff99c..6c1179eae 100644 --- a/src/lib/pkgconfig/pkgconfig.cpp +++ b/src/lib/pkgconfig/pkgconfig.cpp @@ -41,7 +41,15 @@ #include "pcparser.h" #if HAS_STD_FILESYSTEM -# include <filesystem> +# if __has_include(<filesystem>) +# include <filesystem> +# else +# include <experimental/filesystem> +// We need the alias from std::experimental::filesystem to std::filesystem +namespace std { + namespace filesystem = experimental::filesystem; +} +# endif #else # include <QtCore/QDir> # include <QtCore/QFileInfo> @@ -184,7 +192,7 @@ std::vector<std::string> getPcFilePaths(const std::vector<std::string> &searchPa std::vector<std::filesystem::path> paths; for (const auto &searchPath : searchPaths) { - if (!std::filesystem::directory_entry(searchPath).exists()) + if (!std::filesystem::exists(std::filesystem::directory_entry(searchPath).status())) continue; const auto dir = std::filesystem::directory_iterator(searchPath); std::copy_if( diff --git a/src/lib/pkgconfig/pkgconfig.qbs b/src/lib/pkgconfig/pkgconfig.qbs index 25bcb3fdf..e6894429e 100644 --- a/src/lib/pkgconfig/pkgconfig.qbs +++ b/src/lib/pkgconfig/pkgconfig.qbs @@ -57,5 +57,10 @@ QbsStaticLibrary { Export { Depends { name: "cpp" } cpp.defines: exportingProduct.publicDefines + cpp.staticLibraries: { + if (qbs.toolchainType === "gcc" && cpp.compilerVersionMajor === 7) + return ["stdc++fs"]; + return []; + } } } diff --git a/src/lib/pkgconfig/use_pkgconfig.pri b/src/lib/pkgconfig/use_pkgconfig.pri index baccff360..d6fd2205c 100644 --- a/src/lib/pkgconfig/use_pkgconfig.pri +++ b/src/lib/pkgconfig/use_pkgconfig.pri @@ -28,6 +28,16 @@ win32 { LIBS += $${QBSPKGCONFIG_LIB} } +gcc { + isEmpty(COMPILER_VERSION) { + COMPILER_VERSION = $$system($$QMAKE_CXX " -dumpversion") + COMPILER_MAJOR_VERSION = $$str_member($$COMPILER_VERSION) + equals(COMPILER_MAJOR_VERSION, 7) { + LIBS += -lstdc++fs + } + } +} + INCLUDEPATH += \ $$PWD |