55if (MSVC AND MSVC_VERSION GREATER 1890)
66 set (HAVE_FILESYSTEM_WITHOUT_LIB
77 ON
8- CACHE INTERNAL "" FORCE)
8+ CACHE INTERNAL "" FORCE
9+ )
910 if (MSVC_VERSION GREATER 1910)
1011 # Visual Studio 2017 Update 3 added new filesystem impl,
1112 # which only works in C++17 mode.
1213 set (HAVE_FILESYSTEM_NEEDS_17
1314 ON
14- CACHE INTERNAL "" FORCE)
15+ CACHE INTERNAL "" FORCE
16+ )
1517 endif ()
1618else ()
1719 include (CheckCXXSourceCompiles)
5052 #endif
5153
5254 #endif
53- " )
55+ "
56+ )
5457 set (_stdfs_source
5558 "${_stdfs_conditions}
5659 #ifdef USE_FINAL_FS
6164 "
6265 )
6366 set (_stdfs_experimental_source
64- "${_stdfs_conditions}
67+ "${_stdfs_conditions}
6568 #ifdef USE_EXPERIMENTAL_FS
6669 #include <experimental/filesystem>
6770 using namespace std::experimental::filesystem;
@@ -113,7 +116,9 @@ else()
113116 set (CMAKE_TRY_COMPILE_TARGET_TYPE EXECUTABLE)
114117 check_cxx_source_compiles("${_stdfs_needlib_source} " HAVE_FILESYSTEM_WITHOUT_LIB)
115118 set (CMAKE_REQUIRED_LIBRARIES stdc++fs)
116- check_cxx_source_compiles("${_stdfs_needlib_source} " HAVE_FILESYSTEM_NEEDING_LIB)
119+ check_cxx_source_compiles("${_stdfs_needlib_source} " HAVE_FILESYSTEM_NEEDING_LIBSTDCXXFS)
120+ set (CMAKE_REQUIRED_LIBRARIES c++fs)
121+ check_cxx_source_compiles("${_stdfs_needlib_source} " HAVE_FILESYSTEM_NEEDING_LIBCXXFS)
117122 unset (CMAKE_REQUIRED_LIBRARIES)
118123 unset (CMAKE_TRY_COMPILE_TARGET_TYPE)
119124
@@ -129,8 +134,12 @@ function(openxr_add_filesystem_utils TARGET_NAME)
129134 set_property (TARGET ${TARGET_NAME} PROPERTY CXX_STANDARD 17)
130135 set_property (TARGET ${TARGET_NAME} PROPERTY CXX_STANDARD_REQUIRED TRUE )
131136 endif ()
132- if (HAVE_FILESYSTEM_NEEDING_LIB AND NOT HAVE_FILESYSTEM_WITHOUT_LIB)
133- target_link_libraries (${TARGET_NAME} PRIVATE stdc++fs)
137+ if (NOT HAVE_FILESYSTEM_WITHOUT_LIB)
138+ if (HAVE_FILESYSTEM_NEEDING_LIBSTDCXXFS)
139+ target_link_libraries (${TARGET_NAME} PRIVATE stdc++fs)
140+ elseif (HAVE_FILESYSTEM_NEEDING_LIBCXXFS)
141+ target_link_libraries (${TARGET_NAME} PRIVATE c++fs)
142+ endif ()
134143 endif ()
135144 endif ()
136145endfunction ()
0 commit comments