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

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


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

commit 23084a4527c8e5d7336813eaf6f6cbc54bd562e5
Author: Ben Givertz <[email protected]>
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 <[email protected]>
---
 CMakeLists.txt                          |  8 ++++++++
 cmake_modules/ThirdpartyToolchain.cmake | 29 +++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 45aba03..fce4812 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,6 +55,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)
@@ -72,6 +76,10 @@ SET(CPACK_PACKAGE_CONTACT "Apache ORC <[email protected]>")
 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 9903289..2b28816 100644
--- a/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cmake_modules/ThirdpartyToolchain.cmake
@@ -76,6 +76,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}
@@ -124,6 +128,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}
@@ -172,6 +180,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()
@@ -220,6 +232,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()
@@ -291,6 +307,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}
@@ -341,6 +361,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
@@ -426,6 +451,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 orc::protobuf
         URL ${LIBHDFSPP_SRC_URL}

Reply via email to