Skip to content

Commit 59ea770

Browse files
committed
GH-47961: [C++] Fix Meson's Boost process version detection
1 parent 534ef71 commit 59ea770

File tree

1 file changed

+42
-3
lines changed

1 file changed

+42
-3
lines changed

cpp/src/arrow/meson.build

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -623,22 +623,55 @@ if needs_testing
623623
modules: ['filesystem'],
624624
required: false,
625625
)
626-
if not filesystem_dep.found()
626+
base_process_dep = dependency('boost', modules: ['process'], required: false)
627+
628+
if not (filesystem_dep.found() and base_process_dep.found())
627629
cmake = import('cmake')
628630
boost_opt = cmake.subproject_options()
629631
boost_opt.add_cmake_defines(
630-
{'BOOST_INCLUDE_LIBRARIES': 'filesystem;system'},
632+
{'BOOST_INCLUDE_LIBRARIES': 'filesystem;process'},
631633
)
634+
if get_option('default_library') != 'static'
635+
boost_opt.add_cmake_defines({'BUILD_SHARED_LIBS': 'ON'})
636+
endif
632637
boost_proj = cmake.subproject('boost', options: boost_opt)
633638
filesystem_dep = boost_proj.dependency('boost_filesystem')
639+
base_process_dep = boost_proj.dependency('boost_process')
640+
endif
641+
642+
boost_process_have_v2 = false
643+
process_compile_args = []
644+
if base_process_dep.version() >= '1.86'
645+
process_compile_args += [
646+
'-DBOOST_PROCESS_HAVE_V1',
647+
'-DBOOST_PROCESS_HAVE_V2',
648+
]
649+
boost_process_have_v2 = true
650+
elif base_process_dep.version() >= '1.80'
651+
process_compile_args += ['-DBOOST_PROCESS_HAVE_V2']
652+
boost_process_have_v2 = true
634653
endif
635654

655+
if (boost_process_have_v2 and host_machine.system() != 'windows')
656+
# We can't use v2 API on Windows because v2 API doesn't support
657+
# process group[1] and GCS testbench uses multiple processes[2].
658+
#
659+
# [1] https://github.com/boostorg/process/issues/259
660+
# [2] https://github.com/googleapis/storage-testbench/issues/669
661+
process_compile_args += ['-DBOOST_PROCESS_USE_V2']
662+
endif
663+
process_dep = declare_dependency(
664+
dependencies: [base_process_dep],
665+
compile_args: process_compile_args,
666+
)
667+
636668
gtest_dep = dependency('gtest')
637669
gtest_main_dep = dependency('gtest_main')
638670
gtest_dep = dependency('gtest')
639671
gmock_dep = dependency('gmock')
640672
else
641673
filesystem_dep = disabler()
674+
process_dep = disabler()
642675
gtest_dep = disabler()
643676
gtest_main_dep = disabler()
644677
gtest_dep = disabler()
@@ -649,7 +682,13 @@ if needs_testing
649682
arrow_testing_lib = static_library(
650683
'arrow_testing',
651684
sources: arrow_testing_srcs,
652-
dependencies: [arrow_dep, filesystem_dep, gmock_dep, gtest_dep],
685+
dependencies: [
686+
arrow_dep,
687+
process_dep,
688+
filesystem_dep,
689+
gmock_dep,
690+
gtest_dep,
691+
],
653692
)
654693

655694
arrow_testing_dep = declare_dependency(link_with: [arrow_testing_lib])

0 commit comments

Comments
 (0)