Skip to content

Commit b78fc42

Browse files
committed
build: 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 8210d50 commit b78fc42

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ option(
6161
"Enable exception handling in the loader. Leave this on unless your standard library is built to not throw."
6262
ON
6363
)
64+
65+
set(BUILD_WITHOUT_STD_FILESYSTEM_DEFAULT OFF)
66+
if(MINGW)
67+
# Debian 10's MinGW has a bug in the experimental filesystem support
68+
# and MinGW on Windows doesn't apparently have any?
69+
set(BUILD_WITHOUT_STD_FILESYSTEM_DEFAULT ON)
70+
endif()
71+
option(BUILD_WITHOUT_STD_FILESYSTEM "Force building without std::[experimental::]filesystem."
72+
${BUILD_WITHOUT_STD_FILESYSTEM_DEFAULT})
73+
6474
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
6575
option(DYNAMIC_LOADER "Build the loader as a .dll library" OFF)
6676
else()

src/loader/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,11 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
145145
set_target_properties(openxr_loader PROPERTIES SOVERSION "${MAJOR}" VERSION "${MAJOR}.${MINOR}.${PATCH}")
146146
target_link_libraries(
147147
openxr_loader
148-
PRIVATE stdc++fs
149148
PUBLIC m
150149
)
150+
if(NOT BUILD_WITHOUT_STD_FILESYSTEM)
151+
target_link_libraries(openxr_loader PRIVATE stdc++fs)
152+
endif()
151153

152154
add_custom_target(
153155
libopenxr_loader.so.${MAJOR}.${MINOR} ALL
@@ -236,6 +238,9 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
236238
target_compile_options(openxr_loader PRIVATE -Wimplicit-fallthrough=0)
237239
endif()
238240
endif()
241+
if(BUILD_WITHOUT_STD_FILESYSTEM)
242+
target_compile_definitions(openxr_loader PRIVATE DISABLE_STD_FILESYSTEM)
243+
endif()
239244

240245
install(
241246
TARGETS openxr_loader

0 commit comments

Comments
 (0)