This is an automated email from the ASF dual-hosted git repository.

gangwu pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/orc.git


The following commit(s) were added to refs/heads/main by this push:
     new 96afee01c ORC-2013: [C++] Bump to CMake 3.25+ to use FetchContent
96afee01c is described below

commit 96afee01ce5d26094c65e933c749f9928618422b
Author: Gang Wu <[email protected]>
AuthorDate: Thu Oct 9 12:43:46 2025 +0800

    ORC-2013: [C++] Bump to CMake 3.25+ to use FetchContent
    
    ### What changes were proposed in this pull request?
    
    - Rename builtin FindXXX.cmake to FindXXXAlt.cmake to not interfere with 
cannonical package name. These are now only used when `XXX_HOME` or its friends 
are set. This includes:
      - FindGTest.cmake -> FindGTestAlt.cmake
      - FindLZ4.cmake -> FindLZ4Alt.cmake
      - FindProtobuf.cmake -> FindProtobufAlt.cmake
      - FindSnappy.cmake -> FindSnappyAlt.cmake
      - FindZLIB.cmake -> FindZLIBAlt.cmake
      - FindZSTD.cmake -> FindZSTDAlt.cmake
    - Bump CMake minimum requirement to 3.25 to leverage `FetchContent` with 
`FIND_PACKAGE_ARGS`. For 3rd party dependencies now, we try to find system 
installed one via `CONFIG` mode or fallback to vendor it. This includes:
      - GTest
      - LZ4
      - Protobuf
      - Snappy
      - ZSTD
      - ZLIB: note that we use an unreleased version (1.4.0) to work around its 
misuse of build and install interface
      - Sparsehash: always vendor it with workaround to its CMake misuse
    
    ### Why are the changes needed?
    
    - https://github.com/apache/orc/issues/2408
    - https://github.com/apache/orc/issues/2147
    - https://github.com/apache/orc/issues/2016
    - https://github.com/apache/arrow/pull/46906
    
    ### How was this patch tested?
    
    - Pass all CIs
    - Test it manually
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No
    
    Closes #2416 from wgtmac/fetch_content.
    
    Authored-by: Gang Wu <[email protected]>
    Signed-off-by: Gang Wu <[email protected]>
---
 .github/workflows/build_and_test.yml               |   6 +-
 CMakeLists.txt                                     |   3 +-
 c++/orcConfig.cmake.in                             |  25 -
 c++/src/CMakeLists.txt                             |  10 +-
 c++/src/wrap/orc-proto-wrapper.cc                  |   1 +
 c++/src/wrap/orc-proto-wrapper.hh                  |   1 +
 c++/test/CMakeLists.txt                            |   5 -
 .../{FindGTest.cmake => FindGTestAlt.cmake}        |   8 +-
 cmake_modules/{FindLZ4.cmake => FindLZ4Alt.cmake}  |  10 +-
 .../{FindProtobuf.cmake => FindProtobufAlt.cmake}  |  12 +-
 .../{FindSnappy.cmake => FindSnappyAlt.cmake}      |  10 +-
 .../{FindZLIB.cmake => FindZLIBAlt.cmake}          |  10 +-
 .../{FindZSTD.cmake => FindZSTDAlt.cmake}          |  10 +-
 cmake_modules/ThirdpartyToolchain.cmake            | 687 ++++++++++++---------
 conan/all/conandata.yml                            |  23 +-
 conan/all/conanfile.py                             |  49 +-
 conan/config.yml                                   |  10 +-
 tools/test/CMakeLists.txt                          |   3 -
 18 files changed, 460 insertions(+), 423 deletions(-)

diff --git a/.github/workflows/build_and_test.yml 
b/.github/workflows/build_and_test.yml
index 54db8e5eb..c80e00548 100644
--- a/.github/workflows/build_and_test.yml
+++ b/.github/workflows/build_and_test.yml
@@ -269,16 +269,12 @@ jobs:
     steps:
     - name: Checkout repository
       uses: actions/checkout@v5
-    - name: Install dependencies
-      run: |
-        brew update
-        brew install protobuf
     - name: Test
       run: |
         CMAKE_PREFIX_PATH=$(brew --prefix protobuf)
         mkdir -p build
         cd build
-        cmake .. -DBUILD_JAVA=OFF -DPROTOBUF_HOME=${CMAKE_PREFIX_PATH}
+        cmake .. -DBUILD_JAVA=OFF
         make package test-out
 
   meson:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index acb2fbe75..c24060095 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-cmake_minimum_required (VERSION 3.12.0)
+cmake_minimum_required (VERSION 3.25.0)
 if (POLICY CMP0048)
     cmake_policy(SET CMP0048 NEW)
 endif ()
@@ -99,6 +99,7 @@ endif ()
 
 # Set the package format
 SET(CPACK_GENERATOR "TGZ")
+SET(CPACK_SOURCE_GENERATOR "TGZ")
 SET(CPACK_PACKAGE_VENDOR "Apache ORC")
 SET(CPACK_PACKAGE_CONTACT "Apache ORC <[email protected]>")
 
diff --git a/c++/orcConfig.cmake.in b/c++/orcConfig.cmake.in
index 49663b342..c79482256 100644
--- a/c++/orcConfig.cmake.in
+++ b/c++/orcConfig.cmake.in
@@ -33,7 +33,6 @@
 
 @PACKAGE_INIT@
 
-set(ORC_VENDOR_DEPENDENCIES "@ORC_VENDOR_DEPENDENCIES@")
 set(ORC_SYSTEM_DEPENDENCIES "@ORC_SYSTEM_DEPENDENCIES@")
 
 if(DEFINED CMAKE_MODULE_PATH)
@@ -59,30 +58,6 @@ include("${CMAKE_CURRENT_LIST_DIR}/orcTargets.cmake")
 
 get_target_property(orc_static_configurations orc::orc IMPORTED_CONFIGURATIONS)
 
