From c91bacdc4875cc403d8a410e44d71730574032e9 Mon Sep 17 00:00:00 2001 From: Neal Richardson Date: Thu, 6 Jun 2019 15:10:15 -0700 Subject: [PATCH 1/5] Turn off PARQUET_BUILD_ENCRYPTION in CMake if OpenSSL not found --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 258ba01cc11..e6901779006 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -15,6 +15,8 @@ # specific language governing permissions and limitations # under the License. +include(CMakeDependentOption) + add_custom_target(rapidjson) add_custom_target(toolchain) add_custom_target(toolchain-benchmarks) @@ -731,6 +733,12 @@ if(ARROW_WITH_BROTLI) include_directories(SYSTEM ${BROTLI_INCLUDE_DIR}) endif() +if(PARQUET_BUILD_ENCRYPTION) + find_package(OpenSSL QUIET) + CMAKE_DEPENDENT_OPTION(PARQUET_BUILD_ENCRYPTION "Build with OpenSSL support" ON + "OPENSSL_FOUND" OFF) +endif() + if(PARQUET_BUILD_ENCRYPTION OR ARROW_WITH_GRPC) find_package(OpenSSL REQUIRED) # OpenSSL::SSL and OpenSSL::Crypto From b0f9ee56f37f786eef6b76588843a7706575ffc5 Mon Sep 17 00:00:00 2001 From: Neal Richardson Date: Fri, 7 Jun 2019 13:26:57 -0700 Subject: [PATCH 2/5] Refactor the OpenSSL CMake logic --- cpp/CMakeLists.txt | 2 +- cpp/cmake_modules/DefineOptions.cmake | 4 ++-- cpp/cmake_modules/ThirdpartyToolchain.cmake | 17 +++++++++++++---- 3 files changed, 16 insertions(+), 7 deletions(-) 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..93e64f479fa 100644 --- a/cpp/cmake_modules/DefineOptions.cmake +++ b/cpp/cmake_modules/DefineOptions.cmake @@ -233,6 +233,8 @@ Note that this requires linking Boost statically" OFF) define_option(ARROW_WITH_ZLIB "Build with zlib compression" ON) + define_option(ARROW_REQUIRE_ENCRYPTION "Fail if OpenSSL is not found" OFF) + if(CMAKE_VERSION VERSION_LESS 3.7) set(ARROW_WITH_ZSTD_DEFAULT OFF) else() @@ -275,8 +277,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) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index e6901779006..4fa4081f9bc 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -181,6 +181,7 @@ else() endif() if(ARROW_FLIGHT) + set(ARROW_REQUIRE_ENCRYPTION ON) set(ARROW_WITH_GRPC ON) set(ARROW_WITH_URIPARSER ON) endif() @@ -733,14 +734,20 @@ if(ARROW_WITH_BROTLI) include_directories(SYSTEM ${BROTLI_INCLUDE_DIR}) endif() -if(PARQUET_BUILD_ENCRYPTION) +set(ARROW_USE_OPENSSL OFF) +if(ARROW_REQUIRE_ENCRYPTION) + # 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) - CMAKE_DEPENDENT_OPTION(PARQUET_BUILD_ENCRYPTION "Build with OpenSSL support" ON + CMAKE_DEPENDENT_OPTION(ARROW_USE_OPENSSL "Build with OpenSSL support" ON "OPENSSL_FOUND" OFF) endif() -if(PARQUET_BUILD_ENCRYPTION OR ARROW_WITH_GRPC) - find_package(OpenSSL REQUIRED) +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) @@ -758,6 +765,8 @@ if(PARQUET_BUILD_ENCRYPTION OR ARROW_WITH_GRPC) endif() include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR}) +else() + message(STATUS "Building without OpenSSL support") endif() # ---------------------------------------------------------------------- From c1fc96eb458c45f7b0b49359658edae3b3d1d123 Mon Sep 17 00:00:00 2001 From: Neal Richardson Date: Thu, 13 Jun 2019 15:33:10 -0700 Subject: [PATCH 3/5] Refactor --- cpp/cmake_modules/DefineOptions.cmake | 4 ++-- cpp/cmake_modules/ThirdpartyToolchain.cmake | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cpp/cmake_modules/DefineOptions.cmake b/cpp/cmake_modules/DefineOptions.cmake index 93e64f479fa..99b0047b86c 100644 --- a/cpp/cmake_modules/DefineOptions.cmake +++ b/cpp/cmake_modules/DefineOptions.cmake @@ -233,8 +233,6 @@ Note that this requires linking Boost statically" OFF) define_option(ARROW_WITH_ZLIB "Build with zlib compression" ON) - define_option(ARROW_REQUIRE_ENCRYPTION "Fail if OpenSSL is not found" OFF) - if(CMAKE_VERSION VERSION_LESS 3.7) set(ARROW_WITH_ZSTD_DEFAULT OFF) else() @@ -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 4fa4081f9bc..7326625fab6 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -15,8 +15,6 @@ # specific language governing permissions and limitations # under the License. -include(CMakeDependentOption) - add_custom_target(rapidjson) add_custom_target(toolchain) add_custom_target(toolchain-benchmarks) @@ -181,7 +179,6 @@ else() endif() if(ARROW_FLIGHT) - set(ARROW_REQUIRE_ENCRYPTION ON) set(ARROW_WITH_GRPC ON) set(ARROW_WITH_URIPARSER ON) endif() @@ -735,15 +732,19 @@ if(ARROW_WITH_BROTLI) endif() set(ARROW_USE_OPENSSL OFF) -if(ARROW_REQUIRE_ENCRYPTION) +if (PARQUET_BUILD_ENCRYPTION AND NOT ARROW_PARQUET) + set(PARQUET_BUILD_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) - CMAKE_DEPENDENT_OPTION(ARROW_USE_OPENSSL "Build with OpenSSL support" ON - "OPENSSL_FOUND" OFF) + if(OPENSSL_FOUND) + set(ARROW_USE_OPENSSL ON) + endif() endif() if(ARROW_USE_OPENSSL) From 4817a8531d3818c6e33ae1cb6807f12ffc2fa14b Mon Sep 17 00:00:00 2001 From: Neal Richardson Date: Thu, 13 Jun 2019 15:36:04 -0700 Subject: [PATCH 4/5] Fix copypasta --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index 7326625fab6..b9c0d18d6fb 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -732,8 +732,8 @@ if(ARROW_WITH_BROTLI) endif() set(ARROW_USE_OPENSSL OFF) -if (PARQUET_BUILD_ENCRYPTION AND NOT ARROW_PARQUET) - set(PARQUET_BUILD_ENCRYPTION 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 From d2791239d0b54524e464ac75a49aec0e50e12bae Mon Sep 17 00:00:00 2001 From: Neal Richardson Date: Fri, 14 Jun 2019 15:49:46 -0700 Subject: [PATCH 5/5] Lint --- cpp/cmake_modules/ThirdpartyToolchain.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake index b9c0d18d6fb..4647fcd4026 100644 --- a/cpp/cmake_modules/ThirdpartyToolchain.cmake +++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake @@ -732,7 +732,7 @@ if(ARROW_WITH_BROTLI) endif() set(ARROW_USE_OPENSSL OFF) -if (PARQUET_REQUIRE_ENCRYPTION AND NOT ARROW_PARQUET) +if(PARQUET_REQUIRE_ENCRYPTION AND NOT ARROW_PARQUET) set(PARQUET_REQUIRE_ENCRYPTION OFF) endif() if(PARQUET_REQUIRE_ENCRYPTION OR ARROW_FLIGHT)