@@ -1873,11 +1873,6 @@ function(build_protobuf)
18731873 set (PROTOBUF_VENDORED
18741874 TRUE
18751875 PARENT_SCOPE)
1876- # When building protobuf from source via FetchContent, we always build it as static
1877- # Update ARROW_PROTOBUF_USE_SHARED to reflect this (must be CACHE to be visible to ORC)
1878- set (ARROW_PROTOBUF_USE_SHARED
1879- OFF
1880- CACHE BOOL "" FORCE)
18811876 set (PROTOBUF_PREFIX "${CMAKE_CURRENT_BINARY_DIR} /protobuf_fc-install" )
18821877 set (PROTOBUF_PREFIX
18831878 "${PROTOBUF_PREFIX} "
@@ -1887,12 +1882,6 @@ function(build_protobuf)
18871882 "${PROTOBUF_INCLUDE_DIR} "
18881883 PARENT_SCOPE)
18891884
1890- # Always build protobuf as static library to avoid DLL import/export issues on Windows
1891- # Must be set BEFORE fetchcontent_declare and as CACHE FORCE to override the option()
1892- set (protobuf_BUILD_SHARED_LIBS
1893- OFF
1894- CACHE BOOL "Build protobuf shared libs" FORCE)
1895-
18961885 fetchcontent_declare(protobuf
18971886 URL ${PROTOBUF_SOURCE_URL}
18981887 URL_HASH "SHA256=${ARROW_PROTOBUF_BUILD_SHA256_CHECKSUM} "
@@ -1924,27 +1913,6 @@ function(build_protobuf)
19241913
19251914 fetchcontent_makeavailable(protobuf)
19261915
1927- # Ensure protobuf targets don't have PROTOBUF_USE_DLLS defined
1928- # This is critical on Windows to avoid DLL import/export issues when linking static protobuf
1929- if (TARGET protobuf::libprotobuf)
1930- get_target_property (_protobuf_compile_defs protobuf::libprotobuf
1931- INTERFACE_COMPILE_DEFINITIONS )
1932- if (_protobuf_compile_defs)
1933- list (REMOVE_ITEM _protobuf_compile_defs PROTOBUF_USE_DLLS)
1934- set_target_properties (protobuf::libprotobuf PROPERTIES INTERFACE_COMPILE_DEFINITIONS
1935- "${_protobuf_compile_defs} " )
1936- endif ()
1937- endif ()
1938- if (TARGET protobuf::libprotoc)
1939- get_target_property (_protoc_compile_defs protobuf::libprotoc
1940- INTERFACE_COMPILE_DEFINITIONS )
1941- if (_protoc_compile_defs)
1942- list (REMOVE_ITEM _protoc_compile_defs PROTOBUF_USE_DLLS)
1943- set_target_properties (protobuf::libprotoc PROPERTIES INTERFACE_COMPILE_DEFINITIONS
1944- "${_protoc_compile_defs} " )
1945- endif ()
1946- endif ()
1947-
19481916 # Get the actual include directory from the protobuf target
19491917 # For FetchContent, this points to the source directory which contains the .proto files
19501918 set (PROTOBUF_INCLUDE_DIR "${protobuf_SOURCE_DIR} /src" )
@@ -1970,7 +1938,6 @@ function(build_protobuf)
19701938 # We have to do this in two steps to avoid double installation of Protobuf
19711939 # when Arrow is installed.
19721940 # This custom target ensures Protobuf is built before we install
1973- # TODO: Investigate if libprotobuf-lite is actually needed by Arrow/gRPC
19741941 add_custom_target (protobuf_built
19751942 DEPENDS protobuf::libprotobuf protobuf::libprotobuf-lite
19761943 protobuf::libprotoc protobuf::protoc)
@@ -1990,7 +1957,7 @@ function(build_protobuf)
19901957 add_custom_target (protobuf_install_disabled ALL
19911958 DEPENDS "${protobuf_BINARY_DIR} /cmake_install.cmake.saved" )
19921959
1993- # Install Protobuf to PROTOBUF_PREFIX for gRPC to find
1960+ # Install Protobuf to PROTOBUF_PREFIX for dependendants to find
19941961 add_custom_command (OUTPUT "${PROTOBUF_PREFIX} /.protobuf_installed"
19951962 COMMAND ${CMAKE_COMMAND} -E copy_if_different
19961963 "${protobuf_BINARY_DIR} /cmake_install.cmake.saved"
@@ -2007,18 +1974,13 @@ function(build_protobuf)
20071974
20081975 # Make protobuf_fc depend on the install completion marker
20091976 add_custom_target (protobuf_fc DEPENDS "${PROTOBUF_PREFIX} /.protobuf_installed" )
2010-
2011- # For FetchContent, we don't create arrow::protobuf::* aliases because
2012- # protobuf::* are themselves aliases and CMake doesn't allow alias-to-alias.
2013- # The code in resolve_dependency below will use protobuf::* targets directly.
2014-
20151977 list (APPEND ARROW_BUNDLED_STATIC_LIBS protobuf::libprotobuf)
20161978
20171979 if (CMAKE_CROSSCOMPILING )
20181980 # If we are cross compiling, we need to build protoc for the host
20191981 # system also, as it is used when building Arrow
20201982 # We reuse the FetchContent downloaded source but build it with host compiler
2021- set (PROTOBUF_HOST_PREFIX "${CMAKE_CURRENT_BINARY_DIR} /protobuf_fc_host -install" )
1983+ set (PROTOBUF_HOST_PREFIX "${CMAKE_CURRENT_BINARY_DIR} /protobuf_ep_host -install" )
20221984 set (PROTOBUF_HOST_COMPILER "${PROTOBUF_HOST_PREFIX} /bin/protoc" )
20231985
20241986 set (PROTOBUF_HOST_CMAKE_ARGS
@@ -2041,7 +2003,7 @@ function(build_protobuf)
20412003 set_target_properties (arrow::protobuf::host_protoc
20422004 PROPERTIES IMPORTED_LOCATION "${PROTOBUF_HOST_COMPILER} " )
20432005
2044- add_dependencies (arrow::protobuf::host_protoc protobuf_fc_host )
2006+ add_dependencies (arrow::protobuf::host_protoc protobuf_ep_host )
20452007 endif ()
20462008 list (POP_BACK CMAKE_MESSAGE_INDENT)
20472009endfunction ()
@@ -2208,7 +2170,6 @@ macro(build_substrait)
22082170 SKIP_UNITY_BUILD_INCLUSION TRUE )
22092171 list (APPEND SUBSTRAIT_PROTO_GEN_ALL "${SUBSTRAIT_PROTO_GEN} .${EXT} " )
22102172 endforeach ()
2211- # Add protobuf include directory for well-known types when using vendored protobuf
22122173 set (SUBSTRAIT_PROTOC_INCLUDES "-I${SUBSTRAIT_LOCAL_DIR} /proto" )
22132174 if (PROTOBUF_VENDORED AND Protobuf_INCLUDE_DIRS)
22142175 list (APPEND SUBSTRAIT_PROTOC_INCLUDES "-I${Protobuf_INCLUDE_DIRS} " )
@@ -2232,15 +2193,9 @@ macro(build_substrait)
22322193 SKIP_UNITY_BUILD_INCLUSION TRUE )
22332194 list (APPEND SUBSTRAIT_PROTO_GEN_ALL "${ARROW_SUBSTRAIT_PROTO_GEN} .${EXT} " )
22342195 endforeach ()
2235- # Add protobuf include directory for well-known types when using vendored protobuf
2236- set (ARROW_SUBSTRAIT_PROTOC_INCLUDES "-I${SUBSTRAIT_LOCAL_DIR} /proto"
2237- "-I${ARROW_SUBSTRAIT_PROTOS_DIR} " )
2238- if (PROTOBUF_VENDORED AND Protobuf_INCLUDE_DIRS)
2239- list (APPEND ARROW_SUBSTRAIT_PROTOC_INCLUDES "-I${Protobuf_INCLUDE_DIRS} " )
2240- endif ()
22412196 add_custom_command (OUTPUT "${ARROW_SUBSTRAIT_PROTO_GEN} .cc"
22422197 "${ARROW_SUBSTRAIT_PROTO_GEN} .h"
2243- COMMAND ${ARROW_PROTOBUF_PROTOC} ${ARROW_SUBSTRAIT_PROTOC_INCLUDES }
2198+ COMMAND ${ARROW_PROTOBUF_PROTOC} ${SUBSTRAIT_PROTOC_INCLUDES }
22442199 "--cpp_out=${SUBSTRAIT_CPP_DIR} "
22452200 "${ARROW_SUBSTRAIT_PROTOS_DIR} /substrait/${ARROW_SUBSTRAIT_PROTO} .proto"
22462201 DEPENDS ${PROTO_DEPENDS} substrait_ep)
0 commit comments