You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@parquet.apache.org by we...@apache.org on 2016/06/03 07:25:56 UTC

parquet-cpp git commit: PARQUET-615: Allow building static and shared library in parallel

Repository: parquet-cpp
Updated Branches:
  refs/heads/master 427fad9ea -> 22b4977c1


PARQUET-615: Allow building static and shared library in parallel

Author: Uwe L. Korn <uw...@xhochy.com>

Closes #112 from xhochy/parquet-615-2 and squashes the following commits:

46ab870 [Uwe L. Korn] Prefer static builds for unittests
8b1a7f1 [Uwe L. Korn] Always build with -fPIC
2e4b2d0 [Uwe L. Korn] Travis: Build statically for linux coverage reports
423e4e6 [Uwe L. Korn] PARQUET-615: Allow building static and shared library in parallel


Project: http://git-wip-us.apache.org/repos/asf/parquet-cpp/repo
Commit: http://git-wip-us.apache.org/repos/asf/parquet-cpp/commit/22b4977c
Tree: http://git-wip-us.apache.org/repos/asf/parquet-cpp/tree/22b4977c
Diff: http://git-wip-us.apache.org/repos/asf/parquet-cpp/diff/22b4977c

Branch: refs/heads/master
Commit: 22b4977c191f0b9cb9fd6e655393ec71ecbc925f
Parents: 427fad9
Author: Uwe L. Korn <uw...@xhochy.com>
Authored: Fri Jun 3 00:25:50 2016 -0700
Committer: Wes McKinney <we...@apache.org>
Committed: Fri Jun 3 00:25:50 2016 -0700

----------------------------------------------------------------------
 .travis.yml            |  2 +-
 CMakeLists.txt         | 91 ++++++++++++++++++++++++++++-----------------
 example/CMakeLists.txt | 11 +++++-
 3 files changed, 68 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/22b4977c/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 780d9f9..e83aeba 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -26,7 +26,7 @@ matrix:
     before_script:
     - source $TRAVIS_BUILD_DIR/ci/before_script_travis.sh
     - cmake -DCMAKE_CXX_FLAGS="-Werror" -DPARQUET_TEST_MEMCHECK=ON -DPARQUET_BUILD_BENCHMARKS=ON
-      -DPARQUET_GENERATE_COVERAGE=1 $TRAVIS_BUILD_DIR
+      -DPARQUET_GENERATE_COVERAGE=1 $TRAVIS_BUILD_DIR -DPARQUET_BUILD_SHARED=OFF -DPARQUET_BUILD_STATIC=ON
     - export PARQUET_TEST_DATA=$TRAVIS_BUILD_DIR/data
   - compiler: clang
     os: linux

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/22b4977c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 181828a..b878612 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -50,16 +50,12 @@ if(APPLE)
   set(CMAKE_MACOSX_RPATH 1)
 endif()
 
-if (NOT PARQUET_LINK)
-  set(PARQUET_LINK "a")
-elseif(NOT ("auto" MATCHES "^${PARQUET_LINK}" OR
-            "dynamic" MATCHES "^${PARQUET_LINK}" OR
-            "static" MATCHES "^${PARQUET_LINK}"))
-  message(FATAL_ERROR "Unknown value for PARQUET_LINK, must be auto|dynamic|static")
-else()
-  # Remove all but the first letter.
-  string(SUBSTRING "${PARQUET_LINK}" 0 1 PARQUET_LINK)
-endif()
+option(PARQUET_BUILD_SHARED
+    "Build the shared version of libparquet"
+    ON)
+option(PARQUET_BUILD_STATIC
+    "Build the static version of libparquet"
+    OFF)
 
 # if no build build type is specified, default to debug builds
 if (NOT CMAKE_BUILD_TYPE)
@@ -397,15 +393,29 @@ endif()
 #############################################################
 # Test linking
 
-set(PARQUET_MIN_TEST_LIBS
-  parquet_test_main
-  parquet)
+if (PARQUET_BUILD_STATIC)
+    set(PARQUET_MIN_TEST_LIBS
+      parquet_test_main
+      parquet_static)
+else()
+    set(PARQUET_MIN_TEST_LIBS
+      parquet_test_main
+      parquet_shared)
+endif()
 set(PARQUET_TEST_LINK_LIBS ${PARQUET_MIN_TEST_LIBS})
 
 #############################################################
 # Benchmark linking
 
