diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index 501c541e175..052e9732994 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -555,7 +555,7 @@ if(ARROW_WITH_URIPARSER) list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS uriparser::uriparser) endif() -if(PARQUET_BUILD_ENCRYPTION) +if(ARROW_USE_OPENSSL) list(APPEND ARROW_LINK_LIBS OpenSSL::Crypto) list(APPEND ARROW_STATIC_LINK_LIBS OpenSSL::Crypto) list(APPEND ARROW_STATIC_INSTALL_INTERFACE_LIBS OpenSSL::Crypto) diff --git a/cpp/cmake_modules/DefineOptions.cmake b/cpp/cmake_modules/DefineOptions.cmake index d041da5ac40..99b0047b86c 100644 --- a/cpp/cmake_modules/DefineOptions.cmake +++ b/cpp/cmake_modules/DefineOptions.cmake @@ -275,8 +275,6 @@ Note that this requires linking Boost statically" OFF) #---------------------------------------------------------------------- set_option_category("Parquet") - define_option(PARQUET_BUILD_ENCRYPTION "Build Parquet with encryption support" ON) - define_option(PARQUET_MINIMAL_DEPENDENCY "Depend only on Thirdparty headers to build libparquet. \ Always OFF if building binaries" OFF) @@ -288,6 +286,8 @@ Always OFF if building binaries" OFF) define_option(PARQUET_BUILD_EXAMPLES "Build the Parquet examples. Requires static libraries to be built." OFF) + define_option(PARQUET_REQUIRE_ENCRYPTION "Fail if OpenSSL is not found" OFF) + #---------------------------------------------------------------------- set_option_category("Gandiva") diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 258ba01cc11..4647fcd4026 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -731,8 +731,24 @@ if(ARROW_WITH_BROTLI) include_directories(SYSTEM ${BROTLI_INCLUDE_DIR}) endif() -if(PARQUET_BUILD_ENCRYPTION OR ARROW_WITH_GRPC) +set(ARROW_USE_OPENSSL OFF) +if(PARQUET_REQUIRE_ENCRYPTION AND NOT ARROW_PARQUET) + set(PARQUET_REQUIRE_ENCRYPTION OFF) +endif() +if(PARQUET_REQUIRE_ENCRYPTION OR ARROW_FLIGHT) + # This must work find_package(OpenSSL REQUIRED) + set(ARROW_USE_OPENSSL ON) +elseif(ARROW_PARQUET) + # Enable Parquet encryption if OpenSSL is there, but don't fail if it's not + find_package(OpenSSL QUIET) + if(OPENSSL_FOUND) + set(ARROW_USE_OPENSSL ON) + endif() +endif() + +if(ARROW_USE_OPENSSL) + message(STATUS "Building with OpenSSL support") # OpenSSL::SSL and OpenSSL::Crypto # are not available in older CMake versions (CMake < v3.2). if(NOT TARGET OpenSSL::SSL) @@ -750,6 +766,8 @@ if(PARQUET_BUILD_ENCRYPTION OR ARROW_WITH_GRPC) endif() include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR}) +else() + message(STATUS "Building without OpenSSL support") endif() # ----------------------------------------------------------------------