-foreach(dependency ${ORC_VENDOR_DEPENDENCIES})
-  string(REPLACE "|" ";" dependency_pair ${dependency})
-  list(LENGTH dependency_pair dependency_pair_length)
-  if(NOT dependency_pair_length EQUAL 2)
-    message(FATAL_ERROR "Invalid vendor dependency: ${dependency}")
-  endif()
-  list(GET dependency_pair 0 target_name)
-  list(GET dependency_pair 1 static_lib_name)
-
-  add_library("${target_name}" STATIC IMPORTED)
-
-  foreach(CONFIGURATION ${orc_static_configurations})
-    string(TOUPPER "${CONFIGURATION}" CONFIGURATION)
-    get_target_property(orc_static_location orc::orc LOCATION_${CONFIGURATION})
-    get_filename_component(orc_lib_dir "${orc_static_location}" DIRECTORY)
-    set_property(TARGET "${target_name}"
-                 APPEND
-                 PROPERTY IMPORTED_CONFIGURATIONS ${CONFIGURATION})
-    set_target_properties("${target_name}"
-                          PROPERTIES IMPORTED_LOCATION_${CONFIGURATION}
-                                     "${orc_lib_dir}/${static_lib_name}")
-  endforeach()
-endforeach()
-
 check_required_components(orc)
 
 foreach(BUILD_TYPE_SUFFIX
diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt
index 8cfc33dda..2f81bb802 100644
--- a/c++/src/CMakeLists.txt
+++ b/c++/src/CMakeLists.txt
@@ -119,8 +119,8 @@ CHECK_CXX_SOURCE_RUNS("
   HAS_POST_2038
 )
 
-set(CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIR})
-set(CMAKE_REQUIRED_LIBRARIES orc_zlib)
+set(CMAKE_REQUIRED_INCLUDES ${ZLIB_INCLUDE_DIRS})
+set(CMAKE_REQUIRED_LIBRARIES ${ZLIB_LIBRARIES})
 CHECK_CXX_SOURCE_COMPILES("
     #define Z_PREFIX
     #include<zlib.h>
@@ -205,14 +205,14 @@ add_library (orc STATIC ${SOURCE_FILES})
 target_link_libraries (orc
   INTERFACE
     ${ORC_INSTALL_INTERFACE_TARGETS}
-  PRIVATE
+  PUBLIC
     $<BUILD_INTERFACE:orc::protobuf>
     $<BUILD_INTERFACE:orc::zlib>
-    $<BUILD_INTERFACE:orc::snappy>
+    $<BUILD_INTERFACE:orc::Snappy>
     $<BUILD_INTERFACE:orc::lz4>
     $<BUILD_INTERFACE:orc::zstd>
     $<BUILD_INTERFACE:${LIBHDFSPP_LIBRARIES}>
-    $<BUILD_INTERFACE:${SPARSEHASH_LIBRARIES}>
+    $<BUILD_INTERFACE:$<TARGET_NAME_IF_EXISTS:orc::sparsehash>>
   )
 
 target_include_directories (orc
diff --git a/c++/src/wrap/orc-proto-wrapper.cc 
b/c++/src/wrap/orc-proto-wrapper.cc
index 2c9c927c3..30771507b 100644
--- a/c++/src/wrap/orc-proto-wrapper.cc
+++ b/c++/src/wrap/orc-proto-wrapper.cc
@@ -23,6 +23,7 @@
 DIAGNOSTIC_IGNORE("-Warray-bounds")
 DIAGNOSTIC_IGNORE("-Wconversion")
 DIAGNOSTIC_IGNORE("-Wdeprecated")
+DIAGNOSTIC_IGNORE("-Wdeprecated-declarations")
 DIAGNOSTIC_IGNORE("-Wignored-qualifiers")
 DIAGNOSTIC_IGNORE("-Wpadded")
 DIAGNOSTIC_IGNORE("-Wsign-compare")
diff --git a/c++/src/wrap/orc-proto-wrapper.hh 
b/c++/src/wrap/orc-proto-wrapper.hh
index 014c7d657..a1afaccdd 100644
--- a/c++/src/wrap/orc-proto-wrapper.hh
+++ b/c++/src/wrap/orc-proto-wrapper.hh
@@ -27,6 +27,7 @@ DIAGNOSTIC_PUSH
 #if defined(__GNUC__) || defined(__clang__)
 DIAGNOSTIC_IGNORE("-Wconversion")
 DIAGNOSTIC_IGNORE("-Wdeprecated")
+DIAGNOSTIC_IGNORE("-Wdeprecated-declarations")
 DIAGNOSTIC_IGNORE("-Wsign-conversion")
 DIAGNOSTIC_IGNORE("-Wunused-parameter")
 #endif
diff --git a/c++/test/CMakeLists.txt b/c++/test/CMakeLists.txt
index 374cb45b2..93b066db6 100644
--- a/c++/test/CMakeLists.txt
+++ b/c++/test/CMakeLists.txt
@@ -62,10 +62,6 @@ add_executable (orc-test
 
 target_link_libraries (orc-test
   orc
-  orc::lz4
-  orc::protobuf
-  orc::snappy
-  orc::zlib
   orc::gtest
   orc::gmock
 )
@@ -76,7 +72,6 @@ add_executable (create-test-files
 
 target_link_libraries (create-test-files
   orc
-  orc::protobuf
 )
 
 if (TEST_VALGRIND_MEMCHECK)
diff --git a/cmake_modules/FindGTest.cmake b/cmake_modules/FindGTestAlt.cmake
similarity index 95%
rename from cmake_modules/FindGTest.cmake
rename to cmake_modules/FindGTestAlt.cmake
index ee40378ac..802a88d5e 100644
--- a/cmake_modules/FindGTest.cmake
+++ b/cmake_modules/FindGTestAlt.cmake
@@ -22,7 +22,7 @@
 # GTEST_LIBRARY: path to libgtest
 # GMOCK_STATIC_LIB: is set to gmock.a static library
 # GTEST_STATIC_LIB: is set to gtest.a static library
-# GTEST_FOUND is set if GTEST is found
+# GTestAlt_FOUND is set if GTEST is found
 
 if (NOT "${GTEST_HOME}" STREQUAL "")
   message (STATUS "GTEST_HOME set: ${GTEST_HOME}")
@@ -52,14 +52,14 @@ find_library (GTEST_STATIC_LIB NAMES 
${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_
   PATH_SUFFIXES "lib")
 
 if (GTEST_INCLUDE_DIR AND GMOCK_LIBRARY)
-  set (GTEST_FOUND TRUE)
+  set (GTestAlt_FOUND TRUE)
   set (GTEST_HEADER_NAME gmock/gmock.h)
   set (GTEST_HEADER ${GTEST_INCLUDE_DIR}/${GTEST_HEADER_NAME})
 else ()
-  set (GTEST_FOUND FALSE)
+  set (GTestAlt_FOUND FALSE)
 endif ()
 
-if (GTEST_FOUND)
+if (GTestAlt_FOUND)
   message (STATUS "Found the GTest header: ${GTEST_HEADER}")
   message (STATUS "Found the GTest library: ${GTEST_LIBRARY}")
   message (STATUS "Found the GMock library: ${GMOCK_LIBRARY}")
diff --git a/cmake_modules/FindLZ4.cmake b/cmake_modules/FindLZ4Alt.cmake
similarity index 94%
rename from cmake_modules/FindLZ4.cmake
rename to cmake_modules/FindLZ4Alt.cmake
index 3b9cc7fbd..dc599836e 100644
--- a/cmake_modules/FindLZ4.cmake
+++ b/cmake_modules/FindLZ4Alt.cmake
@@ -20,7 +20,7 @@
 # LZ4_INCLUDE_DIR: directory containing headers
 # LZ4_LIBRARY: path to liblz4
 # LZ4_STATIC_LIB: path to lz4.a
-# LZ4_FOUND: whether LZ4 has been found
+# LZ4Alt_FOUND: whether LZ4 has been found
 
 if (NOT LZ4_HOME)
   if (DEFINED ENV{LZ4_HOME})
@@ -52,14 +52,14 @@ find_library (LZ4_STATIC_LIB NAMES 
${CMAKE_STATIC_LIBRARY_PREFIX}${LZ4_LIB_NAME}
   PATH_SUFFIXES "lib" "lib64")
 
 if (LZ4_INCLUDE_DIR AND LZ4_LIBRARY)
-  set (LZ4_FOUND TRUE)
+  set (LZ4Alt_FOUND TRUE)
   set (LZ4_HEADER_NAME lz4.h)
   set (LZ4_HEADER ${LZ4_INCLUDE_DIR}/${LZ4_HEADER_NAME})
 else ()
-  set (LZ4_FOUND FALSE)
+  set (LZ4Alt_FOUND FALSE)
 endif ()
 
-if (LZ4_FOUND)
+if (LZ4Alt_FOUND)
   message (STATUS "Found the LZ4 header: ${LZ4_HEADER}")
   message (STATUS "Found the LZ4 library: ${LZ4_LIBRARY}")
   if (LZ4_STATIC_LIB)
@@ -85,7 +85,7 @@ mark_as_advanced (
   LZ4_LIBRARY
 )
 
-if(LZ4_FOUND AND NOT TARGET LZ4::lz4)
+if(LZ4Alt_FOUND AND NOT TARGET LZ4::lz4)
   add_library(LZ4::lz4 UNKNOWN IMPORTED)
   set_target_properties(LZ4::lz4
                         PROPERTIES IMPORTED_LOCATION "${LZ4_LIBRARY}"
diff --git a/cmake_modules/FindProtobuf.cmake 
b/cmake_modules/FindProtobufAlt.cmake
similarity index 96%
rename from cmake_modules/FindProtobuf.cmake
rename to cmake_modules/FindProtobufAlt.cmake
index ca91fb5ad..efc004136 100644
--- a/cmake_modules/FindProtobuf.cmake
+++ b/cmake_modules/FindProtobufAlt.cmake
@@ -17,7 +17,7 @@
 
 # PROTOBUF_HOME environmental variable is used to check for Protobuf headers 
and static library
 
-# Protobuf_FOUND is set if Protobuf is found
+# ProtobufAlt_FOUND is set if Protobuf is found
 # PROTOBUF_INCLUDE_DIR: directory containing headers
 # PROTOBUF_LIBRARY: location of libprotobuf
 # PROTOBUF_STATIC_LIB: location of protobuf.a
@@ -54,7 +54,7 @@ if (NOT DEFINED CMAKE_STATIC_LIBRARY_SUFFIX)
 endif ()
 
 find_package (Protobuf CONFIG)
-if (Protobuf_FOUND)
+if (ProtobufAlt_FOUND)
   if (TARGET protobuf::libprotobuf)
     set (PROTOBUF_LIBRARY protobuf::libprotobuf)
     set (PROTOBUF_STATIC_LIB PROTOBUF_STATIC_LIB-NOTFOUND)
@@ -127,14 +127,14 @@ else()
 endif ()
 
 if (PROTOBUF_INCLUDE_DIR AND PROTOBUF_LIBRARY AND PROTOC_LIBRARY AND 
PROTOBUF_EXECUTABLE)
-  set (Protobuf_FOUND TRUE)
+  set (ProtobufAlt_FOUND TRUE)
   set (PROTOBUF_LIB_NAME protobuf)
   set (PROTOC_LIB_NAME protoc)
 else ()
-  set (Protobuf_FOUND FALSE)
+  set (ProtobufAlt_FOUND FALSE)
 endif ()
 
-if (Protobuf_FOUND)
+if (ProtobufAlt_FOUND)
   message (STATUS "Found the Protobuf headers: ${PROTOBUF_INCLUDE_DIR}")
   message (STATUS "Found the Protobuf library: ${PROTOBUF_LIBRARY}")
   message (STATUS "Found the Protoc library: ${PROTOC_LIBRARY}")
@@ -167,7 +167,7 @@ mark_as_advanced (
   PROTOC_LIBRARY
 )
 
-if(Protobuf_FOUND AND NOT TARGET protobuf::libprotobuf)
+if(ProtobufAlt_FOUND AND NOT TARGET protobuf::libprotobuf)
   add_library(protobuf::libprotobuf UNKNOWN IMPORTED)
   set_target_properties(protobuf::libprotobuf
                         PROPERTIES IMPORTED_LOCATION "${PROTOBUF_LIBRARY}"
diff --git a/cmake_modules/FindSnappy.cmake b/cmake_modules/FindSnappyAlt.cmake
similarity index 94%
rename from cmake_modules/FindSnappy.cmake
rename to cmake_modules/FindSnappyAlt.cmake
index 1ad991454..e9a5eb7c8 100644
--- a/cmake_modules/FindSnappy.cmake
+++ b/cmake_modules/FindSnappyAlt.cmake
@@ -20,7 +20,7 @@
 # SNAPPY_INCLUDE_DIR: directory containing headers
 # SNAPPY_LIBRARY: path to libsnappy
 # SNAPPY_STATIC_LIB: path to libsnappy.a
-# Snappy_FOUND: whether snappy has been found
+# SnappyAlt_FOUND: whether snappy has been found
 
 if (NOT SNAPPY_HOME)
   if (DEFINED ENV{SNAPPY_HOME})
@@ -56,14 +56,14 @@ find_library (SNAPPY_STATIC_LIB NAMES 
${CMAKE_STATIC_LIBRARY_PREFIX}${SNAPPY_LIB
   PATH_SUFFIXES "lib" "lib64")
 
 if (SNAPPY_INCLUDE_DIR AND SNAPPY_LIBRARY)
-  set (Snappy_FOUND TRUE)
+  set (SnappyAlt_FOUND TRUE)
   set (SNAPPY_HEADER_NAME snappy.h)
   set (SNAPPY_HEADER ${SNAPPY_INCLUDE_DIR}/${SNAPPY_HEADER_NAME})
 else ()
-  set (Snappy_FOUND FALSE)
+  set (SnappyAlt_FOUND FALSE)
 endif ()
 
-if (Snappy_FOUND)
+if (SnappyAlt_FOUND)
   message (STATUS "Found the Snappy header: ${SNAPPY_HEADER}")
   message (STATUS "Found the Snappy library: ${SNAPPY_LIBRARY}")
   if (SNAPPY_STATIC_LIB)
@@ -89,7 +89,7 @@ mark_as_advanced (
   SNAPPY_LIBRARY
 )
 
-if(Snappy_FOUND AND NOT TARGET Snappy::snappy)
+if(SnappyAlt_FOUND AND NOT TARGET Snappy::snappy)
   add_library(Snappy::snappy UNKNOWN IMPORTED)
   set_target_properties(Snappy::snappy
                         PROPERTIES IMPORTED_LOCATION "${SNAPPY_LIBRARY}"
diff --git a/cmake_modules/FindZLIB.cmake b/cmake_modules/FindZLIBAlt.cmake
similarity index 94%
rename from cmake_modules/FindZLIB.cmake
rename to cmake_modules/FindZLIBAlt.cmake
index 374814a7f..962327128 100644
--- a/cmake_modules/FindZLIB.cmake
+++ b/cmake_modules/FindZLIBAlt.cmake
@@ -20,7 +20,7 @@
 # ZLIB_INCLUDE_DIR: directory containing headers
 # ZLIB_LIBRARY: path to libz/libzlib
 # ZLIB_STATIC_LIB: path to zlib.a
-# ZLIB_FOUND: whether ZLIB has been found
+# ZLIBAlt_FOUND: whether ZLIB has been found
 
 if (NOT ZLIB_HOME)
   if (DEFINED ENV{ZLIB_HOME})
@@ -56,14 +56,14 @@ find_library (ZLIB_STATIC_LIB NAMES 
${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_STATIC_
   PATH_SUFFIXES "lib")
 
 if (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
-  set (ZLIB_FOUND TRUE)
+  set (ZLIBAlt_FOUND TRUE)
   set (ZLIB_HEADER_NAME zlib.h)
   set (ZLIB_HEADER ${ZLIB_INCLUDE_DIR}/${ZLIB_HEADER_NAME})
 else ()
-  set (ZLIB_FOUND FALSE)
+  set (ZLIBAlt_FOUND FALSE)
 endif ()
 
-if (ZLIB_FOUND)
+if (ZLIBAlt_FOUND)
   message (STATUS "Found the ZLIB header: ${ZLIB_HEADER}")
   message (STATUS "Found the ZLIB library: ${ZLIB_LIBRARY}")
   if (ZLIB_STATIC_LIB)
@@ -89,7 +89,7 @@ mark_as_advanced (
   ZLIB_LIBRARY
 )
 
-if(ZLIB_FOUND AND NOT TARGET ZLIB::ZLIB)
+if(ZLIBAlt_FOUND AND NOT TARGET ZLIB::ZLIB)
   add_library(ZLIB::ZLIB UNKNOWN IMPORTED)
   set_target_properties(ZLIB::ZLIB
                         PROPERTIES IMPORTED_LOCATION "${ZLIB_LIBRARY}"
diff --git a/cmake_modules/FindZSTD.cmake b/cmake_modules/FindZSTDAlt.cmake
similarity index 95%
rename from cmake_modules/FindZSTD.cmake
rename to cmake_modules/FindZSTDAlt.cmake
index 581719453..402f70514 100644
--- a/cmake_modules/FindZSTD.cmake
+++ b/cmake_modules/FindZSTDAlt.cmake
@@ -20,7 +20,7 @@
 # ZSTD_INCLUDE_DIR: directory containing headers
 # ZSTD_LIBRARY: path to libzstd
 # ZSTD_STATIC_LIB: path to libzstd.a
-# ZSTD_FOUND: whether zstd has been found
+# ZSTDAlt_FOUND: whether zstd has been found
 
 if (NOT ZSTD_HOME)
   if (DEFINED ENV{ZSTD_HOME})
@@ -52,14 +52,14 @@ find_library (ZSTD_STATIC_LIB NAMES 
${CMAKE_STATIC_LIBRARY_PREFIX}zstd${CMAKE_ST
         PATH_SUFFIXES "lib")
 
 if (ZSTD_INCLUDE_DIR AND ZSTD_LIBRARY)
-  set (ZSTD_FOUND TRUE)
+  set (ZSTDAlt_FOUND TRUE)
   set (ZSTD_HEADER_NAME zstd.h)
   set (ZSTD_HEADER ${ZSTD_INCLUDE_DIR}/${ZSTD_HEADER_NAME})
 else ()
-  set (ZSTD_FOUND FALSE)
+  set (ZSTDAlt_FOUND FALSE)
 endif ()
 
-if (ZSTD_FOUND)
+if (ZSTDAlt_FOUND)
   message (STATUS "Found the zstd header: ${ZSTD_HEADER}")
   message (STATUS "Found the zstd library: ${ZSTD_LIBRARY}")
   if (ZSTD_STATIC_LIB)
@@ -85,7 +85,7 @@ mark_as_advanced (
         ZSTD_LIBRARY
 )
 
-if(ZSTD_FOUND)
+if(ZSTDAlt_FOUND)
   if(NOT TARGET zstd::libzstd_static AND ZSTD_STATIC_LIB)
     add_library(zstd::libzstd_static STATIC IMPORTED)
     set_target_properties(zstd::libzstd_static
diff --git a/cmake_modules/ThirdpartyToolchain.cmake 
b/cmake_modules/ThirdpartyToolchain.cmake
index 9103ace12..2dde7e7e8 100644
--- a/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cmake_modules/ThirdpartyToolchain.cmake
@@ -16,8 +16,8 @@
 # under the License.
 
 INCLUDE(ExternalProject)
+INCLUDE(FetchContent)
 
-set(ORC_VENDOR_DEPENDENCIES)
 set(ORC_SYSTEM_DEPENDENCIES)
 set(ORC_INSTALL_INTERFACE_TARGETS)
 
@@ -54,50 +54,22 @@ string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_BUILD_TYPE)
 
 if (DEFINED ENV{SNAPPY_HOME})
   set (SNAPPY_HOME "$ENV{SNAPPY_HOME}")
-elseif (Snappy_ROOT)
-  set (SNAPPY_HOME "${Snappy_ROOT}")
-elseif (DEFINED ENV{Snappy_ROOT})
-  set (SNAPPY_HOME "$ENV{Snappy_ROOT}")
-elseif (SNAPPY_ROOT)
-  set (SNAPPY_HOME "${SNAPPY_ROOT}")
-elseif (DEFINED ENV{SNAPPY_ROOT})
-  set (SNAPPY_HOME "$ENV{SNAPPY_ROOT}")
 endif ()
 
 if (DEFINED ENV{ZLIB_HOME})
   set (ZLIB_HOME "$ENV{ZLIB_HOME}")
-elseif (ZLIB_ROOT)
-  set (ZLIB_HOME "${ZLIB_ROOT}")
-elseif (DEFINED ENV{ZLIB_ROOT})
-  set (ZLIB_HOME "$ENV{ZLIB_ROOT}")
 endif ()
 
 if (DEFINED ENV{LZ4_HOME})
   set (LZ4_HOME "$ENV{LZ4_HOME}")
-elseif (LZ4_ROOT)
-  set (LZ4_HOME "${LZ4_ROOT}")
-elseif (DEFINED ENV{LZ4_ROOT})
-  set (LZ4_HOME "$ENV{LZ4_ROOT}")
 endif ()
 
 if (DEFINED ENV{PROTOBUF_HOME})
   set (PROTOBUF_HOME "$ENV{PROTOBUF_HOME}")
-elseif (Protobuf_ROOT)
-  set (PROTOBUF_HOME "${Protobuf_ROOT}")
-elseif (DEFINED ENV{Protobuf_ROOT})
-  set (PROTOBUF_HOME "$ENV{Protobuf_ROOT}")
-elseif (PROTOBUF_ROOT)
-  set (PROTOBUF_HOME "${PROTOBUF_ROOT}")
-elseif (DEFINED ENV{PROTOBUF_ROOT})
-  set (PROTOBUF_HOME "$ENV{PROTOBUF_ROOT}")
 endif ()
 
 if (DEFINED ENV{ZSTD_HOME})
   set (ZSTD_HOME "$ENV{ZSTD_HOME}")
-elseif (ZSTD_ROOT)
-  set (ZSTD_HOME "${ZSTD_ROOT}")
-elseif (DEFINED ENV{ZSTD_ROOT})
-  set (ZSTD_HOME "$ENV{ZSTD_ROOT}")
 endif ()
 
 if (DEFINED ENV{GTEST_HOME})
@@ -137,6 +109,33 @@ function(orc_provide_find_module PACKAGE_NAME)
   orc_provide_cmake_module("Find${PACKAGE_NAME}")
 endfunction()
 
+# ----------------------------------------------------------------------
+# FetchContent
+
+include(FetchContent)
+set(FC_DECLARE_COMMON_OPTIONS)
+if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
+  list(APPEND FC_DECLARE_COMMON_OPTIONS EXCLUDE_FROM_ALL TRUE)
+endif()
+
+macro(prepare_fetchcontent)
+  set(BUILD_SHARED_LIBS OFF)
+  set(BUILD_STATIC_LIBS ON)
+  set(CMAKE_COMPILE_WARNING_AS_ERROR OFF)
+  set(CMAKE_WARN_DEPRECATED OFF)
+  set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY ON)
+  set(CMAKE_POLICY_VERSION_MINIMUM 3.25)
+  if(BUILD_POSITION_INDEPENDENT_LIB)
+    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+  endif()
+  # Use "NEW" for CMP0077 by default.
+  #
+  # https://cmake.org/cmake/help/latest/policy/CMP0077.html
+  #
+  # option() honors normal variables.
+  set(CMAKE_POLICY_DEFAULT_CMP0077 NEW CACHE STRING "")
+endmacro()
+
 # ----------------------------------------------------------------------
 # ORC Format
 if(DEFINED ENV{ORC_FORMAT_URL})
@@ -155,6 +154,103 @@ ExternalProject_Add (orc-format_ep
   TEST_COMMAND     ""
 )
 
+# ----------------------------------------------------------------------
+# Protobuf
+#
+# XXX: It must be processed before ZLIB, otherwise ZLIB_LIBRARIES will 
interfere with building protobuf.
+
+if (ORC_PACKAGE_KIND STREQUAL "conan")
+  find_package (Protobuf REQUIRED CONFIG)
+  add_library (orc_protobuf INTERFACE)
+  target_link_libraries(orc_protobuf INTERFACE protobuf::protobuf)
+  list (APPEND ORC_SYSTEM_DEPENDENCIES Protobuf)
+  list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:protobuf::protobuf>")
+elseif (ORC_PACKAGE_KIND STREQUAL "vcpkg")
+  find_package(Protobuf CONFIG REQUIRED)
+  add_library (orc_protobuf INTERFACE IMPORTED)
+  target_link_libraries(orc_protobuf INTERFACE protobuf::libprotobuf)
+  list (APPEND ORC_SYSTEM_DEPENDENCIES Protobuf)
+  list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:protobuf::libprotobuf>")
+  set (PROTOBUF_EXECUTABLE protobuf::protoc)
+elseif (NOT "${PROTOBUF_HOME}" STREQUAL "")
+  find_package (ProtobufAlt REQUIRED)
+
+  if (ORC_PREFER_STATIC_PROTOBUF AND PROTOBUF_STATIC_LIB)
+    orc_add_resolved_library (orc_protobuf ${PROTOBUF_STATIC_LIB} 
${PROTOBUF_INCLUDE_DIR})
+  else ()
+    orc_add_resolved_library (orc_protobuf ${PROTOBUF_LIBRARY} 
${PROTOBUF_INCLUDE_DIR})
+  endif ()
+
+  if (ORC_PREFER_STATIC_PROTOBUF AND PROTOC_STATIC_LIB)
+    orc_add_resolved_library (orc_protoc ${PROTOC_STATIC_LIB} 
${PROTOBUF_INCLUDE_DIR})
+  else ()
+    orc_add_resolved_library (orc_protoc ${PROTOC_LIBRARY} 
${PROTOBUF_INCLUDE_DIR})
+  endif ()
+
+  list (APPEND ORC_SYSTEM_DEPENDENCIES ProtobufAlt)
+  list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:protobuf::libprotobuf>")
+  orc_provide_find_module (ProtobufAlt)
+else ()
+  block(PROPAGATE ORC_SYSTEM_DEPENDENCIES ORC_INSTALL_INTERFACE_TARGETS 
PROTOBUF_EXECUTABLE)
+    prepare_fetchcontent()
+
+    set(protobuf_INSTALL OFF)
+    set(protobuf_BUILD_TESTS OFF)
+    set(protobuf_BUILD_PROTOBUF_BINARIES ON)
+    set(protobuf_BUILD_PROTOC_BINARIES ON)
+    set(protobuf_WITH_ZLIB OFF)
+    set(protobuf_BUILD_SHARED_LIBS OFF)
+
+    # Set compiler flags to suppress warnings before fetching protobuf
+    if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL 
"GNU")
+      set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
+      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
+    endif()
+
+    fetchcontent_declare(Protobuf
+      URL 
"https://github.com/google/protobuf/archive/v${PROTOBUF_VERSION}.tar.gz";
+      SOURCE_SUBDIR "cmake"
+      FIND_PACKAGE_ARGS
+      NAMES Protobuf
+      CONFIG
+      )
+    fetchcontent_makeavailable(Protobuf)
+
+    if(protobuf_SOURCE_DIR)
+      message(STATUS "Using vendored Protobuf")
+
+      add_library(protobuf::libprotobuf ALIAS libprotobuf)
+      add_executable(protobuf::protoc ALIAS protoc)
+
+      if(BUILD_POSITION_INDEPENDENT_LIB)
+        set_target_properties(libprotobuf PROPERTIES POSITION_INDEPENDENT_CODE 
ON)
+        set_target_properties(protoc PROPERTIES POSITION_INDEPENDENT_CODE ON)
+      endif()
+
+      if(INSTALL_VENDORED_LIBS)
+        set_target_properties(libprotobuf PROPERTIES OUTPUT_NAME 
"orc_vendored_protobuf")
+        install(TARGETS libprotobuf
+                EXPORT orc_targets
+                RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+                ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+                LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+      endif()
+
+      list(APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:orc::libprotobuf>")
+    else()
+      message(STATUS "Using system Protobuf")
+      list(APPEND ORC_SYSTEM_DEPENDENCIES Protobuf)
+      list(APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:protobuf::libprotobuf>")
+    endif()
+
+    add_library(orc_protobuf INTERFACE IMPORTED)
+    target_link_libraries(orc_protobuf INTERFACE protobuf::libprotobuf)
+    set(PROTOBUF_EXECUTABLE protobuf::protoc)
+  endblock()
+endif ()
+
+add_library (orc::protobuf ALIAS orc_protobuf)
+
 # ----------------------------------------------------------------------
 # Snappy
 if (ORC_PACKAGE_KIND STREQUAL "conan")
@@ -170,41 +266,70 @@ elseif (ORC_PACKAGE_KIND STREQUAL "vcpkg")
   list (APPEND ORC_SYSTEM_DEPENDENCIES Snappy)
   list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:Snappy::snappy>")
 elseif (NOT "${SNAPPY_HOME}" STREQUAL "")
-  find_package (Snappy REQUIRED)
+  find_package (SnappyAlt REQUIRED)
   if (ORC_PREFER_STATIC_SNAPPY AND SNAPPY_STATIC_LIB)
     orc_add_resolved_library (orc_snappy ${SNAPPY_STATIC_LIB} 
${SNAPPY_INCLUDE_DIR})
   else ()
     orc_add_resolved_library (orc_snappy ${SNAPPY_LIBRARY} 
${SNAPPY_INCLUDE_DIR})
   endif ()
-  list (APPEND ORC_SYSTEM_DEPENDENCIES Snappy)
+  list (APPEND ORC_SYSTEM_DEPENDENCIES SnappyAlt)
   list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:Snappy::snappy>")
-  orc_provide_find_module (Snappy)
+  orc_provide_find_module (SnappyAlt)
 else ()
-  set(SNAPPY_HOME "${THIRDPARTY_DIR}/snappy_ep-install")
-  set(SNAPPY_INCLUDE_DIR "${SNAPPY_HOME}/include")
-  set(SNAPPY_STATIC_LIB_NAME 
"${CMAKE_STATIC_LIBRARY_PREFIX}snappy${CMAKE_STATIC_LIBRARY_SUFFIX}")
-  set(SNAPPY_STATIC_LIB "${SNAPPY_HOME}/lib/${SNAPPY_STATIC_LIB_NAME}")
-  set(SNAPPY_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${SNAPPY_HOME}
-                        -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_LIBDIR=lib
-                        -DSNAPPY_BUILD_BENCHMARKS=OFF)
-
-  if (BUILD_POSITION_INDEPENDENT_LIB)
-    set(SNAPPY_CMAKE_ARGS ${SNAPPY_CMAKE_ARGS} 
-DCMAKE_POSITION_INDEPENDENT_CODE=ON)
-  endif ()
+  block(PROPAGATE ORC_SYSTEM_DEPENDENCIES ORC_INSTALL_INTERFACE_TARGETS)
+    prepare_fetchcontent()
+
+    set(SNAPPY_BUILD_TESTS OFF)
+    set(SNAPPY_BUILD_BENCHMARKS OFF)
+    set(SNAPPY_INSTALL OFF)
+
+    fetchcontent_declare(Snappy
+      URL "https://github.com/google/snappy/archive/${SNAPPY_VERSION}.tar.gz";
+      FIND_PACKAGE_ARGS
+      NAMES Snappy
+      CONFIG
+      )
+    fetchcontent_makeavailable(Snappy)
+
+    if(snappy_SOURCE_DIR)
+      message(STATUS "Using vendored Snappy")
+      if(NOT TARGET Snappy::snappy)
+        add_library(Snappy::snappy INTERFACE IMPORTED)
+        target_link_libraries(Snappy::snappy INTERFACE snappy)
+        target_include_directories(Snappy::snappy INTERFACE 
${snappy_SOURCE_DIR} ${snappy_BINARY_DIR})
+      endif()
 
-  ExternalProject_Add (snappy_ep
-    URL "https://github.com/google/snappy/archive/${SNAPPY_VERSION}.tar.gz";
-    CMAKE_ARGS ${SNAPPY_CMAKE_ARGS} -DSNAPPY_BUILD_TESTS=OFF
-    ${THIRDPARTY_LOG_OPTIONS}
-    BUILD_BYPRODUCTS "${SNAPPY_STATIC_LIB}")
+      if(BUILD_POSITION_INDEPENDENT_LIB)
+        set_target_properties(snappy POSITION_INDEPENDENT_CODE ON)
+      endif()
 
-  orc_add_built_library (snappy_ep orc_snappy ${SNAPPY_STATIC_LIB} 
${SNAPPY_INCLUDE_DIR})
+      if(INSTALL_VENDORED_LIBS)
+        set_target_properties(snappy PROPERTIES OUTPUT_NAME 
"orc_vendored_snappy")
+
+        install(FILES ${snappy_SOURCE_DIR}/snappy-c.h DESTINATION 
"${CMAKE_INSTALL_INCLUDEDIR}")
+        install(FILES ${snappy_SOURCE_DIR}/snappy-sinksource.h DESTINATION 
"${CMAKE_INSTALL_INCLUDEDIR}")
+        install(FILES ${snappy_SOURCE_DIR}/snappy.h DESTINATION 
"${CMAKE_INSTALL_INCLUDEDIR}")
+        install(FILES ${snappy_BINARY_DIR}/snappy-stubs-public.h DESTINATION 
"${CMAKE_INSTALL_INCLUDEDIR}")
+        install(TARGETS snappy
+                EXPORT orc_targets
+                RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+                ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+                LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+      endif()
 
-  list (APPEND ORC_VENDOR_DEPENDENCIES 
"orc::vendored_snappy|${SNAPPY_STATIC_LIB_NAME}")
-  list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:orc::vendored_snappy>")
+      list(APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:orc::snappy>")
+    else()
+      message(STATUS "Using system Snappy")
+      list(APPEND ORC_SYSTEM_DEPENDENCIES Snappy)
+      list(APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:Snappy::snappy>")
+    endif()
+
+    add_library(orc_snappy INTERFACE IMPORTED)
+    target_link_libraries(orc_snappy INTERFACE Snappy::snappy)
+  endblock()
 endif ()
 
-add_library (orc::snappy ALIAS orc_snappy)
+add_library (orc::Snappy ALIAS orc_snappy)
 
 # ----------------------------------------------------------------------
 # ZLIB
@@ -223,48 +348,76 @@ elseif (ORC_PACKAGE_KIND STREQUAL "vcpkg")
   list (APPEND ORC_SYSTEM_DEPENDENCIES ZLIB)
   list (APPEND ORC_INSTALL_INTERFACE_TARGETS "$<INSTALL_INTERFACE:ZLIB::ZLIB>")
 elseif (NOT "${ZLIB_HOME}" STREQUAL "")
-  find_package (ZLIB REQUIRED)
+  find_package (ZLIBAlt REQUIRED)
   if (ORC_PREFER_STATIC_ZLIB AND ZLIB_STATIC_LIB)
     orc_add_resolved_library (orc_zlib ${ZLIB_STATIC_LIB} ${ZLIB_INCLUDE_DIR})
   else ()
     orc_add_resolved_library (orc_zlib ${ZLIB_LIBRARY} ${ZLIB_INCLUDE_DIR})
   endif ()
-  list (APPEND ORC_SYSTEM_DEPENDENCIES ZLIB)
+  list (APPEND ORC_SYSTEM_DEPENDENCIES ZLIBAlt)
   list (APPEND ORC_INSTALL_INTERFACE_TARGETS "$<INSTALL_INTERFACE:ZLIB::ZLIB>")
-  orc_provide_find_module (ZLIB)
+  orc_provide_find_module (ZLIBAlt)
 else ()
-  set(ZLIB_PREFIX "${THIRDPARTY_DIR}/zlib_ep-install")
-  set(ZLIB_INCLUDE_DIR "${ZLIB_PREFIX}/include")
-  if (MSVC)
-    set(ZLIB_STATIC_LIB_NAME zlibstatic)
-    if (${UPPERCASE_BUILD_TYPE} STREQUAL "DEBUG")
-      set(ZLIB_STATIC_LIB_NAME ${ZLIB_STATIC_LIB_NAME}d)
-    endif ()
-  else ()
-    set(ZLIB_STATIC_LIB_NAME z)
-  endif ()
-  set(ZLIB_STATIC_LIB_NAME 
"${CMAKE_STATIC_LIBRARY_PREFIX}${ZLIB_STATIC_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}")
-  set(ZLIB_STATIC_LIB "${ZLIB_PREFIX}/lib/${ZLIB_STATIC_LIB_NAME}")
-  set(ZLIB_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${ZLIB_PREFIX}
-                      -DBUILD_SHARED_LIBS=OFF)
+  block(PROPAGATE ORC_SYSTEM_DEPENDENCIES ORC_INSTALL_INTERFACE_TARGETS 
ZLIB_LIBRARIES ZLIB_INCLUDE_DIRS)
+    prepare_fetchcontent()
+
+    set(ZLIB_BUILD_EXAMPLES OFF)
+    set(ZLIB_BUILD_TESTING OFF)
+    set(ZLIB_BUILD_STATIC ON)
+    set(ZLIB_BUILD_SHARED OFF)
+    set(ZLIB_INSTALL OFF)
+    set(ZLIB_PREFIX OFF)
+
+    fetchcontent_declare(ZLIB
+      # URL "https://zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz";
+      # See https://github.com/madler/zlib/issues/937
+      GIT_REPOSITORY "https://github.com/madler/zlib.git";
+      GIT_TAG 5a82f71ed1dfc0bec044d9702463dbdf84ea3b71
+      FIND_PACKAGE_ARGS
+      NAMES ZLIB
+      CONFIG
+      )
+    fetchcontent_makeavailable(ZLIB)
+
+    if(zlib_SOURCE_DIR)
+      message(STATUS "Using vendored ZLIB")
+      if(NOT TARGET ZLIB::ZLIB)
+        add_library(ZLIB::ZLIB ALIAS zlibstatic)
+      endif()
 
-  if (BUILD_POSITION_INDEPENDENT_LIB)
-    set(ZLIB_CMAKE_ARGS ${ZLIB_CMAKE_ARGS} 
-DCMAKE_POSITION_INDEPENDENT_CODE=ON)
-  endif ()
+      if(BUILD_POSITION_INDEPENDENT_LIB)
+        set_target_properties(zlibstatic POSITION_INDEPENDENT_CODE ON)
+      endif()
 
-  ExternalProject_Add (zlib_ep
-    URL "https://zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz";
-    CMAKE_ARGS ${ZLIB_CMAKE_ARGS}
-    ${THIRDPARTY_LOG_OPTIONS}
-    BUILD_BYPRODUCTS "${ZLIB_STATIC_LIB}")
+      if(INSTALL_VENDORED_LIBS)
+        set_target_properties(zlibstatic PROPERTIES OUTPUT_NAME 
"orc_vendored_zlib")
+        install(TARGETS zlibstatic
+                EXPORT orc_targets
+                RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+                ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+                LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+      endif()
 
-  orc_add_built_library (zlib_ep orc_zlib ${ZLIB_STATIC_LIB} 
${ZLIB_INCLUDE_DIR})
+      list(APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:orc::ZLIBSTATIC>")
+      set(ZLIB_LIBRARIES "zlibstatic")
+      set(ZLIB_INCLUDE_DIRS "${zlib_SOURCE_DIR}")
+    else()
+      message(STATUS "Using system ZLIB")
+      # FindZLIB guarantees that ZLIB::ZLIB target exists if found
+      # See 
https://cmake.org/cmake/help/latest/module/FindZLIB.html#imported-targets
+      if(NOT TARGET ZLIB::ZLIB)
+        message(FATAL_ERROR "Using system ZLIB, but ZLIB::ZLIB not found")
+      endif()
+      list(APPEND ORC_SYSTEM_DEPENDENCIES ZLIB)
+      list(APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:ZLIB::ZLIB>")
+    endif()
 
-  list (APPEND ORC_VENDOR_DEPENDENCIES 
"orc::vendored_zlib|${ZLIB_STATIC_LIB_NAME}")
-  list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:orc::vendored_zlib>")
-endif ()
+    add_library(orc_zlib INTERFACE IMPORTED)
+    target_link_libraries(orc_zlib INTERFACE ZLIB::ZLIB)
+  endblock()
+endif()
 
-add_library (orc::zlib ALIAS orc_zlib)
+add_library(orc::zlib ALIAS orc_zlib)
 
 # ----------------------------------------------------------------------
 # Zstd
@@ -285,7 +438,7 @@ elseif (ORC_PACKAGE_KIND STREQUAL "vcpkg")
   list(APPEND ORC_SYSTEM_DEPENDENCIES zstd)
   list(APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:$<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>>")
 elseif (NOT "${ZSTD_HOME}" STREQUAL "")
-  find_package (ZSTD REQUIRED)
+  find_package (ZSTDAlt REQUIRED)
   if (ORC_PREFER_STATIC_ZSTD AND ZSTD_STATIC_LIB)
     orc_add_resolved_library (orc_zstd ${ZSTD_STATIC_LIB} ${ZSTD_INCLUDE_DIR})
     list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:zstd::libzstd_static>")
@@ -293,40 +446,60 @@ elseif (NOT "${ZSTD_HOME}" STREQUAL "")
     orc_add_resolved_library (orc_zstd ${ZSTD_LIBRARY} ${ZSTD_INCLUDE_DIR})
     list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:$<IF:$<TARGET_EXISTS:zstd::libzstd_shared>,zstd::libzstd_shared,zstd::libzstd_static>>")
   endif ()
-  list (APPEND ORC_SYSTEM_DEPENDENCIES ZSTD)
-  orc_provide_find_module (ZSTD)
+  list (APPEND ORC_SYSTEM_DEPENDENCIES ZSTDAlt)
+  orc_provide_find_module (ZSTDAlt)
 else ()
-  set(ZSTD_HOME "${THIRDPARTY_DIR}/zstd_ep-install")
-  set(ZSTD_INCLUDE_DIR "${ZSTD_HOME}/include")
-  if (MSVC)
-    set(ZSTD_STATIC_LIB_NAME zstd_static)
-    if (${UPPERCASE_BUILD_TYPE} STREQUAL "DEBUG")
-      set(ZSTD_STATIC_LIB_NAME ${ZSTD_STATIC_LIB_NAME})
-    endif ()
-  else ()
-    set(ZSTD_STATIC_LIB_NAME zstd)
-  endif ()
-  set(ZSTD_STATIC_LIB_NAME 
"${CMAKE_STATIC_LIBRARY_PREFIX}${ZSTD_STATIC_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}")
-  set(ZSTD_STATIC_LIB "${ZSTD_HOME}/lib/${ZSTD_STATIC_LIB_NAME}")
-  set(ZSTD_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${ZSTD_HOME}
-          -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_LIBDIR=lib)
-
-  if (BUILD_POSITION_INDEPENDENT_LIB)
-    set(ZSTD_CMAKE_ARGS ${ZSTD_CMAKE_ARGS} 
-DCMAKE_POSITION_INDEPENDENT_CODE=ON)
-  endif ()
-
-  set(ZSTD_CONFIGURE SOURCE_SUBDIR "build/cmake" CMAKE_ARGS ${ZSTD_CMAKE_ARGS})
+  block(PROPAGATE ORC_SYSTEM_DEPENDENCIES ORC_INSTALL_INTERFACE_TARGETS)
+    prepare_fetchcontent()
+
+    set(ZSTD_BUILD_TESTING OFF)
+    set(ZSTD_BUILD_PROGRAMS OFF)
+    set(ZSTD_BUILD_STATIC ON)
+    set(ZSTD_BUILD_SHARED OFF)
+    set(ZSTD_BUILD_CONTRIB OFF)
+
+    fetchcontent_declare(zstd
+      URL "https://github.com/facebook/zstd/archive/v${ZSTD_VERSION}.tar.gz";
+      SOURCE_SUBDIR "build/cmake"
+      FIND_PACKAGE_ARGS
+      NAMES zstd
+      CONFIG
+      )
+    fetchcontent_makeavailable(zstd)
+
+    if(zstd_SOURCE_DIR)
+      message(STATUS "Using vendored zstd")
+      if(NOT TARGET zstd::libzstd_static)
+        add_library(zstd::libzstd_static ALIAS libzstd_static)
+      endif()
+      
+      if(BUILD_POSITION_INDEPENDENT_LIB)
+        set_target_properties(libzstd_static POSITION_INDEPENDENT_CODE ON)
+      endif()
 
-  ExternalProject_Add(zstd_ep
-          URL 
"https://github.com/facebook/zstd/archive/v${ZSTD_VERSION}.tar.gz";
-          ${ZSTD_CONFIGURE}
-          ${THIRDPARTY_LOG_OPTIONS}
-          BUILD_BYPRODUCTS ${ZSTD_STATIC_LIB})
+      if(INSTALL_VENDORED_LIBS)
+        set_target_properties(libzstd_static PROPERTIES OUTPUT_NAME 
"orc_vendored_zstd")
+        install(TARGETS libzstd_static
+                EXPORT orc_targets
+                RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+                ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+                LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+      endif()
 
-  orc_add_built_library (zstd_ep orc_zstd ${ZSTD_STATIC_LIB} 
${ZSTD_INCLUDE_DIR})
+      list(APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:orc::libzstd_static>")
+    else()
+      message(STATUS "Using system zstd")
+      list(APPEND ORC_SYSTEM_DEPENDENCIES zstd)
+      list(APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:$<TARGET_NAME_IF_EXISTS:zstd::libzstd_shared>>")
+      list(APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:$<TARGET_NAME_IF_EXISTS:zstd::libzstd_static>>")
+    endif()
 
-  list (APPEND ORC_VENDOR_DEPENDENCIES 
"orc::vendored_zstd|${ZSTD_STATIC_LIB_NAME}")
-  list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:orc::vendored_zstd>")
+    add_library(orc_zstd INTERFACE IMPORTED)
+    target_link_libraries(orc_zstd INTERFACE
+      $<TARGET_NAME_IF_EXISTS:zstd::libzstd_static>
+      $<TARGET_NAME_IF_EXISTS:zstd::libzstd_shared>
+    )
+  endblock()
 endif ()
 
 add_library (orc::zstd ALIAS orc_zstd)
@@ -349,40 +522,63 @@ elseif (ORC_PACKAGE_KIND STREQUAL "vcpkg")
   list (APPEND ORC_SYSTEM_DEPENDENCIES lz4)
   list (APPEND ORC_INSTALL_INTERFACE_TARGETS "$<INSTALL_INTERFACE:LZ4::lz4>")
 elseif (NOT "${LZ4_HOME}" STREQUAL "")
-  find_package (LZ4 REQUIRED)
+  find_package (LZ4Alt REQUIRED)
   if (ORC_PREFER_STATIC_LZ4 AND LZ4_STATIC_LIB)
     orc_add_resolved_library (orc_lz4 ${LZ4_STATIC_LIB} ${LZ4_INCLUDE_DIR})
   else ()
     orc_add_resolved_library (orc_lz4 ${LZ4_LIBRARY} ${LZ4_INCLUDE_DIR})
   endif ()
-  list (APPEND ORC_SYSTEM_DEPENDENCIES LZ4)
+  list (APPEND ORC_SYSTEM_DEPENDENCIES LZ4Alt)
   list (APPEND ORC_INSTALL_INTERFACE_TARGETS "$<INSTALL_INTERFACE:LZ4::lz4>")
-  orc_provide_find_module (LZ4)
+  orc_provide_find_module (LZ4Alt)
 else ()
-  set(LZ4_PREFIX "${THIRDPARTY_DIR}/lz4_ep-install")
-  set(LZ4_INCLUDE_DIR "${LZ4_PREFIX}/include")
-  set(LZ4_STATIC_LIB_NAME 
"${CMAKE_STATIC_LIBRARY_PREFIX}lz4${CMAKE_STATIC_LIBRARY_SUFFIX}")
-  set(LZ4_STATIC_LIB "${LZ4_PREFIX}/lib/${LZ4_STATIC_LIB_NAME}")
-  set(LZ4_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LZ4_PREFIX}
-                     -DCMAKE_INSTALL_LIBDIR=lib
-                     -DBUILD_SHARED_LIBS=OFF)
-
-  if (BUILD_POSITION_INDEPENDENT_LIB)
-    set(LZ4_CMAKE_ARGS ${LZ4_CMAKE_ARGS} -DCMAKE_POSITION_INDEPENDENT_CODE=ON)
-  endif ()
+  block(PROPAGATE ORC_SYSTEM_DEPENDENCIES ORC_INSTALL_INTERFACE_TARGETS)
+    prepare_fetchcontent()
+
+    set(LZ4_BUILD_CLI OFF)
+
+    fetchcontent_declare(lz4
+      URL "https://github.com/lz4/lz4/archive/v${LZ4_VERSION}.tar.gz";
+      SOURCE_SUBDIR "build/cmake"
+      FIND_PACKAGE_ARGS
+      NAMES lz4
+      CONFIG
+      )
+    fetchcontent_makeavailable(lz4)
+
+    if(lz4_SOURCE_DIR)
+      message(STATUS "Using vendored lz4")
+      if(NOT TARGET LZ4::lz4_static)
+        add_library(LZ4::lz4_static ALIAS lz4_static)
+      endif()
 
-  set(LZ4_CONFIGURE SOURCE_SUBDIR "build/cmake" CMAKE_ARGS ${LZ4_CMAKE_ARGS})
+      if(BUILD_POSITION_INDEPENDENT_LIB)
+        set_target_properties(lz4_static POSITION_INDEPENDENT_CODE ON)
+      endif()
 
-  ExternalProject_Add(lz4_ep
-    URL "https://github.com/lz4/lz4/archive/v${LZ4_VERSION}.tar.gz";
-    ${LZ4_CONFIGURE}
-    ${THIRDPARTY_LOG_OPTIONS}
-    BUILD_BYPRODUCTS ${LZ4_STATIC_LIB})
+      if(INSTALL_VENDORED_LIBS)
+        set_target_properties(lz4_static PROPERTIES OUTPUT_NAME 
"orc_vendored_lz4")
+        install(TARGETS lz4_static
+                EXPORT orc_targets
+                RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+                ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+                LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+      endif()
 
-  orc_add_built_library (lz4_ep orc_lz4 ${LZ4_STATIC_LIB} ${LZ4_INCLUDE_DIR})
+      list(APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:orc::lz4_static>")
+    else()
+      message(STATUS "Using system lz4")
+      list(APPEND ORC_SYSTEM_DEPENDENCIES lz4)
+      list(APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:$<TARGET_NAME_IF_EXISTS:LZ4::lz4_shared>>")
+      list(APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:$<TARGET_NAME_IF_EXISTS:LZ4::lz4_static>>")
+    endif()
 
-  list (APPEND ORC_VENDOR_DEPENDENCIES 
"orc::vendored_lz4|${LZ4_STATIC_LIB_NAME}")
-  list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:orc::vendored_lz4>")
+    add_library(orc_lz4 INTERFACE IMPORTED)
+    target_link_libraries(orc_lz4 INTERFACE
+      $<TARGET_NAME_IF_EXISTS:LZ4::lz4_shared>
+      $<TARGET_NAME_IF_EXISTS:LZ4::lz4_static>
+    )
+  endblock()
 endif ()
 
 add_library (orc::lz4 ALIAS orc_lz4)
@@ -426,183 +622,82 @@ endif ()
 # GoogleTest (gtest now includes gmock)
 
 if (BUILD_CPP_TESTS)
-  if (NOT "${GTEST_HOME}" STREQUAL "")
-    find_package (GTest REQUIRED)
-    set (GTEST_VENDORED FALSE)
-  else ()
-    set(GTEST_PREFIX "${THIRDPARTY_DIR}/googletest_ep-install")
-    set(GTEST_INCLUDE_DIR "${GTEST_PREFIX}/include")
-    set(GMOCK_STATIC_LIB 
"${GTEST_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX}")
-    set(GTEST_STATIC_LIB 
"${GTEST_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}")
-    set(GTEST_SRC_URL 
"https://github.com/google/googletest/archive/refs/tags/v${GTEST_VERSION}.tar.gz";)
-    if(APPLE)
-      set(GTEST_CMAKE_CXX_FLAGS " -DGTEST_USE_OWN_TR1_TUPLE=1 
-Wno-unused-value -Wno-ignored-attributes")
-    else()
-      set(GTEST_CMAKE_CXX_FLAGS "")
-    endif()
-
-    set(GTEST_CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-                         -DCMAKE_INSTALL_PREFIX=${GTEST_PREFIX}
-                         -DCMAKE_INSTALL_LIBDIR=lib
-                         -Dgtest_force_shared_crt=ON
-                         -DCMAKE_CXX_FLAGS=${GTEST_CMAKE_CXX_FLAGS})
-
-  if (BUILD_POSITION_INDEPENDENT_LIB)
-    set(GTEST_CMAKE_ARGS ${GTEST_CMAKE_ARGS} 
-DCMAKE_POSITION_INDEPENDENT_CODE=ON)
-  endif ()
-
-    ExternalProject_Add(googletest_ep
-      BUILD_IN_SOURCE 1
-      URL ${GTEST_SRC_URL}
-      ${THIRDPARTY_LOG_OPTIONS}
-      CMAKE_ARGS ${GTEST_CMAKE_ARGS}
-      BUILD_BYPRODUCTS "${GMOCK_STATIC_LIB}" "${GTEST_STATIC_LIB}")
-
-    set(GMOCK_LIBRARY ${GMOCK_STATIC_LIB})
-    set(GTEST_LIBRARY ${GTEST_STATIC_LIB})
-    set(GTEST_VENDORED TRUE)
-  endif ()
-
-  # This is a bit special cased because gmock requires gtest and some
-  # distributions statically link gtest inside the gmock shared lib
   add_library (orc_gmock INTERFACE)
-  add_library (orc::gmock ALIAS orc_gmock)
   add_library (orc_gtest INTERFACE)
+  add_library (orc::gmock ALIAS orc_gmock)
   add_library (orc::gtest ALIAS orc_gtest)
-  if (ORC_PREFER_STATIC_GMOCK AND GMOCK_STATIC_LIB)
-    target_link_libraries (orc_gmock INTERFACE ${GMOCK_STATIC_LIB})
-    target_link_libraries (orc_gtest INTERFACE ${GTEST_STATIC_LIB})
-  else ()
-    target_link_libraries (orc_gmock INTERFACE ${GMOCK_LIBRARY})
-    target_link_libraries (orc_gtest INTERFACE ${GTEST_LIBRARY})
-  endif ()
-  target_include_directories (orc_gmock SYSTEM INTERFACE ${GTEST_INCLUDE_DIR})
-  target_include_directories (orc_gtest SYSTEM INTERFACE ${GTEST_INCLUDE_DIR})
-
-  if (GTEST_VENDORED)
-    add_dependencies (orc_gmock googletest_ep)
-    add_dependencies (orc_gtest googletest_ep)
-  endif ()
-
-  if (NOT APPLE AND NOT MSVC)
-    target_link_libraries (orc_gmock INTERFACE Threads::Threads)
-    target_link_libraries (orc_gtest INTERFACE Threads::Threads)
-  endif ()
-endif ()
 
-# ----------------------------------------------------------------------
-# Protobuf
+  if (NOT "${GTEST_HOME}" STREQUAL "")
+    find_package (GTestAlt REQUIRED)
 
-if (ORC_PACKAGE_KIND STREQUAL "conan")
-  find_package (Protobuf REQUIRED CONFIG)
-  add_library (orc_protobuf INTERFACE)
-  target_link_libraries(orc_protobuf INTERFACE protobuf::protobuf)
-  list (APPEND ORC_SYSTEM_DEPENDENCIES Protobuf)
-  list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:protobuf::protobuf>")
-elseif (ORC_PACKAGE_KIND STREQUAL "vcpkg")
-  find_package(Protobuf CONFIG REQUIRED)
-  add_library (orc_protobuf INTERFACE IMPORTED)
-  target_link_libraries(orc_protobuf INTERFACE protobuf::libprotobuf)
-  list (APPEND ORC_SYSTEM_DEPENDENCIES Protobuf)
-  list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:protobuf::libprotobuf>")
-  set (PROTOBUF_EXECUTABLE protobuf::protoc)
-elseif (NOT "${PROTOBUF_HOME}" STREQUAL "")
-  find_package (Protobuf REQUIRED)
+    # This is a bit special cased because gmock requires gtest and some
+    # distributions statically link gtest inside the gmock shared lib
+    if (ORC_PREFER_STATIC_GMOCK AND GMOCK_STATIC_LIB)
+      target_link_libraries (orc_gmock INTERFACE ${GMOCK_STATIC_LIB})
+      target_link_libraries (orc_gtest INTERFACE ${GTEST_STATIC_LIB})
+    else ()
+      target_link_libraries (orc_gmock INTERFACE ${GMOCK_LIBRARY})
+      target_link_libraries (orc_gtest INTERFACE ${GTEST_LIBRARY})
+    endif ()
 
-  if (ORC_PREFER_STATIC_PROTOBUF AND PROTOBUF_STATIC_LIB)
-    orc_add_resolved_library (orc_protobuf ${PROTOBUF_STATIC_LIB} 
${PROTOBUF_INCLUDE_DIR})
-  else ()
-    orc_add_resolved_library (orc_protobuf ${PROTOBUF_LIBRARY} 
${PROTOBUF_INCLUDE_DIR})
-  endif ()
+    target_include_directories (orc_gmock SYSTEM INTERFACE 
${GTEST_INCLUDE_DIR})
+    target_include_directories (orc_gtest SYSTEM INTERFACE 
${GTEST_INCLUDE_DIR})
 
-  if (ORC_PREFER_STATIC_PROTOBUF AND PROTOC_STATIC_LIB)
-    orc_add_resolved_library (orc_protoc ${PROTOC_STATIC_LIB} 
${PROTOBUF_INCLUDE_DIR})
+    if (NOT APPLE AND NOT MSVC)
+      target_link_libraries (orc_gmock INTERFACE Threads::Threads)
+      target_link_libraries (orc_gtest INTERFACE Threads::Threads)
+    endif ()
   else ()
-    orc_add_resolved_library (orc_protoc ${PROTOC_LIBRARY} 
${PROTOBUF_INCLUDE_DIR})
-  endif ()
-
-  list (APPEND ORC_SYSTEM_DEPENDENCIES Protobuf)
-  list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:protobuf::libprotobuf>")
-  orc_provide_find_module (Protobuf)
-else ()
-  set(PROTOBUF_PREFIX "${THIRDPARTY_DIR}/protobuf_ep-install")
-  set(PROTOBUF_INCLUDE_DIR "${PROTOBUF_PREFIX}/include")
-  set(PROTOBUF_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PROTOBUF_PREFIX}
-                          -DCMAKE_INSTALL_LIBDIR=lib
-                          -DCMAKE_POLICY_VERSION_MINIMUM=3.12
-                          -DBUILD_SHARED_LIBS=OFF
-                          -Dprotobuf_BUILD_TESTS=OFF)
-
-  if (BUILD_POSITION_INDEPENDENT_LIB)
-    set(PROTOBUF_CMAKE_ARGS ${PROTOBUF_CMAKE_ARGS} 
-DCMAKE_POSITION_INDEPENDENT_CODE=ON)
-  endif ()
+    block()
+      prepare_fetchcontent()
+      fetchcontent_declare(GTest
+        URL 
"https://github.com/google/googletest/archive/refs/tags/v${GTEST_VERSION}.tar.gz";
+        FIND_PACKAGE_ARGS
+        NAMES GTest
+        CONFIG
+        )
+      fetchcontent_makeavailable(GTest)
+
+      if(gtest_SOURCE_DIR)
+        message(STATUS "Using vendored GTest")
+        if(NOT TARGET GTest::gtest)
+          add_library(GTest::gtest ALIAS gtest)
+        endif()
+        if(NOT TARGET GTest::gmock)
+          add_library(GTest::gmock ALIAS gmock)
+        endif()
+        if(BUILD_POSITION_INDEPENDENT_LIB)
+          set_target_properties(gtest PROPERTIES POSITION_INDEPENDENT_CODE ON)
+          set_target_properties(gmock PROPERTIES POSITION_INDEPENDENT_CODE ON)
+        endif()
+      else()
+        message(STATUS "Using system GTest")
+      endif()
 
-  if (MSVC)
-    set(PROTOBUF_STATIC_LIB_PREFIX lib)
-    list(APPEND PROTOBUF_CMAKE_ARGS -Dprotobuf_MSVC_STATIC_RUNTIME=OFF
-                                    -Dprotobuf_DEBUG_POSTFIX=)
-  else ()
-    set(PROTOBUF_STATIC_LIB_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX})
+      target_link_libraries (orc_gmock INTERFACE GTest::gmock)
+      target_link_libraries (orc_gtest INTERFACE GTest::gtest)
+    endblock()
   endif ()
-  set(PROTOBUF_STATIC_LIB_NAME 
"${PROTOBUF_STATIC_LIB_PREFIX}protobuf${CMAKE_STATIC_LIBRARY_SUFFIX}")
-  set(PROTOBUF_STATIC_LIB "${PROTOBUF_PREFIX}/lib/${PROTOBUF_STATIC_LIB_NAME}")
-  set(PROTOC_STATIC_LIB 
"${PROTOBUF_PREFIX}/lib/${PROTOBUF_STATIC_LIB_PREFIX}protoc${CMAKE_STATIC_LIBRARY_SUFFIX}")
-  set(PROTOBUF_EXECUTABLE 
"${PROTOBUF_PREFIX}/bin/protoc${CMAKE_EXECUTABLE_SUFFIX}")
-
-  set(PROTOBUF_CONFIGURE SOURCE_SUBDIR "cmake" CMAKE_ARGS 
${PROTOBUF_CMAKE_ARGS})
-
-  ExternalProject_Add(protobuf_ep
-    URL 
"https://github.com/google/protobuf/archive/v${PROTOBUF_VERSION}.tar.gz";
-    ${PROTOBUF_CONFIGURE}
-    ${THIRDPARTY_LOG_OPTIONS}
-    BUILD_BYPRODUCTS "${PROTOBUF_STATIC_LIB}" "${PROTOC_STATIC_LIB}")
-
-  orc_add_built_library (protobuf_ep orc_protobuf ${PROTOBUF_STATIC_LIB} 
${PROTOBUF_INCLUDE_DIR})
-  orc_add_built_library (protobuf_ep orc_protoc ${PROTOC_STATIC_LIB} 
${PROTOBUF_INCLUDE_DIR})
-
-  list (APPEND ORC_VENDOR_DEPENDENCIES 
"orc::vendored_protobuf|${PROTOBUF_STATIC_LIB_NAME}")
-  list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:orc::vendored_protobuf>")
-endif ()
-
-add_library (orc::protobuf ALIAS orc_protobuf)
-if (NOT (ORC_PACKAGE_KIND STREQUAL "conan" OR ORC_PACKAGE_KIND STREQUAL 
"vcpkg"))
-  add_library (orc::protoc ALIAS orc_protoc)
 endif ()
 
 # ----------------------------------------------------------------------
 # SPARSEHASH
 if(BUILD_SPARSEHASH)
-  set(SPARSEHASH_HOME "${THIRDPARTY_DIR}/sparsehash_ep-install")
-  set(SPARSEHASH_INCLUDE_DIR "${SPARSEHASH_HOME}/include/google")
-  set(SPARSEHASH_CMAKE_ARGS
-      -DCMAKE_INSTALL_PREFIX=${SPARSEHASH_HOME}
-      -DBUILD_SHARED_LIBS=OFF
-      -DCMAKE_INSTALL_LIBDIR=lib
-      -DCMAKE_POLICY_VERSION_MINIMUM=3.5
-  )
-  if (BUILD_POSITION_INDEPENDENT_LIB)
-    set(SPARSEHASH_CMAKE_ARGS ${SPARSEHASH_CMAKE_ARGS} 
-DCMAKE_POSITION_INDEPENDENT_CODE=ON)
-  endif ()
-
-  set(SPARSEHASH_CONFIGURE SOURCE_SUBDIR "" CMAKE_ARGS 
${SPARSEHASH_CMAKE_ARGS})
+  block()
+    prepare_fetchcontent()
 
-  ExternalProject_Add(sparsehash_ep
+    fetchcontent_declare(sparsehash
       URL 
"https://github.com/sparsehash/sparsehash-c11/archive/refs/tags/v${SPARSEHASH_VERSION}.tar.gz";
-      ${SPARSEHASH_CONFIGURE}
-      ${THIRDPARTY_LOG_OPTIONS})
-
-  # sparsehash-c11 is header-only, create interface library
-  add_library(orc_sparsehash INTERFACE)
-  target_include_directories(orc_sparsehash INTERFACE 
-      $<BUILD_INTERFACE:${SPARSEHASH_INCLUDE_DIR}>
-      $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
-  add_dependencies(orc_sparsehash sparsehash_ep)
-
-  list (APPEND ORC_VENDOR_DEPENDENCIES "orc::vendored_sparsehash")
-  list (APPEND ORC_INSTALL_INTERFACE_TARGETS 
"$<INSTALL_INTERFACE:orc::vendored_sparsehash>")
-
-  add_library (orc::sparsehash ALIAS orc_sparsehash)
-  set (SPARSEHASH_LIBRARIES orc::sparsehash)
+      SOURCE_SUBDIR "sparsehash" # XXX: sparsehash bundles gtest which 
conflicts with our vendored one
+      )
+    fetchcontent_makeavailable(sparsehash)
+    message(STATUS "Using vendored sparsehash")
+
+    # sparsehash-c11 is header-only
+    add_library(orc_sparsehash INTERFACE)
+    add_library(orc::sparsehash ALIAS orc_sparsehash)
+    target_include_directories(orc_sparsehash INTERFACE 
$<BUILD_INTERFACE:${sparsehash_SOURCE_DIR}>)
+  endblock()
 endif()
 
 # ----------------------------------------------------------------------
diff --git a/conan/all/conandata.yml b/conan/all/conandata.yml
index f51fba463..e2076c59c 100644
--- a/conan/all/conandata.yml
+++ b/conan/all/conandata.yml
@@ -16,15 +16,18 @@
 # under the License.
 
 sources:
+  "2.2.1":
+    url: "https://archive.apache.org/dist/orc/orc-2.2.1/orc-2.2.1.tar.gz";
+    sha256: "52fc762332442e8b05d7182f8c035f9e04d945b9a52be22ab69f28b3f37d4500"
+  "2.1.1":
+    url: "https://archive.apache.org/dist/orc/orc-2.1.1/orc-2.1.1.tar.gz";
+    sha256: "15af8baeee322bab0298559a14a09cf8c14cf2008e35d8a78d3cc8a4c98d1e59"
+  "2.0.3":
+    url: "https://archive.apache.org/dist/orc/orc-2.0.3/orc-2.0.3.tar.gz";
+    sha256: "082cba862b5a8a0d14c225404d0b51cd8d1b64ca81b8f1e500322ce8922cb86d"
   "2.0.0":
-    url: "https://dlcdn.apache.org/orc/orc-2.0.0/orc-2.0.0.tar.gz";
+    url: "https://archive.apache.org/dist/orc/orc-2.0.0/orc-2.0.0.tar.gz";
     sha256: "9107730919c29eb39efaff1b9e36166634d1d4d9477e5fee76bfd6a8fec317df"
-  "1.9.2":
-    url: "https://dlcdn.apache.org/orc/orc-1.9.2/orc-1.9.2.tar.gz";
-    sha256: "7f46f2c184ecefd6791f1a53fb062286818bd8710c3f08b94dd3cac365e240ee"
-  "1.8.6":
-    url: "https://dlcdn.apache.org/orc/orc-1.8.6/orc-1.8.6.tar.gz";
-    sha256: "5675b18118df4dd7f86cc6ba859ed75b425ea1b7ddff805e1d671a17fd57d7f7"
-  "1.7.10":
-    url: "https://dlcdn.apache.org/orc/orc-1.7.10/orc-1.7.10.tar.gz";
-    sha256: "85aef9368dc9bcdffaaf10010b66dfe053ce22f30b64854f63852248164686a3"
+  "1.9.5":
+    url: "https://archive.apache.org/dist/orc/orc-1.9.5/orc-1.9.5.tar.gz";
+    sha256: "6900b4e8a2e4e49275f4067bd0f838ad68330204305fd3f13a5ec519e9d71547"
diff --git a/conan/all/conanfile.py b/conan/all/conanfile.py
index 9e45cd46d..cc79f5b0d 100644
--- a/conan/all/conanfile.py
+++ b/conan/all/conanfile.py
@@ -18,14 +18,13 @@
 import os
 
 from conan import ConanFile
-from conan.errors import ConanInvalidConfiguration
 from conan.tools.build import check_min_cppstd
 from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
 from conan.tools.env import VirtualBuildEnv, VirtualRunEnv
 from conan.tools.files import copy, get, rmdir, replace_in_file, mkdir
 from conan.tools.scm import Version
 
-required_conan_version = ">=1.60.0 <2.0 || >=2.0.5"
+required_conan_version = ">=2.1"
 
 class OrcRecipe(ConanFile):
     name = "orc"
@@ -50,27 +49,9 @@ class OrcRecipe(ConanFile):
         "build_avx512": True,
     }
 
-    @property
-    def _min_cppstd(self):
-        return 17
-
-    @property
-    def _compilers_minimum_version(self):
-        return {
-            "Visual Studio": "16",
-            "msvc": "192",
-            "gcc": "8",
-            "clang": "7",
-            "apple-clang": "12",
-        }
-
-    @property
-    def _is_legacy_one_profile(self):
-        return not hasattr(self, "settings_build")
-
     @property
     def _should_patch_thirdparty_toolchain(self):
-        return self.version < "2.0.0"
+        return Version(self.version) < "2.0.0"
 
     def export_sources(self):
         if self._should_patch_thirdparty_toolchain:
@@ -96,20 +77,13 @@ class OrcRecipe(ConanFile):
         self.requires("lz4/1.9.4")
         self.requires("snappy/1.1.9")
         self.requires("zlib/[>=1.2.11 <2]")
-        self.requires("zstd/1.5.5")
+        self.requires("zstd/[~1.5]")
 
     def validate(self):
-        if self.settings.compiler.cppstd:
-            check_min_cppstd(self, self._min_cppstd)
-        minimum_version = 
self._compilers_minimum_version.get(str(self.settings.compiler), False)
-        if minimum_version and Version(self.settings.compiler.version) < 
minimum_version:
-            raise ConanInvalidConfiguration(
-                f"{self.ref} requires C++{self._min_cppstd}, which your 
compiler does not support."
-            )
+        check_min_cppstd(self, 17)
 
     def build_requirements(self):
-        if not self._is_legacy_one_profile:
-            self.tool_requires("protobuf/<host_version>")
+        self.tool_requires("protobuf/<host_version>")
 
     def source(self):
         # START
@@ -133,13 +107,15 @@ class OrcRecipe(ConanFile):
             return
         # END
         get(self, **self.conan_data["sources"][self.version], strip_root=True)
+        self._patch_sources()
 
     def generate(self):
         VirtualBuildEnv(self).generate()
         VirtualRunEnv(self).generate(scope="build")
 
         tc = CMakeToolchain(self)
-        tc.variables["ORC_PACKAGE_KIND"] = "conan"
+        if Version(self.version) < "2.3.0":
+            tc.variables["ORC_PACKAGE_KIND"] = "conan"
         tc.variables["BUILD_JAVA"] = False
         tc.variables["BUILD_CPP_TESTS"] = False
         tc.variables["BUILD_TOOLS"] = self.options.build_tools
@@ -151,11 +127,6 @@ class OrcRecipe(ConanFile):
         tc.variables["STOP_BUILD_ON_WARNING"] = False
         tc.variables["CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = True
 
-        # CMake versions less than 3.12 are supported by ORC pre-1.9.0 
versions.
-        # Setting policy CMP0077 to NEW to remove unnecessary cache_variables 
settings.
-        if self.version < "1.9.0":
-            tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW"
-
         protoc_path = 
os.path.join(self.dependencies["protobuf"].cpp_info.bindir, "protoc")
         tc.variables["PROTOBUF_EXECUTABLE"] = protoc_path.replace("\\", "/")
         tc.variables["HAS_POST_2038"] = self.settings.os != "Windows"
@@ -174,7 +145,6 @@ class OrcRecipe(ConanFile):
                         "add_library (orc STATIC ${SOURCE_FILES})", 
"add_library (orc ${SOURCE_FILES})")
 
     def build(self):
-        self._patch_sources()
         cmake = CMake(self)
         cmake.configure()
         cmake.build()
@@ -185,7 +155,8 @@ class OrcRecipe(ConanFile):
         cmake = CMake(self)
         cmake.install()
         rmdir(self, os.path.join(self.package_folder, "share"))
-        if self.settings.os == "Windows" and self.options.shared:
+        rmdir(self, os.path.join(self.package_folder, "lib", "cmake"))
+        if self.settings.os == "Windows" and self.options.shared and 
Version(self.version) < "2.1.1":
             mkdir(self, os.path.join(self.package_folder, "bin"))
             os.rename(os.path.join(self.package_folder, "lib", "orc.dll"),
                       os.path.join(self.package_folder, "bin", "orc.dll"))
diff --git a/conan/config.yml b/conan/config.yml
index f95e56839..bfa64b36f 100644
--- a/conan/config.yml
+++ b/conan/config.yml
@@ -16,11 +16,13 @@
 # under the License.
 
 versions:
-  "2.0.0":
+  "2.2.1":
+    folder: all
+  "2.1.1":
     folder: all
-  "1.9.2":
+  "2.0.3":
     folder: all
-  "1.8.6":
+  "2.0.0":
     folder: all
-  "1.7.10":
+  "1.9.5":
     folder: all
diff --git a/tools/test/CMakeLists.txt b/tools/test/CMakeLists.txt
index 202ddb2e0..ae407d2ff 100644
--- a/tools/test/CMakeLists.txt
+++ b/tools/test/CMakeLists.txt
@@ -28,9 +28,6 @@ add_executable (tool-test
 
 target_link_libraries (tool-test
   orc
-  orc::protobuf
-  orc::zlib
-  orc::snappy
   orc::gtest
   orc::gmock
 )

Reply via email to