diff --git a/CMakeLists.txt b/CMakeLists.txt index a10a408b..ac2a88f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,10 +56,14 @@ find_package(GMP REQUIRED) find_package(Threads REQUIRED) find_package(Boost REQUIRED) +if(APPLE) + find_package(Boost REQUIRED COMPONENTS filesystem) +endif() + add_subdirectory(src/abycore) if(ABY_BUILD_EXE) - add_subdirectory(src/test) add_subdirectory(src/examples) + add_subdirectory(src/test) endif(ABY_BUILD_EXE) diff --git a/src/abycore/CMakeLists.txt b/src/abycore/CMakeLists.txt index d25f5295..2b271612 100644 --- a/src/abycore/CMakeLists.txt +++ b/src/abycore/CMakeLists.txt @@ -32,9 +32,15 @@ target_include_directories(aby # libc++. Linking to libstdc++fs is currently required when using the # std::filesystem library. # cf. https://gitlab.kitware.com/cmake/cmake/issues/17834 -target_link_libraries(aby - PRIVATE stdc++fs -) +if (!APPLE) + target_link_libraries(aby + PRIVATE stdc++fs + ) +else() + target_link_libraries(aby + PUBLIC Boost::filesystem + ) +endif() target_link_libraries(aby PUBLIC OTExtension::otextension diff --git a/src/abycore/sharing/boolsharing.cpp b/src/abycore/sharing/boolsharing.cpp index 4c8c9345..eb16efb9 100644 --- a/src/abycore/sharing/boolsharing.cpp +++ b/src/abycore/sharing/boolsharing.cpp @@ -25,6 +25,9 @@ namespace filesystem = std::filesystem; #elif __has_include() #include namespace filesystem = std::experimental::filesystem; +#elif __has_include() +#include +namespace filesystem = boost::filesystem; #else #error "C++17 filesystem library not found" #endif diff --git a/src/abycore/sharing/sharing.cpp b/src/abycore/sharing/sharing.cpp index 47f3a253..20e232c5 100644 --- a/src/abycore/sharing/sharing.cpp +++ b/src/abycore/sharing/sharing.cpp @@ -29,6 +29,10 @@ namespace filesystem = std::filesystem; #elif __has_include() #include namespace filesystem = std::experimental::filesystem; +#elif __has_include() +#define IS_BOOST_FILESYSTEM 1 +#include +namespace filesystem = boost::filesystem; #else #error "C++17 filesystem library not found" #endif @@ -92,7 +96,11 @@ void Sharing::PreCompFileDelete() { } else { truncation_size = filesystem::file_size(filename) - m_nFilePos; +#if defined (IS_BOOST_FILESYSTEM) + boost::system::error_code ec; +#else std::error_code ec; +#endif filesystem::resize_file(filename, truncation_size, ec); if(ec) { std::cout << "Error occured in truncate:" << ec.message() << std::endl;