Skip to content

Commit a7a6034

Browse files
kouraulcd
authored andcommitted
GH-36598: [C++][MinGW] Fix build failure with Protobuf 23.4 (#36606)
### Rationale for this change There are 2 problems: * `FindProtobuf.cmake` provided by CMake is incomplete with Protobuf 23.4. * Misses `-DPROTOBUF_USE_DLLS` for building Substrait related files. ### What changes are included in this PR? * We need to use `protobuf-config.cmake` provided by Protobuf instead of `FindProtobuf.cmake` provided by CMake because `FindProtobuf.cmake` misses `absl::status` dependency. * Accept Protobuf 23.4. * Use `PROTOBUF_USE_DLLS` when we build Substrait related files. * Use `Boost_INCLUDE_DIRS` instead of `Boost_INCLUDE_DIR` because `Boost_INCLUDE_DIR` isn't defined in `BoostConfig.cmake`. ### Are these changes tested? Yes. ### Are there any user-facing changes? Yes. * Closes: #36598 Authored-by: Sutou Kouhei <[email protected]> Signed-off-by: Antoine Pitrou <[email protected]>
1 parent dc6954a commit a7a6034

File tree

5 files changed

+24
-3
lines changed

5 files changed

+24
-3
lines changed

.github/workflows/cpp.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,7 @@ jobs:
364364
CMAKE_ARGS: >-
365365
-DARROW_PACKAGE_PREFIX=/${{ matrix.msystem_lower}}
366366
-DBoost_NO_BOOST_CMAKE=ON
367+
-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON
367368
# We can't use unity build because we don't have enough memory on
368369
# GitHub Actions.
369370
# CMAKE_UNITY_BUILD: ON

.github/workflows/ruby.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ jobs:
229229
CMAKE_ARGS: >-
230230
-DARROW_PACKAGE_PREFIX=/ucrt${{ matrix.mingw-n-bits }}
231231
-DBoost_NO_BOOST_CMAKE=ON
232+
-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON
232233
CMAKE_UNITY_BUILD: ON
233234
steps:
234235
- name: Disable Crash Dialogs

cpp/cmake_modules/FindProtobufAlt.cmake

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,10 @@ if(ProtobufAlt_FIND_QUIETLY)
3030
endif()
3131
find_package(Protobuf ${find_package_args})
3232
set(ProtobufAlt_FOUND ${Protobuf_FOUND})
33+
if(ProtobufAlt_FOUND)
34+
set(ProtobufAlt_VERSION ${Protobuf_VERSION})
35+
set(ProtobufAlt_VERSION_MAJOR ${Protobuf_VERSION_MAJOR})
36+
set(ProtobufAlt_VERSION_MINOR ${Protobuf_VERSION_MINOR})
37+
set(ProtobufAlt_VERSION_PATCH ${Protobuf_VERSION_PATCH})
38+
set(ProtobufAlt_VERSION_TWEEK ${Protobuf_VERSION_TWEEK})
39+
endif()

cpp/cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,7 @@ if(ARROW_USE_BOOST)
12241224
target_compile_definitions(Boost::headers INTERFACE "BOOST_USE_WINDOWS_H=1")
12251225
endif()
12261226

1227-
message(STATUS "Boost include dir: ${Boost_INCLUDE_DIR}")
1227+
message(STATUS "Boost include dir: ${Boost_INCLUDE_DIRS}")
12281228
endif()
12291229

12301230
# ----------------------------------------------------------------------
@@ -1710,7 +1710,17 @@ if(ARROW_WITH_PROTOBUF)
17101710
else()
17111711
set(ARROW_PROTOBUF_REQUIRED_VERSION "2.6.1")
17121712
endif()
1713+
# We need to use FORCE_ANY_NEWER_VERSION here to accept Protobuf
1714+
# newer version such as 23.4. If we don't use it, 23.4 is processed
1715+
# as an incompatible version with 3.12.0 with protobuf-config.cmake
1716+
# provided by Protobuf. Because protobuf-config-version.cmake
1717+
# requires the same major version. In the example, "23" for 23.4 and
1718+
# "3" for 3.12.0 are different. So 23.4 is rejected with 3.12.0. If
1719+
# we use FORCE_ANY_NEWER_VERSION here, we can bypass the check and
1720+
# use 23.4.
17131721
resolve_dependency(Protobuf
1722+
FORCE_ANY_NEWER_VERSION
1723+
TRUE
17141724
HAVE_ALT
17151725
TRUE
17161726
REQUIRED_VERSION
@@ -1853,7 +1863,7 @@ macro(build_substrait)
18531863
add_library(substrait STATIC ${SUBSTRAIT_SOURCES})
18541864
set_target_properties(substrait PROPERTIES POSITION_INDEPENDENT_CODE ON)
18551865
target_include_directories(substrait PUBLIC ${SUBSTRAIT_INCLUDES})
1856-
target_link_libraries(substrait INTERFACE ${ARROW_PROTOBUF_LIBPROTOBUF})
1866+
target_link_libraries(substrait PUBLIC ${ARROW_PROTOBUF_LIBPROTOBUF})
18571867
add_dependencies(substrait substrait_gen)
18581868

18591869
list(APPEND ARROW_BUNDLED_STATIC_LIBS substrait)

cpp/src/gandiva/precompiled/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ foreach(SRC_FILE ${PRECOMPILED_SRCS})
8383
-I${ARROW_BINARY_DIR}/src)
8484

8585
if(NOT ARROW_USE_NATIVE_INT128)
86-
list(APPEND PRECOMPILE_COMMAND -I${Boost_INCLUDE_DIR})
86+
foreach(boost_include_dir ${Boost_INCLUDE_DIRS})
87+
list(APPEND PRECOMPILE_COMMAND -I${boost_include_dir})
88+
endforeach()
8789
endif()
8890
add_custom_command(OUTPUT ${BC_FILE}
8991
COMMAND ${PRECOMPILE_COMMAND}

0 commit comments

Comments
 (0)