diff --git a/lang/c++/CMakeLists.txt b/lang/c++/CMakeLists.txt index 1fc19f90a2a..8e7f12bb530 100644 --- a/lang/c++/CMakeLists.txt +++ b/lang/c++/CMakeLists.txt @@ -57,16 +57,13 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}) option(AVRO_BUILD_EXECUTABLES "Build executables" ON) option(AVRO_BUILD_TESTS "Build tests" ON) +option(AVRO_USE_BOOST "Use Boost" OFF) if (WIN32 AND NOT CYGWIN AND NOT MSYS) add_definitions (/EHa) add_definitions ( -DNOMINMAX - -DBOOST_REGEX_DYN_LINK - -DBOOST_FILESYSTEM_DYN_LINK -DBOOST_SYSTEM_DYN_LINK - -DBOOST_IOSTREAMS_DYN_LINK - -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_ALL_NO_LIB) endif() @@ -81,11 +78,8 @@ if (AVRO_ADD_PROTECTOR_FLAGS) endif () endif () -if (AVRO_BUILD_TESTS OR AVRO_BUILD_EXECUTABLES) - find_package (Boost 1.38 REQUIRED - COMPONENTS filesystem iostreams program_options system) -else () - find_package (Boost 1.38 REQUIRED COMPONENTS iostreams) +if (AVRO_BUILD_TESTS OR AVRO_USE_BOOST) + find_package (Boost 1.38 REQUIRED COMPONENTS system) endif () include(FetchContent) diff --git a/lang/c++/test/DataFileTests.cc b/lang/c++/test/DataFileTests.cc index c55988550da..c360a07dbb4 100644 --- a/lang/c++/test/DataFileTests.cc +++ b/lang/c++/test/DataFileTests.cc @@ -16,7 +16,6 @@ * limitations under the License. */ -#include #include #include #include @@ -24,6 +23,7 @@ #include #include +#include #include #include @@ -199,7 +199,7 @@ class DataFileTest { using Pair = pair; void testCleanup() { - BOOST_CHECK(boost::filesystem::remove(filename)); + BOOST_CHECK(std::filesystem::remove(filename)); } void testWrite() { @@ -278,12 +278,12 @@ class DataFileTest { void testTruncate() { testWriteDouble(); - uintmax_t size = boost::filesystem::file_size(filename); + uintmax_t size = std::filesystem::file_size(filename); { avro::DataFileWriter df(filename, writerSchema, 100); df.close(); } - uintmax_t new_size = boost::filesystem::file_size(filename); + uintmax_t new_size = std::filesystem::file_size(filename); BOOST_CHECK(size > new_size); } @@ -471,7 +471,7 @@ class DataFileTest { void testReaderSplits() { boost::mt19937 random(static_cast(time(nullptr))); avro::DataFileReader df(filename, writerSchema); - int length = static_cast(boost::filesystem::file_size(filename)); + int length = static_cast(std::filesystem::file_size(filename)); int splits = 10; int end = length; // end of split int remaining = end; // bytes remaining diff --git a/lang/c++/test/StreamTests.cc b/lang/c++/test/StreamTests.cc index 2096197ef18..d14558ecd28 100644 --- a/lang/c++/test/StreamTests.cc +++ b/lang/c++/test/StreamTests.cc @@ -18,10 +18,11 @@ #include "Exception.hh" #include "Stream.hh" -#include "boost/filesystem.hpp" #include #include +#include + namespace avro { namespace stream { @@ -136,9 +137,9 @@ void testNonEmpty2(const TestData &td) { static const char filename[] = "test_str.bin"; struct FileRemover { - const boost::filesystem::path file; + const std::filesystem::path file; explicit FileRemover(const char *fn) : file(fn) {} - ~FileRemover() { boost::filesystem::remove(file); } + ~FileRemover() { std::filesystem::remove(file); } }; template