Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use boost filesystem library for macos #112

Open
wants to merge 1 commit into
base: public
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
12 changes: 9 additions & 3 deletions src/abycore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/abycore/sharing/boolsharing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ namespace filesystem = std::filesystem;
#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
namespace filesystem = std::experimental::filesystem;
#elif __has_include(<boost/filesystem.hpp>)
#include <boost/filesystem.hpp>
namespace filesystem = boost::filesystem;
#else
#error "C++17 filesystem library not found"
#endif
Expand Down
8 changes: 8 additions & 0 deletions src/abycore/sharing/sharing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ namespace filesystem = std::filesystem;
#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
namespace filesystem = std::experimental::filesystem;
#elif __has_include(<boost/filesystem.hpp>)
#define IS_BOOST_FILESYSTEM 1
#include <boost/filesystem.hpp>
namespace filesystem = boost::filesystem;
#else
#error "C++17 filesystem library not found"
#endif
Expand Down Expand Up @@ -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;
Expand Down