-set(PARQUET_BENCHMARK_LINK_LIBS parquet parquet_benchmark_main)
+if (PARQUET_BUILD_STATIC)
+    set(PARQUET_BENCHMARK_LINK_LIBS
+      parquet_benchmark_main
+      parquet_static)
+else()
+    set(PARQUET_BENCHMARK_LINK_LIBS
+      parquet_benchmark_main
+      parquet_shared)
+endif()
 
 #############################################################
 # Code coverage
@@ -423,10 +433,7 @@ if ("${PARQUET_GENERATE_COVERAGE}")
   # For coverage to work properly, we need to use static linkage. Otherwise,
   # __gcov_flush() doesn't properly flush coverage from every module.
   # See http://stackoverflow.com/questions/28164543/using-gcov-flush-within-a-library-doesnt-force-the-other-modules-to-yield-gc
-  if("${PARQUET_LINK}" STREQUAL "a")
-    message("Using static linking for coverage build")
-    set(PARQUET_LINK "s")
-  elseif("${PARQUET_LINK}" STREQUAL "d")
+  if(NOT PARQUET_BUILD_STATIC)
     message(SEND_ERROR "Cannot use coverage with dynamic linking")
   endif()
 endif()
@@ -459,23 +466,32 @@ set(LIBPARQUET_LINK_LIBS
   thriftstatic
 )
 
-if ("${PARQUET_LINK}" STREQUAL "d" OR "${PARQUET_LINK}" STREQUAL "a")
-  set(LIBPARQUET_LINKAGE "SHARED")
-else()
-  set(LIBPARQUET_LINKAGE "STATIC")
-endif()
-
-add_library(parquet
+add_library(parquet_objlib OBJECT
   ${LIBPARQUET_LINKAGE}
   ${LIBPARQUET_SRCS}
 )
-set_target_properties(parquet
-  PROPERTIES
-  LIBRARY_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}")
-target_link_libraries(parquet ${LIBPARQUET_LINK_LIBS})
 
-if(APPLE)
-    set_target_properties(parquet PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
+set_property(TARGET parquet_objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
+
+if (PARQUET_BUILD_SHARED)
+    add_library(parquet_shared SHARED $<TARGET_OBJECTS:parquet_objlib>)
+    if(APPLE)
+        set_target_properties(parquet_shared PROPERTIES LINK_FLAGS "-undefined dynamic_lookup")
+    endif()
+    set_target_properties(parquet_shared
+      PROPERTIES
+      LIBRARY_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}"
+      OUTPUT_NAME "parquet")
+    target_link_libraries(parquet_shared ${LIBPARQUET_LINK_LIBS})
+endif()
+
+if (PARQUET_BUILD_STATIC)
+    add_library(parquet_static STATIC $<TARGET_OBJECTS:parquet_objlib>)
+    set_target_properties(parquet_static
+      PROPERTIES
+      LIBRARY_OUTPUT_DIRECTORY "${BUILD_OUTPUT_ROOT_DIRECTORY}"
+      OUTPUT_NAME "parquet")
+    target_link_libraries(parquet_static ${LIBPARQUET_LINK_LIBS})
 endif()
 
 add_subdirectory(src/parquet)
@@ -497,6 +513,13 @@ add_custom_target(clean-all
 
 # installation
 
-install(TARGETS parquet
-  ARCHIVE DESTINATION lib
-  LIBRARY DESTINATION lib)
+if (PARQUET_BUILD_STATIC)
+    install(TARGETS parquet_static
+      ARCHIVE DESTINATION lib
+      LIBRARY DESTINATION lib)
+endif()
+if (PARQUET_BUILD_SHARED)
+    install(TARGETS parquet_shared
+      ARCHIVE DESTINATION lib
+      LIBRARY DESTINATION lib)
+endif()

http://git-wip-us.apache.org/repos/asf/parquet-cpp/blob/22b4977c/example/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt
index 1dfb58c..4b02f81 100644
--- a/example/CMakeLists.txt
+++ b/example/CMakeLists.txt
@@ -16,10 +16,19 @@
 # under the License.
 
 SET(LINK_LIBS
-  parquet
   snappystatic
   thriftstatic)
 
+if (PARQUET_BUILD_STATIC)
+    SET(LINK_LIBS
+        ${LINK_LIBS}
+        parquet_static)
+else ()
+    SET(LINK_LIBS
+        ${LINK_LIBS}
+        parquet_shared)
+endif()
+
 if (PARQUET_BUILD_EXECUTABLES)
   add_executable(decode_benchmark decode_benchmark.cc)
   target_link_libraries(decode_benchmark ${LINK_LIBS})