Skip to content

Commit e4febfb

Browse files
Hatem Helalwesm
Hatem Helal
authored andcommitted
ARROW-6096: [C++] conditionally use boost regex for gcc < 4.9
I did a quick test of this on mac and verified that the parquet shared library no longer depends on the boost regex lib. Closes #4985 from hatemhelal/arrow-6096 and squashes the following commits: c88bb4e <Hatem Helal> remove boost regex dependency from libarrow 6b81153 <Hatem Helal> conditionally use boost regex for gcc < 4.9 Authored-by: Hatem Helal <[email protected]> Signed-off-by: Wes McKinney <[email protected]>
1 parent 248f2ce commit e4febfb

File tree

3 files changed

+23
-13
lines changed

3 files changed

+23
-13
lines changed

cpp/CMakeLists.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -659,10 +659,9 @@ if(ARROW_STATIC_LINK_LIBS)
659659
endif()
660660

661661
set(ARROW_SHARED_PRIVATE_LINK_LIBS ${ARROW_STATIC_LINK_LIBS} ${BOOST_SYSTEM_LIBRARY}
662-
${BOOST_FILESYSTEM_LIBRARY} ${BOOST_REGEX_LIBRARY})
662+
${BOOST_FILESYSTEM_LIBRARY})
663663

664-
list(APPEND ARROW_STATIC_LINK_LIBS ${BOOST_SYSTEM_LIBRARY} ${BOOST_FILESYSTEM_LIBRARY}
665-
${BOOST_REGEX_LIBRARY})
664+
list(APPEND ARROW_STATIC_LINK_LIBS ${BOOST_SYSTEM_LIBRARY} ${BOOST_FILESYSTEM_LIBRARY})
666665

667666
list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS boost_system boost_filesystem boost_regex)
668667

@@ -693,7 +692,6 @@ set(ARROW_TEST_SHARED_LINK_LIBS
693692
${double-conversion_LIBRARIES}
694693
${BOOST_SYSTEM_LIBRARY}
695694
${BOOST_FILESYSTEM_LIBRARY}
696-
${BOOST_REGEX_LIBRARY}
697695
${ARROW_TEST_LINK_TOOLCHAIN})
698696

699697
if(NOT MSVC)

cpp/src/parquet/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ else()
9494
endif()
9595

9696
set(PARQUET_BOOST_LINK_LIBS)
97-
list(APPEND PARQUET_BOOST_LINK_LIBS ${BOOST_REGEX_LIBRARY})
98-
if(MSVC)
99-
list(APPEND PARQUET_BOOST_LINK_LIBS ${BOOST_SYSTEM_LIBRARY})
97+
98+
if("${COMPILER_FAMILY}" STREQUAL "gcc" AND "${COMPILER_VERSION}" VERSION_LESS "4.9")
99+
add_definitions(-DPARQUET_USE_BOOST_REGEX)
100+
list(APPEND PARQUET_BOOST_LINK_LIBS ${BOOST_REGEX_LIBRARY})
100101
endif()
101102

102103
set(PARQUET_MIN_TEST_LIBS GTest::Main GTest::GTest)

cpp/src/parquet/metadata.cc

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,18 @@
2929
#include "parquet/statistics.h"
3030
#include "parquet/thrift.h"
3131

32+
// ARROW-6096: The boost regex library must be used when compiling with gcc < 4.9
33+
#if defined(PARQUET_USE_BOOST_REGEX)
3234
#include <boost/regex.hpp> // IWYU pragma: keep
35+
using ::boost::regex;
36+
using ::boost::regex_match;
37+
using ::boost::smatch;
38+
#else
39+
#include <regex>
40+
using ::std::regex;
41+
using ::std::regex_match;
42+
using ::std::smatch;
43+
#endif
3344

3445
namespace parquet {
3546

@@ -520,16 +531,16 @@ ApplicationVersion::ApplicationVersion(const std::string& application, int major
520531
: application_(application), version{major, minor, patch, "", "", ""} {}
521532

522533
ApplicationVersion::ApplicationVersion(const std::string& created_by) {
523-
boost::regex app_regex{ApplicationVersion::APPLICATION_FORMAT};
524-
boost::regex ver_regex{ApplicationVersion::VERSION_FORMAT};
525-
boost::smatch app_matches;
526-
boost::smatch ver_matches;
534+
regex app_regex{ApplicationVersion::APPLICATION_FORMAT};
535+
regex ver_regex{ApplicationVersion::VERSION_FORMAT};
536+
smatch app_matches;
537+
smatch ver_matches;
527538

528539
std::string created_by_lower = created_by;
529540
std::transform(created_by_lower.begin(), created_by_lower.end(),
530541
created_by_lower.begin(), ::tolower);
531542

532-
bool app_success = boost::regex_match(created_by_lower, app_matches, app_regex);
543+
bool app_success = regex_match(created_by_lower, app_matches, app_regex);
533544
bool ver_success = false;
534545
std::string version_str;
535546

@@ -538,7 +549,7 @@ ApplicationVersion::ApplicationVersion(const std::string& created_by) {
538549
application_ = app_matches[1];
539550
version_str = app_matches[3];
540551
build_ = app_matches[4];
541-
ver_success = boost::regex_match(version_str, ver_matches, ver_regex);
552+
ver_success = regex_match(version_str, ver_matches, ver_regex);
542553
} else {
543554
application_ = "unknown";
544555
}

0 commit comments

Comments
 (0)