From d61cee0ed87eccbc7ebf14ac03a9c1adca162195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20M=C3=A4=C3=A4tt=C3=A4?= Date: Mon, 13 Nov 2023 11:49:34 +0200 Subject: [PATCH] Fix build with std::filesystem Use cxx17_filesystem config instead of Q_OS_INTEGRITY. Change-Id: I1d3fdae449a534dd25a32ce2820a4ebf788de2b0 Reviewed-by: Hatem ElKharashy Reviewed-by: Janne Koskinen --- src/plugins/tracing/CMakeLists.txt | 5 +++++ src/plugins/tracing/qctflib.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/plugins/tracing/CMakeLists.txt b/src/plugins/tracing/CMakeLists.txt index 94e9eccfdd..823e11c174 100644 --- a/src/plugins/tracing/CMakeLists.txt +++ b/src/plugins/tracing/CMakeLists.txt @@ -25,3 +25,8 @@ qt_internal_extend_target(QCtfTracePlugin CONDITION QT_FEATURE_zstd LIBRARIES WrapZSTD::WrapZSTD ) + +qt_internal_extend_target(QCtfTracePlugin CONDITION (QT_FEATURE_cxx17_filesystem) AND (GCC AND (QMAKE_GCC_MAJOR_VERSION LESS 9)) + LINK_OPTIONS + "-lstdc++fs" +) diff --git a/src/plugins/tracing/qctflib.cpp b/src/plugins/tracing/qctflib.cpp index dc8bd77bd4..fe3946d27c 100644 --- a/src/plugins/tracing/qctflib.cpp +++ b/src/plugins/tracing/qctflib.cpp @@ -15,7 +15,7 @@ #include #include "qctflib_p.h" -#ifndef Q_OS_INTEGRITY +#if QT_CONFIG(cxx17_filesystem) #include #endif @@ -121,7 +121,7 @@ QCtfLibImpl::QCtfLibImpl() m_session.tracepoints.append(allLiteral()); m_session.name = defaultLiteral(); } else { -#ifdef Q_OS_INTEGRITY +#if !QT_CONFIG(cxx17_filesystem) qCWarning(lcDebugTrace) << "Unable to use filesystem"; return; #endif @@ -168,7 +168,7 @@ QCtfLibImpl::QCtfLibImpl() m_session.name = defaultLiteral(); } m_location = location + u"/ust"; -#ifndef Q_OS_INTEGRITY +#if QT_CONFIG(cxx17_filesystem) std::filesystem::create_directory(qPrintable(m_location), qPrintable(location)); #endif } @@ -185,7 +185,7 @@ QCtfLibImpl::QCtfLibImpl() void QCtfLibImpl::clearLocation() { -#ifndef Q_OS_INTEGRITY +#if QT_CONFIG(cxx17_filesystem) const std::filesystem::path location{qUtf16Printable(m_location)}; for (auto const& dirEntry : std::filesystem::directory_iterator{location}) {