|
|
|
|
@@ -0,0 +1,452 @@
|
|
|
|
|
From 66690965385fcc9f71fbb3caccfdeb123dfca688 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: Ryan Pavlik <ryan.pavlik@collabora.com>
|
|
|
|
|
Date: Fri, 13 Aug 2021 11:21:50 -0500
|
|
|
|
|
Subject: [PATCH 1/5] Split the filesystem conditionals into a separate header
|
|
|
|
|
to share with detection.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
src/common/filesystem_utils.cpp | 35 +------------------------
|
|
|
|
|
src/common/stdfs_conditions.h | 45 +++++++++++++++++++++++++++++++++
|
|
|
|
|
2 files changed, 46 insertions(+), 34 deletions(-)
|
|
|
|
|
create mode 100644 src/common/stdfs_conditions.h
|
|
|
|
|
|
|
|
|
|
diff --git a/src/common/filesystem_utils.cpp b/src/common/filesystem_utils.cpp
|
|
|
|
|
index 3b0685de..d3d4182f 100644
|
|
|
|
|
--- a/src/common/filesystem_utils.cpp
|
|
|
|
|
+++ b/src/common/filesystem_utils.cpp
|
|
|
|
|
@@ -20,40 +20,7 @@
|
|
|
|
|
#define USE_FINAL_FS 0
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
-// If the C++ macro is set to the version containing C++17, it must support
|
|
|
|
|
-// the final C++17 package
|
|
|
|
|
-#if __cplusplus >= 201703L
|
|
|
|
|
-#define USE_EXPERIMENTAL_FS 0
|
|
|
|
|
-#define USE_FINAL_FS 1
|
|
|
|
|
-
|
|
|
|
|
-#elif defined(_MSC_VER) && _MSC_VER >= 1900
|
|
|
|
|
-
|
|
|
|
|
-#if defined(_HAS_CXX17) && _HAS_CXX17
|
|
|
|
|
-// When MSC supports c++17 use <filesystem> package.
|
|
|
|
|
-#define USE_EXPERIMENTAL_FS 0
|
|
|
|
|
-#define USE_FINAL_FS 1
|
|
|
|
|
-#endif // !_HAS_CXX17
|
|
|
|
|
-
|
|
|
|
|
-// Right now, GCC still only supports the experimental filesystem items starting in GCC 6
|
|
|
|
|
-#elif (__GNUC__ >= 6)
|
|
|
|
|
-#define USE_EXPERIMENTAL_FS 1
|
|
|
|
|
-#define USE_FINAL_FS 0
|
|
|
|
|
-
|
|
|
|
|
-// If Clang, check for feature support
|
|
|
|
|
-#elif defined(__clang__) && (__cpp_lib_filesystem || __cpp_lib_experimental_filesystem)
|
|
|
|
|
-#if __cpp_lib_filesystem
|
|
|
|
|
-#define USE_EXPERIMENTAL_FS 0
|
|
|
|
|
-#define USE_FINAL_FS 1
|
|
|
|
|
-#else
|
|
|
|
|
-#define USE_EXPERIMENTAL_FS 1
|
|
|
|
|
-#define USE_FINAL_FS 0
|
|
|
|
|
-#endif
|
|
|
|
|
-
|
|
|
|
|
-// If all above fails, fall back to standard C++ and OS-specific items
|
|
|
|
|
-#else
|
|
|
|
|
-#define USE_EXPERIMENTAL_FS 0
|
|
|
|
|
-#define USE_FINAL_FS 0
|
|
|
|
|
-#endif
|
|
|
|
|
+#include "stdfs_conditions.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if USE_FINAL_FS == 1
|
|
|
|
|
diff --git a/src/common/stdfs_conditions.h b/src/common/stdfs_conditions.h
|
|
|
|
|
new file mode 100644
|
|
|
|
|
index 00000000..52e8a1df
|
|
|
|
|
--- /dev/null
|
|
|
|
|
+++ b/src/common/stdfs_conditions.h
|
|
|
|
|
@@ -0,0 +1,45 @@
|
|
|
|
|
+// Copyright (c) 2017-2021 The Khronos Group Inc.
|
|
|
|
|
+// Copyright (c) 2017 Valve Corporation
|
|
|
|
|
+// Copyright (c) 2017 LunarG, Inc.
|
|
|
|
|
+//
|
|
|
|
|
+// SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
|
|
|
+
|
|
|
|
|
+#ifndef _STDFS_CONDITIONS_H
|
|
|
|
|
+#define _STDFS_CONDITIONS_H
|
|
|
|
|
+
|
|
|
|
|
+// If the C++ macro is set to the version containing C++17, it must support
|
|
|
|
|
+// the final C++17 package
|
|
|
|
|
+#if __cplusplus >= 201703L
|
|
|
|
|
+#define USE_EXPERIMENTAL_FS 0
|
|
|
|
|
+#define USE_FINAL_FS 1
|
|
|
|
|
+
|
|
|
|
|
+#elif defined(_MSC_VER) && _MSC_VER >= 1900
|
|
|
|
|
+
|
|
|
|
|
+#if defined(_HAS_CXX17) && _HAS_CXX17
|
|
|
|
|
+// When MSC supports c++17 use <filesystem> package.
|
|
|
|
|
+#define USE_EXPERIMENTAL_FS 0
|
|
|
|
|
+#define USE_FINAL_FS 1
|
|
|
|
|
+#endif // !_HAS_CXX17
|
|
|
|
|
+
|
|
|
|
|
+// GCC supports the experimental filesystem items starting in GCC 6
|
|
|
|
|
+#elif (__GNUC__ >= 6)
|
|
|
|
|
+#define USE_EXPERIMENTAL_FS 1
|
|
|
|
|
+#define USE_FINAL_FS 0
|
|
|
|
|
+
|
|
|
|
|
+// If Clang, check for feature support
|
|
|
|
|
+#elif defined(__clang__) && (__cpp_lib_filesystem || __cpp_lib_experimental_filesystem)
|
|
|
|
|
+#if __cpp_lib_filesystem
|
|
|
|
|
+#define USE_EXPERIMENTAL_FS 0
|
|
|
|
|
+#define USE_FINAL_FS 1
|
|
|
|
|
+#else
|
|
|
|
|
+#define USE_EXPERIMENTAL_FS 1
|
|
|
|
|
+#define USE_FINAL_FS 0
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+// If all above fails, fall back to standard C++ and OS-specific items
|
|
|
|
|
+#else
|
|
|
|
|
+#define USE_EXPERIMENTAL_FS 0
|
|
|
|
|
+#define USE_FINAL_FS 0
|
|
|
|
|
+#endif
|
|
|
|
|
+
|
|
|
|
|
+#endif // !_STDFS_CONDITIONS_H
|
|
|
|
|
|
|
|
|
|
From 0eec6af8fd08c4e0e5f63d3e4d4381fa41634ac3 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: Ryan Pavlik <ryan.pavlik@collabora.com>
|
|
|
|
|
Date: Fri, 13 Aug 2021 11:30:01 -0500
|
|
|
|
|
Subject: [PATCH 2/5] build: Port StdFilesystemFlags.cmake to use that same
|
|
|
|
|
header.
|
|
|
|
|
|
|
|
|
|
Better than including the code in this file.
|
|
|
|
|
---
|
|
|
|
|
src/cmake/StdFilesystemFlags.cmake | 44 ++++++++----------------------
|
|
|
|
|
1 file changed, 12 insertions(+), 32 deletions(-)
|
|
|
|
|
|
|
|
|
|
diff --git a/src/cmake/StdFilesystemFlags.cmake b/src/cmake/StdFilesystemFlags.cmake
|
|
|
|
|
index b3e5c14b..0eb1e1d5 100644
|
|
|
|
|
--- a/src/cmake/StdFilesystemFlags.cmake
|
|
|
|
|
+++ b/src/cmake/StdFilesystemFlags.cmake
|
|
|
|
|
@@ -2,6 +2,8 @@
|
|
|
|
|
#
|
|
|
|
|
# SPDX-License-Identifier: BSL-1.0
|
|
|
|
|
|
|
|
|
|
+set(_FILESYSTEM_UTILS_DIR "${PROJECT_SOURCE_DIR}/src/common")
|
|
|
|
|
+
|
|
|
|
|
if(MSVC AND MSVC_VERSION GREATER 1890)
|
|
|
|
|
set(HAVE_FILESYSTEM_WITHOUT_LIB
|
|
|
|
|
ON
|
|
|
|
|
@@ -26,37 +28,13 @@ else()
|
|
|
|
|
}
|
|
|
|
|
"
|
|
|
|
|
)
|
|
|
|
|
- set(_stdfs_conditions
|
|
|
|
|
- "// If the C++ macro is set to the version containing C++17, it must support
|
|
|
|
|
- // the final C++17 package
|
|
|
|
|
- #if __cplusplus >= 201703L
|
|
|
|
|
- #define USE_FINAL_FS 1
|
|
|
|
|
-
|
|
|
|
|
- #elif defined(_MSC_VER) && _MSC_VER >= 1900
|
|
|
|
|
-
|
|
|
|
|
- #if defined(_HAS_CXX17) && _HAS_CXX17
|
|
|
|
|
- // When MSC supports c++17 use <filesystem> package.
|
|
|
|
|
- #define USE_FINAL_FS 1
|
|
|
|
|
- #endif // !_HAS_CXX17
|
|
|
|
|
-
|
|
|
|
|
- // Right now, GCC still only supports the experimental filesystem items starting in GCC 6
|
|
|
|
|
- #elif (__GNUC__ >= 6)
|
|
|
|
|
- #define USE_EXPERIMENTAL_FS 1
|
|
|
|
|
|
|
|
|
|
- // If Clang, check for feature support
|
|
|
|
|
- #elif defined(__clang__) && (__cpp_lib_filesystem || __cpp_lib_experimental_filesystem)
|
|
|
|
|
- #if __cpp_lib_filesystem
|
|
|
|
|
- #define USE_FINAL_FS 1
|
|
|
|
|
- #else
|
|
|
|
|
- #define USE_EXPERIMENTAL_FS 1
|
|
|
|
|
- #endif
|
|
|
|
|
+ set(_stdfs_conditions "#include <stdfs_conditions.h>
|
|
|
|
|
+ ")
|
|
|
|
|
|
|
|
|
|
- #endif
|
|
|
|
|
- "
|
|
|
|
|
- )
|
|
|
|
|
set(_stdfs_source
|
|
|
|
|
"${_stdfs_conditions}
|
|
|
|
|
- #ifdef USE_FINAL_FS
|
|
|
|
|
+ #if defined(USE_FINAL_FS) && USE_FINAL_FS
|
|
|
|
|
#include <filesystem>
|
|
|
|
|
using namespace std::filesystem;
|
|
|
|
|
#endif
|
|
|
|
|
@@ -65,7 +43,7 @@ else()
|
|
|
|
|
)
|
|
|
|
|
set(_stdfs_experimental_source
|
|
|
|
|
"${_stdfs_conditions}
|
|
|
|
|
- #ifdef USE_EXPERIMENTAL_FS
|
|
|
|
|
+ #if defined(USE_EXPERIMENTAL_FS) && USE_EXPERIMENTAL_FS
|
|
|
|
|
#include <experimental/filesystem>
|
|
|
|
|
using namespace std::experimental::filesystem;
|
|
|
|
|
#endif
|
|
|
|
|
@@ -74,11 +52,11 @@ else()
|
|
|
|
|
)
|
|
|
|
|
set(_stdfs_needlib_source
|
|
|
|
|
"${_stdfs_conditions}
|
|
|
|
|
- #ifdef USE_FINAL_FS
|
|
|
|
|
+ #if defined(USE_FINAL_FS) && USE_FINAL_FS
|
|
|
|
|
#include <filesystem>
|
|
|
|
|
using namespace std::filesystem;
|
|
|
|
|
#endif
|
|
|
|
|
- #ifdef USE_EXPERIMENTAL_FS
|
|
|
|
|
+ #if defined(USE_EXPERIMENTAL_FS) && USE_EXPERIMENTAL_FS
|
|
|
|
|
#include <experimental/filesystem>
|
|
|
|
|
using namespace std::experimental::filesystem;
|
|
|
|
|
#endif
|
|
|
|
|
@@ -88,8 +66,10 @@ else()
|
|
|
|
|
|
|
|
|
|
# First, just look for the include.
|
|
|
|
|
# We're checking if it compiles, not if the include exists,
|
|
|
|
|
- # because the source code uses similar conditionals to decide.
|
|
|
|
|
+ # because the source code uses the same conditionals to decide.
|
|
|
|
|
+ # (Static libraries are just object files, they don't get linked)
|
|
|
|
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
|
|
|
|
+ set(CMAKE_REQUIRED_INCLUDES "${_FILESYSTEM_UTILS_DIR}")
|
|
|
|
|
unset(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
|
unset(CMAKE_REQUIRED_FLAGS)
|
|
|
|
|
check_cxx_source_compiles("${_stdfs_source}" HAVE_FILESYSTEM_IN_STD)
|
|
|
|
|
@@ -121,7 +101,7 @@ else()
|
|
|
|
|
check_cxx_source_compiles("${_stdfs_needlib_source}" HAVE_FILESYSTEM_NEEDING_LIBCXXFS)
|
|
|
|
|
unset(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
|
unset(CMAKE_TRY_COMPILE_TARGET_TYPE)
|
|
|
|
|
-
|
|
|
|
|
+ unset(CMAKE_REQUIRED_INCLUDES)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
function(openxr_add_filesystem_utils TARGET_NAME)
|
|
|
|
|
|
|
|
|
|
From 288ab9228c866fefb50254f29f6925422df1580a Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: Ryan Pavlik <ryan.pavlik@collabora.com>
|
|
|
|
|
Date: Fri, 13 Aug 2021 11:30:16 -0500
|
|
|
|
|
Subject: [PATCH 3/5] build: Clean up and document StdFilesystemFlags.cmake
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
src/cmake/StdFilesystemFlags.cmake | 62 ++++++++++++++++++++++++++++--
|
|
|
|
|
1 file changed, 58 insertions(+), 4 deletions(-)
|
|
|
|
|
|
|
|
|
|
diff --git a/src/cmake/StdFilesystemFlags.cmake b/src/cmake/StdFilesystemFlags.cmake
|
|
|
|
|
index 0eb1e1d5..35af972c 100644
|
|
|
|
|
--- a/src/cmake/StdFilesystemFlags.cmake
|
|
|
|
|
+++ b/src/cmake/StdFilesystemFlags.cmake
|
|
|
|
|
@@ -20,7 +20,14 @@ if(MSVC AND MSVC_VERSION GREATER 1890)
|
|
|
|
|
else()
|
|
|
|
|
include(CheckCXXSourceCompiles)
|
|
|
|
|
|
|
|
|
|
- # This is just example code that is known to not compile if std::filesystem isn't working right
|
|
|
|
|
+ ###
|
|
|
|
|
+ # Test Sources
|
|
|
|
|
+ ###
|
|
|
|
|
+
|
|
|
|
|
+ # This is just example code that is known to not compile if std::filesystem isn't working right.
|
|
|
|
|
+ # It depends on having the proper includes and `using namespace` so it can use the `is_regular_file`
|
|
|
|
|
+ # function unqualified.
|
|
|
|
|
+ # It is at the end of every test file below.
|
|
|
|
|
set(_stdfs_test_source
|
|
|
|
|
"int main() {
|
|
|
|
|
(void)is_regular_file(\"/\");
|
|
|
|
|
@@ -29,9 +36,23 @@ else()
|
|
|
|
|
"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
+ # This is preprocessor code included in all test compiles, which pulls in the conditions
|
|
|
|
|
+ # originally found in filesystem_utils.cpp.
|
|
|
|
|
+ #
|
|
|
|
|
+ # It defines:
|
|
|
|
|
+ # USE_FINAL_FS = 1 if it thinks we have the full std::filesystem in <filesystem> as in C++17
|
|
|
|
|
+ # USE_EXPERIMENTAL_FS = 1 if it thinks we don't have the full c++17 filesystem, but should have
|
|
|
|
|
+ # std::experimental::filesystem and <experimental/filesystem>
|
|
|
|
|
+ #
|
|
|
|
|
+ # Ideally the first condition (__cplusplus >= 201703L) would handle most cases,
|
|
|
|
|
+ # however you're not supposed to report that unless you're fully conformant with all
|
|
|
|
|
+ # of c++17, so you might have a c++17 build flag and the final filesystem library but
|
|
|
|
|
+ # a lower __cplusplus value if some other part of the standard is missing.
|
|
|
|
|
set(_stdfs_conditions "#include <stdfs_conditions.h>
|
|
|
|
|
")
|
|
|
|
|
|
|
|
|
|
+ # This should only compile if our common detection code decides on the
|
|
|
|
|
+ # **final** (non-experimental) filesystem library.
|
|
|
|
|
set(_stdfs_source
|
|
|
|
|
"${_stdfs_conditions}
|
|
|
|
|
#if defined(USE_FINAL_FS) && USE_FINAL_FS
|
|
|
|
|
@@ -41,6 +62,9 @@ else()
|
|
|
|
|
${_stdfs_test_source}
|
|
|
|
|
"
|
|
|
|
|
)
|
|
|
|
|
+
|
|
|
|
|
+ # This should only compile if our common detection code decides on the
|
|
|
|
|
+ # **experimental** filesystem library.
|
|
|
|
|
set(_stdfs_experimental_source
|
|
|
|
|
"${_stdfs_conditions}
|
|
|
|
|
#if defined(USE_EXPERIMENTAL_FS) && USE_EXPERIMENTAL_FS
|
|
|
|
|
@@ -50,6 +74,11 @@ else()
|
|
|
|
|
${_stdfs_test_source}
|
|
|
|
|
"
|
|
|
|
|
)
|
|
|
|
|
+
|
|
|
|
|
+ # This should compile if the common detection code decided that either
|
|
|
|
|
+ # the experimental or final filesystem library is available.
|
|
|
|
|
+ # We use this when trying to detect what library to link, if any:
|
|
|
|
|
+ # earlier checks are the ones that care about how we include the headers.
|
|
|
|
|
set(_stdfs_needlib_source
|
|
|
|
|
"${_stdfs_conditions}
|
|
|
|
|
#if defined(USE_FINAL_FS) && USE_FINAL_FS
|
|
|
|
|
@@ -64,6 +93,10 @@ else()
|
|
|
|
|
"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
+ ###
|
|
|
|
|
+ # Identifying header/namespace and standards flags
|
|
|
|
|
+ ###
|
|
|
|
|
+
|
|
|
|
|
# First, just look for the include.
|
|
|
|
|
# We're checking if it compiles, not if the include exists,
|
|
|
|
|
# because the source code uses the same conditionals to decide.
|
|
|
|
|
@@ -75,15 +108,20 @@ else()
|
|
|
|
|
check_cxx_source_compiles("${_stdfs_source}" HAVE_FILESYSTEM_IN_STD)
|
|
|
|
|
check_cxx_source_compiles("${_stdfs_experimental_source}" HAVE_FILESYSTEM_IN_STDEXPERIMENTAL)
|
|
|
|
|
|
|
|
|
|
+ # See if the "final" version builds if we try to specify C++17 explicitly
|
|
|
|
|
+ # TODO I think this should actually be compiler flags, not cmake flags...
|
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "-DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=TRUE")
|
|
|
|
|
check_cxx_source_compiles("${_stdfs_source}" HAVE_FILESYSTEM_IN_STD_17)
|
|
|
|
|
unset(CMAKE_REQUIRED_FLAGS)
|
|
|
|
|
|
|
|
|
|
+ # If we found the final version of filesystem when specifying c++17 explicitly,
|
|
|
|
|
+ # but found it no other way, then we record that we must use C++17 flags.
|
|
|
|
|
if(HAVE_FILESYSTEM_IN_STD_17 AND NOT HAVE_FILESYSTEM_IN_STD)
|
|
|
|
|
set(HAVE_FILESYSTEM_NEEDS_17
|
|
|
|
|
ON
|
|
|
|
|
CACHE INTERNAL ""
|
|
|
|
|
)
|
|
|
|
|
+ # TODO I think this should actually be compiler flags, not cmake flags...
|
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "-DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=TRUE")
|
|
|
|
|
else()
|
|
|
|
|
set(HAVE_FILESYSTEM_NEEDS_17
|
|
|
|
|
@@ -92,21 +130,37 @@ else()
|
|
|
|
|
)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
- # Now, see if we need libstdc++fs
|
|
|
|
|
+ ###
|
|
|
|
|
+ # Identifying library to link
|
|
|
|
|
+ ###
|
|
|
|
|
+
|
|
|
|
|
+ # Now, see if we need to link against libstdc++fs, and what it's called
|
|
|
|
|
+ # If we needed c++17 standard flags to find it, they've already been set above.
|
|
|
|
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
|
|
|
|
|
+
|
|
|
|
|
+ # Try with no lib specified
|
|
|
|
|
check_cxx_source_compiles("${_stdfs_needlib_source}" HAVE_FILESYSTEM_WITHOUT_LIB)
|
|
|
|
|
+
|
|
|
|
|
+ # Try with stdc++fs
|
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES stdc++fs)
|
|
|
|
|
check_cxx_source_compiles("${_stdfs_needlib_source}" HAVE_FILESYSTEM_NEEDING_LIBSTDCXXFS)
|
|
|
|
|
+
|
|
|
|
|
+ # Try with c++fs (from clang's libc++)
|
|
|
|
|
set(CMAKE_REQUIRED_LIBRARIES c++fs)
|
|
|
|
|
check_cxx_source_compiles("${_stdfs_needlib_source}" HAVE_FILESYSTEM_NEEDING_LIBCXXFS)
|
|
|
|
|
+
|
|
|
|
|
+ # Clean up these variables before the next user.
|
|
|
|
|
unset(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
|
unset(CMAKE_TRY_COMPILE_TARGET_TYPE)
|
|
|
|
|
unset(CMAKE_REQUIRED_INCLUDES)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
+# Use the observations of the code above to add the filesystem_utils.cpp
|
|
|
|
|
+# file to a target, along with any required compiler settings and libraries.
|
|
|
|
|
+# Also handles our BUILD_WITH_STD_FILESYSTEM option.
|
|
|
|
|
function(openxr_add_filesystem_utils TARGET_NAME)
|
|
|
|
|
- target_sources(${TARGET_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/src/common/filesystem_utils.cpp)
|
|
|
|
|
- target_include_directories(${TARGET_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/src/common)
|
|
|
|
|
+ target_sources(${TARGET_NAME} PRIVATE ${_FILESYSTEM_UTILS_DIR}/filesystem_utils.cpp)
|
|
|
|
|
+ target_include_directories(${TARGET_NAME} PRIVATE ${_FILESYSTEM_UTILS_DIR})
|
|
|
|
|
if(NOT BUILD_WITH_STD_FILESYSTEM)
|
|
|
|
|
target_compile_definitions(${TARGET_NAME} PRIVATE DISABLE_STD_FILESYSTEM)
|
|
|
|
|
else()
|
|
|
|
|
|
|
|
|
|
From bbef2219ecfae31bc67962d945146cf4f8f9d4fc Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: Ryan Pavlik <ryan.pavlik@collabora.com>
|
|
|
|
|
Date: Mon, 25 Oct 2021 12:26:02 -0500
|
|
|
|
|
Subject: [PATCH 4/5] build: Update to handle GCC 11 explicitly.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
src/cmake/StdFilesystemFlags.cmake | 26 +++++++++++++++-----------
|
|
|
|
|
1 file changed, 15 insertions(+), 11 deletions(-)
|
|
|
|
|
|
|
|
|
|
diff --git a/src/cmake/StdFilesystemFlags.cmake b/src/cmake/StdFilesystemFlags.cmake
|
|
|
|
|
index 35af972c..e80d3919 100644
|
|
|
|
|
--- a/src/cmake/StdFilesystemFlags.cmake
|
|
|
|
|
+++ b/src/cmake/StdFilesystemFlags.cmake
|
|
|
|
|
@@ -104,24 +104,28 @@ else()
|
|
|
|
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
|
|
|
|
set(CMAKE_REQUIRED_INCLUDES "${_FILESYSTEM_UTILS_DIR}")
|
|
|
|
|
unset(CMAKE_REQUIRED_LIBRARIES)
|
|
|
|
|
- unset(CMAKE_REQUIRED_FLAGS)
|
|
|
|
|
- check_cxx_source_compiles("${_stdfs_source}" HAVE_FILESYSTEM_IN_STD)
|
|
|
|
|
- check_cxx_source_compiles("${_stdfs_experimental_source}" HAVE_FILESYSTEM_IN_STDEXPERIMENTAL)
|
|
|
|
|
+ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 11.0)
|
|
|
|
|
+ # GCC 11+ defaults to C++17 mode and acts badly in these tests if we tell it to use a different version.
|
|
|
|
|
+ set(HAVE_FILESYSTEM_IN_STD_17 ON)
|
|
|
|
|
+ set(HAVE_FILESYSTEM_IN_STD OFF)
|
|
|
|
|
+ else()
|
|
|
|
|
+ set(CMAKE_REQUIRED_FLAGS "-DCMAKE_CXX_STANDARD=14 -DCMAKE_CXX_STANDARD_REQUIRED=TRUE")
|
|
|
|
|
+ check_cxx_source_compiles("${_stdfs_source}" HAVE_FILESYSTEM_IN_STD)
|
|
|
|
|
+ check_cxx_source_compiles("${_stdfs_experimental_source}" HAVE_FILESYSTEM_IN_STDEXPERIMENTAL)
|
|
|
|
|
|
|
|
|
|
- # See if the "final" version builds if we try to specify C++17 explicitly
|
|
|
|
|
- # TODO I think this should actually be compiler flags, not cmake flags...
|
|
|
|
|
- set(CMAKE_REQUIRED_FLAGS "-DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=TRUE")
|
|
|
|
|
- check_cxx_source_compiles("${_stdfs_source}" HAVE_FILESYSTEM_IN_STD_17)
|
|
|
|
|
- unset(CMAKE_REQUIRED_FLAGS)
|
|
|
|
|
+ # See if the "final" version builds if we try to specify C++17 explicitly
|
|
|
|
|
+ set(CMAKE_REQUIRED_FLAGS "-DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=TRUE")
|
|
|
|
|
+ check_cxx_source_compiles("${_stdfs_source}" HAVE_FILESYSTEM_IN_STD_17)
|
|
|
|
|
+ unset(CMAKE_REQUIRED_FLAGS)
|
|
|
|
|
+ endif()
|
|
|
|
|
|
|
|
|
|
- # If we found the final version of filesystem when specifying c++17 explicitly,
|
|
|
|
|
+ # If we found the final version of filesystem when specifying C++17 explicitly,
|
|
|
|
|
# but found it no other way, then we record that we must use C++17 flags.
|
|
|
|
|
if(HAVE_FILESYSTEM_IN_STD_17 AND NOT HAVE_FILESYSTEM_IN_STD)
|
|
|
|
|
set(HAVE_FILESYSTEM_NEEDS_17
|
|
|
|
|
ON
|
|
|
|
|
CACHE INTERNAL ""
|
|
|
|
|
)
|
|
|
|
|
- # TODO I think this should actually be compiler flags, not cmake flags...
|
|
|
|
|
set(CMAKE_REQUIRED_FLAGS "-DCMAKE_CXX_STANDARD=17 -DCMAKE_CXX_STANDARD_REQUIRED=TRUE")
|
|
|
|
|
else()
|
|
|
|
|
set(HAVE_FILESYSTEM_NEEDS_17
|
|
|
|
|
@@ -135,7 +139,7 @@ else()
|
|
|
|
|
###
|
|
|
|
|
|
|
|
|
|
# Now, see if we need to link against libstdc++fs, and what it's called
|
|
|
|
|
- # If we needed c++17 standard flags to find it, they've already been set above.
|
|
|
|
|
+ # If we needed C++17 standard flags to find it, they've already been set above.
|
|
|
|
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
|
|
|
|
|
|
|
|
|
|
# Try with no lib specified
|
|
|
|
|
|
|
|
|
|
From 6b8f48bb6413b447f2b420f89121e1244a43f0d5 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: Ryan Pavlik <ryan.pavlik@collabora.com>
|
|
|
|
|
Date: Thu, 28 Oct 2021 17:27:44 -0500
|
|
|
|
|
Subject: [PATCH 5/5] Changelog fragment
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
changes/sdk/pr.276.gh.OpenXR-SDK-Source.md | 5 +++++
|
|
|
|
|
1 file changed, 5 insertions(+)
|
|
|
|
|
create mode 100644 changes/sdk/pr.276.gh.OpenXR-SDK-Source.md
|
|
|
|
|
|
|
|
|
|
diff --git a/changes/sdk/pr.276.gh.OpenXR-SDK-Source.md b/changes/sdk/pr.276.gh.OpenXR-SDK-Source.md
|
|
|
|
|
new file mode 100644
|
|
|
|
|
index 00000000..63086223
|
|
|
|
|
--- /dev/null
|
|
|
|
|
+++ b/changes/sdk/pr.276.gh.OpenXR-SDK-Source.md
|
|
|
|
|
@@ -0,0 +1,5 @@
|
|
|
|
|
+---
|
|
|
|
|
+- issue.260.gh.OpenXR-SDK-Source
|
|
|
|
|
+- issue.1571.gl
|
|
|
|
|
+---
|
|
|
|
|
+- Fix detection of std::filesystem options on GCC 11 and newer.
|