Skip to content
This repository was archived by the owner on May 10, 2024. It is now read-only.

Commit 323ffe6

Browse files
Deepak Majetiwesm
Deepak Majeti
authored andcommitted
PARQUET-932: Add option to build parquet library with minimal dependency
If users want to build only the parquet library, thirdparty headers are sufficient and GTEST and GBENCHMARK are not required. Author: Deepak Majeti <deepak.majeti@hpe.com> Closes #279 from majetideepak/ParquetMinimal and squashes the following commits: cdb4135 [Deepak Majeti] correct arrow.h with api.h 100a47a [Deepak Majeti] add to README dacc908 [Deepak Majeti] add message 016d055 [Deepak Majeti] Support minimal dependency build
1 parent 3cf1eb2 commit 323ffe6

7 files changed

+63
-24
lines changed

CMakeLists.txt

+23-12
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,14 @@ if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
113113
option(PARQUET_RPATH_ORIGIN
114114
"Build Parquet libraries with RATH set to \$ORIGIN"
115115
OFF)
116+
option(PARQUET_MINIMAL_DEPENDENCY
117+
"Depend only on Thirdparty headers to build libparquet. Always OFF if building binaries"
118+
OFF)
116119
endif()
117120

118121
if (PARQUET_BUILD_TESTS OR PARQUET_BUILD_EXECUTABLES OR PARQUET_BUILD_BENCHMARKS)
119122
set(PARQUET_BUILD_STATIC ON)
123+
set(PARQUET_MINIMAL_DEPENDENCY OFF)
120124
endif()
121125

122126
# If build in-source, create the latest symlink. If build out-of-source, which is
@@ -315,6 +319,12 @@ enable_testing()
315319
# Dependencies
316320
############################################################
317321

322+
if (PARQUET_MINIMAL_DEPENDENCY)
323+
set(IGNORE_OPTIONAL_PACKAGES ON)
324+
message(STATUS "Build using minimal dependencies")
325+
else()
326+
set(IGNORE_OPTIONAL_PACKAGES OFF)
327+
endif()
318328
include(ThirdpartyToolchain)
319329

320330
# Thrift requires these definitions for some types that we use
@@ -574,16 +584,6 @@ set(BUNDLED_STATIC_LIBS
574584
zlibstatic
575585
)
576586

577-
# These are libraries that we will link privately with parquet_shared (as they
578-
# do not need to be linked transitively by other linkers), but publicly with
579-
# parquet_static (because internal users need to transitively link all
580-
# dependencies)
581-
set(LIBPARQUET_INTERFACE_LINK_LIBS
582-
${ARROW_LINK_LIBS}
583-
${BOOST_LINK_LIBS}
584-
${BUNDLED_STATIC_LIBS}
585-
)
586-
587587
add_library(parquet_objlib OBJECT
588588
${LIBPARQUET_SRCS}
589589
)
@@ -594,10 +594,21 @@ add_custom_target(thrift-deps ALL
594594
DEPENDS ${THRIFT_OUTPUT_FILES})
595595
add_dependencies(parquet_objlib thrift-deps)
596596

597+
if (NOT PARQUET_MINIMAL_DEPENDENCY)
598+
# These are libraries that we will link privately with parquet_shared (as they
599+
# do not need to be linked transitively by other linkers), but publicly with
600+
# parquet_static (because internal users need to transitively link all
601+
# dependencies)
602+
set(LIBPARQUET_INTERFACE_LINK_LIBS
603+
${ARROW_LINK_LIBS}
604+
${BOOST_LINK_LIBS}
605+
${BUNDLED_STATIC_LIBS}
606+
)
597607
# Although we don't link parquet_objlib against anything, we need it to depend
598608
# on these libs as we may generate their headers via ExternalProject_Add
599-
add_dependencies(parquet_objlib
600-
${LIBPARQUET_INTERFACE_LINK_LIBS})
609+
add_dependencies(parquet_objlib
610+
${LIBPARQUET_INTERFACE_LINK_LIBS})
611+
endif()
601612

602613
set_property(TARGET parquet_objlib PROPERTY POSITION_INDEPENDENT_CODE 1)
603614

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ To disable the testing (which requires `googletest`), pass
102102
For release-level builds (enable optimizations and disable debugging), pass
103103
`-DCMAKE_BUILD_TYPE=Release` to `cmake`.
104104

