diff --git a/cpp/cmake_modules/FindThrift.cmake b/cpp/cmake_modules/FindThriftAlt.cmake similarity index 91% rename from cpp/cmake_modules/FindThrift.cmake rename to cpp/cmake_modules/FindThriftAlt.cmake index 2f20a5cb59..e317e2c7c4 100644 --- a/cpp/cmake_modules/FindThrift.cmake +++ b/cpp/cmake_modules/FindThriftAlt.cmake @@ -28,7 +28,23 @@ # thrift::thrift, a library target to use Thrift # thrift::compiler, a executable target to use Thrift compiler +if(ThriftAlt_FOUND) + return() +endif() + +set(find_package_args "") +if(ThriftAlt_FIND_VERSION) + list(APPEND find_package_args ${ThriftAlt_FIND_VERSION}) +endif() +if(ThriftAlt_FIND_QUIETLY) + list(APPEND find_package_args QUIET) +endif() +find_package(Thrift ${find_package_args}) if(Thrift_FOUND) + set(ThriftAlt_FOUND TRUE) + add_executable(thrift::compiler IMPORTED) + set_target_properties(thrift::compiler PROPERTIES IMPORTED_LOCATION + "${THRIFT_COMPILER}") return() endif() @@ -133,12 +149,12 @@ else() endif() find_package_handle_standard_args( - Thrift + ThriftAlt REQUIRED_VARS THRIFT_LIB THRIFT_INCLUDE_DIR VERSION_VAR Thrift_VERSION HANDLE_COMPONENTS) -if(Thrift_FOUND) +if(ThriftAlt_FOUND) if(ARROW_THRIFT_USE_SHARED) add_library(thrift::thrift SHARED IMPORTED) else() diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index b7cd31f3d7..72b8cfe286 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -1510,8 +1510,10 @@ macro(build_thrift) endmacro() if(ARROW_WITH_THRIFT) - # Thrift c++ code generated by 0.13 requires 0.11 or greater + # Thrift C++ code generated by 0.13 requires 0.11 or greater resolve_dependency(Thrift + HAVE_ALT + TRUE REQUIRED_VERSION 0.11.0 PC_PACKAGE_NAMES