Skip to content

Commit a5c6011

Browse files
committed
Allow disabling of std::filesystem in CMake.
In particular, disable its usage on MinGW running on not-Windows because the version in Debian Buster has a bug.
1 parent 380849a commit a5c6011

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,15 @@ option(
5353
"Enable exception handling in the loader. Leave this on unless your standard library is built to not throw."
5454
ON
5555
)
56+
57+
set(BUILD_WITHOUT_STD_FILESYSTEM_DEFAULT OFF)
58+
if(MINGW AND NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
59+
# Debian 10's MinGW has a bug in the experimental filesystem support
60+
set(BUILD_WITHOUT_STD_FILESYSTEM_DEFAULT ON)
61+
endif()
62+
option(BUILD_WITHOUT_STD_FILESYSTEM "Force building without std::[experimental::]filesystem."
63+
${BUILD_WITHOUT_STD_FILESYSTEM_DEFAULT})
64+
5665
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
5766
option(DYNAMIC_LOADER "Build the loader as a .dll library" OFF)
5867
else()

src/loader/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,18 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
222222
-ffunction-sections
223223
-fdata-sections
224224
)
225+
if(NOT BUILD_WITHOUT_STD_FILESYSTEM)
226+
target_link_libraries(openxr_loader PRIVATE stdc++fs)
227+
endif()
225228
# For GCC version 7.1 or greater, we need to disable the implicit fallthrough warning since
226229
# there's no consistent way to satisfy all compilers until they all accept the C++17 standard
227230
if(CMAKE_COMPILER_IS_GNUCC AND NOT (CMAKE_CXX_COMPILER_VERSION LESS 7.1))
228231
target_compile_options(openxr_loader PRIVATE -Wimplicit-fallthrough=0)
229232
endif()
230233
endif()
234+
if(BUILD_WITHOUT_STD_FILESYSTEM)
235+
target_compile_definitions(openxr_loader PRIVATE DISABLE_STD_FILESYSTEM)
236+
endif()
231237

232238
install(
233239
TARGETS openxr_loader

0 commit comments

Comments
 (0)