105+
To build only the library with minimal dependencies, pass
106+
`-DPARQUET_MINIMAL_DEPENDENCY=ON` to `cmake`.
107+
Note that the executables, tests, and benchmarks should be disabled as well.
108+
105109
Incremental builds can be done afterwords with just `make`.
106110

107111
## Using with Apache Arrow

cmake_modules/FindArrow.cmake

+9-3
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ find_library(ARROW_IO_LIB_PATH NAMES arrow_io
5151
${ARROW_SEARCH_LIB_PATH}
5252
NO_DEFAULT_PATH)
5353

54-
if (ARROW_INCLUDE_DIR AND ARROW_LIB_PATH)
54+
if (ARROW_INCLUDE_DIR AND (PARQUET_MINIMAL_DEPENDENCY OR ARROW_LIB_PATH))
5555
set(ARROW_FOUND TRUE)
56+
set(ARROW_HEADER_NAME arrow/api.h)
57+
set(ARROW_HEADER ${ARROW_INCLUDE_DIR}/${ARROW_HEADER_NAME})
5658
set(ARROW_LIB_NAME libarrow)
5759
set(ARROW_IO_LIB_NAME libarrow_io)
5860

@@ -63,8 +65,12 @@ if (ARROW_INCLUDE_DIR AND ARROW_LIB_PATH)
6365
set(ARROW_IO_STATIC_LIB ${ARROW_LIBS}/${ARROW_IO_LIB_NAME}.a)
6466
set(ARROW_IO_SHARED_LIB ${ARROW_LIBS}/${ARROW_IO_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
6567
if (NOT Arrow_FIND_QUIETLY)
66-
message(STATUS "Found the Arrow core library: ${ARROW_LIB_PATH}")
67-
message(STATUS "Found the Arrow IO library: ${ARROW_IO_LIB_PATH}")
68+
if (PARQUET_MINIMAL_DEPENDENCY)
69+
message(STATUS "Found the Arrow core and IO header: ${ARROW_HEADER}")
70+
else ()
71+
message(STATUS "Found the Arrow core library: ${ARROW_LIB_PATH}")
72+
message(STATUS "Found the Arrow IO library: ${ARROW_IO_LIB_PATH}")
73+
endif ()
6874
endif ()
6975
else ()
7076
if (NOT Arrow_FIND_QUIETLY)

cmake_modules/FindBrotli.cmake

+8-2
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ endif ()
6060
set(BROTLI_LIBRARIES ${BROTLI_LIBRARY_ENC} ${BROTLI_LIBRARY_DEC}
6161
${BROTLI_LIBRARY_COMMON})
6262

63-
if (BROTLI_INCLUDE_DIR AND BROTLI_LIBRARIES)
63+
if (BROTLI_INCLUDE_DIR AND (PARQUET_MINIMAL_DEPENDENCY OR BROTLI_LIBRARIES))
6464
set(BROTLI_FOUND TRUE)
6565
get_filename_component( BROTLI_LIBS ${BROTLI_LIBRARY_ENC} PATH )
66+
set(BROTLI_HEADER_NAME brotli.h)
67+
set(BROTLI_HEADER ${BROTLI_INCLUDE_DIR}/${BROTLI_HEADER_NAME})
6668
set(BROTLI_LIB_NAME libbrotli)
6769
set(BROTLI_STATIC_LIB
6870
${BROTLI_LIBS}/${BROTLI_LIB_NAME}enc.a
@@ -78,7 +80,11 @@ endif ()
7880

7981
if (BROTLI_FOUND)
8082
if (NOT Brotli_FIND_QUIETLY)
81-
message(STATUS "Found the Brotli library: ${BROTLI_LIBRARIES}")
83+
if (PARQUET_MINIMAL_DEPENDENCY)
84+
message(STATUS "Found the Brotli header: ${BROTLI_HEADER}")
85+
else ()
86+
message(STATUS "Found the Brotli library: ${BROTLI_LIBRARIES}")
87+
endif ()
8288
endif ()
8389
else ()
8490
if (NOT Brotli_FIND_QUIETLY)

cmake_modules/FindSnappy.cmake

+8-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ find_library( SNAPPY_LIBRARIES NAMES snappy PATHS
4949
NO_DEFAULT_PATH
5050
PATH_SUFFIXES "lib")
5151

52-
if (SNAPPY_INCLUDE_DIR AND SNAPPY_LIBRARIES)
52+
if (SNAPPY_INCLUDE_DIR AND (PARQUET_MINIMAL_DEPENDENCY OR SNAPPY_LIBRARIES))
5353
set(SNAPPY_FOUND TRUE)
5454
get_filename_component( SNAPPY_LIBS ${SNAPPY_LIBRARIES} PATH )
55+
set(SNAPPY_HEADER_NAME snappy.h)
56+
set(SNAPPY_HEADER ${SNAPPY_INCLUDE_DIR}/${SNAPPY_HEADER_NAME})
5557
set(SNAPPY_LIB_NAME libsnappy)
5658
set(SNAPPY_STATIC_LIB ${SNAPPY_LIBS}/${SNAPPY_LIB_NAME}.a)
5759
set(SNAPPY_SHARED_LIB ${SNAPPY_LIBS}/${SNAPPY_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
@@ -61,7 +63,11 @@ endif ()
6163

6264
if (SNAPPY_FOUND)
6365
if (NOT Snappy_FIND_QUIETLY)
64-
message(STATUS "Found the Snappy library: ${SNAPPY_LIBRARIES}")
66+
if (PARQUET_MINIMAL_DEPENDENCY)
67+
message(STATUS "Found the Snappy header: ${SNAPPY_HEADER}")
68+
else ()
69+
message(STATUS "Found the Snappy library: ${SNAPPY_LIBRARIES}")
70+
endif ()
6571
endif ()
6672
else ()
6773
if (NOT Snappy_FIND_QUIETLY)

cmake_modules/FindZLIB.cmake

+9-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#
2323
# ZLIB_HOME - When set, this path is inspected instead of standard library
2424
# locations as the root of the ZLIB installation.
25-
# The environment variable ZLIB_HOME overrides this veriable.
25+
# The environment variable ZLIB_HOME overrides this variable.
2626
#
2727
# - Find ZLIB (zlib.h, libz.a, libz.so, and libz.so.1)
2828
# This module defines
@@ -54,9 +54,11 @@ else ()
5454
endif ()
5555

5656

57-
if (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARIES)
57+
if (ZLIB_INCLUDE_DIR AND (PARQUET_MINIMAL_DEPENDENCY OR ZLIB_LIBRARIES))
5858
set(ZLIB_FOUND TRUE)
5959
get_filename_component( ZLIB_LIBS ${ZLIB_LIBRARIES} PATH )
60+
set(ZLIB_HEADER_NAME zlib.h)
61+
set(ZLIB_HEADER ${ZLIB_INCLUDE_DIR}/${ZLIB_HEADER_NAME})
6062
set(ZLIB_LIB_NAME libz)
6163
set(ZLIB_STATIC_LIB ${ZLIB_LIBS}/${ZLIB_LIB_NAME}.a)
6264
set(ZLIB_SHARED_LIB ${ZLIB_LIBS}/${ZLIB_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX})
@@ -66,7 +68,11 @@ endif ()
6668

6769
if (ZLIB_FOUND)
6870
if (NOT ZLIB_FIND_QUIETLY)
69-
message(STATUS "Found the ZLIB library: ${ZLIB_LIBRARIES}")
71+
if (PARQUET_MINIMAL_DEPENDENCY)
72+
message(STATUS "Found the ZLIB header: ${ZLIB_HEADER}")
73+
else()
74+
message(STATUS "Found the ZLIB library: ${ZLIB_LIBRARIES}")
75+
endif ()
7076
endif ()
7177
else ()
7278
if (NOT ZLIB_FIND_QUIETLY)

cmake_modules/ThirdpartyToolchain.cmake

+2-2
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ if (ZLIB_VENDORED)
251251
endif()
252252

253253
## GTest
254-
if(PARQUET_BUILD_TESTS)
254+
if(PARQUET_BUILD_TESTS AND NOT IGNORE_OPTIONAL_PACKAGES)
255255
add_custom_target(unittest ctest -L unittest)
256256

257257
if("$ENV{GTEST_HOME}" STREQUAL "")
@@ -308,7 +308,7 @@ if ("$ENV{GBENCHMARK_HOME}" STREQUAL "")
308308
set(GBENCHMARK_HOME ${THIRDPARTY_DIR}/installed)
309309
endif()
310310

311-
if(PARQUET_BUILD_BENCHMARKS)
311+
if(PARQUET_BUILD_BENCHMARKS AND NOT IGNORE_OPTIONAL_PACKAGES)
312312
add_custom_target(runbenchmark ctest -L benchmark)
313313

314314

0 commit comments

Comments
 (0)