Bring back ghc::filesystem for broke AF macos

macOS doesn't provide `<filesystem>` support when targetting anything
earlier than 10.15.
pull/1282/head
Jason Rhinelander 4 years ago
parent 4d34ee82c9
commit be9ddf2ae1

3
.gitmodules vendored

@ -7,6 +7,9 @@
[submodule "external/cxxopts"]
path = external/cxxopts
url = https://github.com/jarro2783/cxxopts.git
[submodule "external/ghc-filesystem"]
path = external/ghc-filesystem
url = https://github.com/gulrak/filesystem.git
[submodule "test/Catch2"]
path = test/Catch2
url = https://github.com/catchorg/Catch2

@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.10) # bionic's cmake version
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13) # Has to be set before `project()`, and ignored on non-macos
# Has to be set before `project()`, and ignored on non-macos:
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13 CACHE STRING "macOS deployment target (Apple clang only)")
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
@ -261,6 +262,7 @@ if(SUBMODULE_CHECK)
check_submodule(external/nlohmann)
check_submodule(external/googletest)
check_submodule(external/cxxopts)
check_submodule(external/ghc-filesystem)
check_submodule(external/date)
check_submodule(external/pybind11)
check_submodule(external/libuv)

@ -15,6 +15,13 @@ int main() {
}
]])
if(CMAKE_CXX_COMPILER STREQUAL "AppleClang" AND CMAKE_OSX_DEPLOYMENT_TARGET)
# It seems that check_cxx_source_compiles doesn't respect the CMAKE_OSX_DEPLOYMENT_TARGET, so this
# check would pass on Catalina (10.15) and then later compilation would fail because you aren't
# allowed to use <filesystem> when the deployment target is anything before 10.15.
set(CMAKE_REQUIRED_FLAGS -mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET})
endif()
check_cxx_source_compiles("${filesystem_code}" filesystem_compiled)
if(filesystem_compiled)
message(STATUS "No extra link flag needed for std::filesystem")
@ -35,5 +42,9 @@ unset(CMAKE_REQUIRED_LIBRARIES)
if(filesystem_is_good EQUAL 1)
message(STATUS "we have std::filesystem")
else()
message(FATAL_ERROR "we don't have std::filesystem")
# Probably broken AF macos
message(STATUS "std::filesystem is not available, apparently this compiler isn't C++17 compliant; falling back to ghc::filesystem")
add_subdirectory(external/ghc-filesystem)
target_link_libraries(filesystem INTERFACE ghc_filesystem)
target_compile_definitions(filesystem INTERFACE USE_GHC_FILESYSTEM)
endif()

@ -0,0 +1 @@
Subproject commit e63a58c5bac94a3a75a7083f87bb092531407a92

@ -16,7 +16,6 @@
#include <fstream>
#include <ios>
#include <iostream>
#include <filesystem>
namespace llarp
{

@ -9,8 +9,13 @@
#define PATH_SEP "/"
#endif
#ifdef USE_GHC_FILESYSTEM
#include <ghc/filesystem.hpp>
namespace fs = ghc::filesystem;
#else
#include <filesystem>
namespace fs = std::filesystem;
#endif
#ifndef _MSC_VER
#include <dirent.h>

Loading…
Cancel
Save