You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by om...@apache.org on 2021/03/23 19:43:37 UTC

[orc] branch branch-1.6 updated: ORC-765: Add support for PIC option in C++.

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

omalley pushed a commit to branch branch-1.6
in repository https://gitbox.apache.org/repos/asf/orc.git


The following commit(s) were added to refs/heads/branch-1.6 by this push:
     new b0847b5  ORC-765: Add support for PIC option in C++.
b0847b5 is described below

commit b0847b50cef3ac36bcf92f2abe00f59e43b35a19
Author: Ben Givertz <bg...@gmail.com>
AuthorDate: Thu Mar 18 16:54:29 2021 -0400

    ORC-765: Add support for PIC option in C++.
    
    Fixes #657
    
    Signed-off-by: Owen O'Malley <oo...@linkedin.com>
---
 CMakeLists.txt                          |  8 ++++++++
 cmake_modules/ThirdpartyToolchain.cmake | 29 +++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index d12ac04..7bfc35f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,6 +52,10 @@ option(INSTALL_VENDORED_LIBS
 option(STOP_BUILD_ON_WARNING
     "Fail the build on C++ warnings"
     ON)
+  
+option(BUILD_POSITION_INDEPENDENT_LIB
+    "Compile static libraries with position independent code"
+    OFF)
 
 # Make sure that a build type is selected
 if (NOT CMAKE_BUILD_TYPE)
@@ -69,6 +73,10 @@ SET(CPACK_PACKAGE_CONTACT "Apache ORC <de...@orc.apache.org>")
 INCLUDE(CPack)
 INCLUDE(ExternalProject)
 
+if (BUILD_POSITION_INDEPENDENT_LIB)
+  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+endif ()
+
 #
 # Compiler specific flags
 #
diff --git a/cmake_modules/ThirdpartyToolchain.cmake b/cmake_modules/ThirdpartyToolchain.cmake
index 8e7affd..fc4409c 100644
--- a/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cmake_modules/ThirdpartyToolchain.cmake
@@ -69,6 +69,10 @@ else ()
   set(SNAPPY_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${SNAPPY_HOME}
                         -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_LIBDIR=lib)
 
+  if (BUILD_POSITION_INDEPENDENT_LIB)
+    set(SNAPPY_CMAKE_ARGS ${SNAPPY_CMAKE_ARGS} -DCMAKE_POSITION_INDEPENDENT_CODE=ON)
+  endif ()
+
   ExternalProject_Add (snappy_ep
     URL "https://github.com/google/snappy/archive/${SNAPPY_VERSION}.tar.gz"
     CMAKE_ARGS ${SNAPPY_CMAKE_ARGS}
@@ -111,6 +115,10 @@ else ()
   set(ZLIB_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${ZLIB_PREFIX}
                       -DBUILD_SHARED_LIBS=OFF)
 
+  if (BUILD_POSITION_INDEPENDENT_LIB)
+    set(ZLIB_CMAKE_ARGS ${ZLIB_CMAKE_ARGS} -DCMAKE_POSITION_INDEPENDENT_CODE=ON)
+  endif ()
+
   ExternalProject_Add (zlib_ep
     URL "http://zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz"
     CMAKE_ARGS ${ZLIB_CMAKE_ARGS}
@@ -153,6 +161,10 @@ else ()
   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 ()
+
   if (CMAKE_VERSION VERSION_GREATER "3.7")
     set(ZSTD_CONFIGURE SOURCE_SUBDIR "build/cmake" CMAKE_ARGS ${ZSTD_CMAKE_ARGS})
   else()
@@ -195,6 +207,10 @@ else ()
                      -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 ()
+
   if (CMAKE_VERSION VERSION_GREATER "3.7")
     set(LZ4_CONFIGURE SOURCE_SUBDIR "contrib/cmake_unofficial" CMAKE_ARGS ${LZ4_CMAKE_ARGS})
   else()
@@ -260,6 +276,10 @@ if (BUILD_CPP_TESTS)
                          -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}
@@ -298,6 +318,11 @@ else ()
                           -DCMAKE_INSTALL_LIBDIR=lib
                           -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 ()
+
   if (MSVC)
     set(PROTOBUF_STATIC_LIB_PREFIX lib)
     list(APPEND PROTOBUF_CMAKE_ARGS -Dprotobuf_MSVC_STATIC_RUNTIME=OFF
@@ -370,6 +395,10 @@ if(BUILD_LIBHDFSPP)
                                 -DHDFSPP_LIBRARY_ONLY=TRUE
                                 -DBUILD_SHARED_HDFSPP=FALSE)
 
+      if (BUILD_POSITION_INDEPENDENT_LIB)
+        set(LIBHDFSPP_CMAKE_ARGS ${LIBHDFSPP_CMAKE_ARGS} -DCMAKE_POSITION_INDEPENDENT_CODE=ON)
+      endif ()
+
       ExternalProject_Add (libhdfspp_ep
         DEPENDS protobuf
         URL ${LIBHDFSPP_SRC_URL}