You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2017/07/01 22:00:59 UTC
arrow git commit: ARROW-599: CMake support of LZ4 compression lib
Repository: arrow
Updated Branches:
refs/heads/master 9f500aff8 -> 456330f6d
ARROW-599: CMake support of LZ4 compression lib
Author: Max Risuhin <ri...@gmail.com>
Closes #799 from MaxRis/ARROW-599 and squashes the following commits:
2e905dae [Max Risuhin] ARROW-599: CMake support of LZ4 compression lib
Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/456330f6
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/456330f6
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/456330f6
Branch: refs/heads/master
Commit: 456330f6d2a84ffa28a325e32f2786469cdad820
Parents: 9f500af
Author: Max Risuhin <ri...@gmail.com>
Authored: Sat Jul 1 18:00:53 2017 -0400
Committer: Wes McKinney <we...@twosigma.com>
Committed: Sat Jul 1 18:00:53 2017 -0400
----------------------------------------------------------------------
cpp/cmake_modules/FindLz4.cmake | 70 ++++++++++++++++++++++++
cpp/cmake_modules/ThirdpartyToolchain.cmake | 45 +++++++++++++++
2 files changed, 115 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/arrow/blob/456330f6/cpp/cmake_modules/FindLz4.cmake
----------------------------------------------------------------------
diff --git a/cpp/cmake_modules/FindLz4.cmake b/cpp/cmake_modules/FindLz4.cmake
new file mode 100644
index 0000000..e25b013
--- /dev/null
+++ b/cpp/cmake_modules/FindLz4.cmake
@@ -0,0 +1,70 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# - Find LZ4 (lz4.h, liblz4.a, liblz4.so, and liblz4.so.0)
+# This module defines
+# LZ4_INCLUDE_DIR, directory containing headers
+# LZ4_SHARED_LIB, path to liblz4 shared library
+# LZ4_STATIC_LIB, path to liblz4 static library
+# LZ4_FOUND, whether lz4 has been found
+
+if( NOT "${LZ4_HOME}" STREQUAL "")
+ file( TO_CMAKE_PATH "${LZ4_HOME}" _native_path )
+ list( APPEND _lz4_roots ${_native_path} )
+elseif ( Lz4_HOME )
+ list( APPEND _lz4_roots ${Lz4_HOME} )
+endif()
+
+if (MSVC AND NOT LZ4_MSVC_STATIC_LIB_SUFFIX)
+ set(LZ4_MSVC_STATIC_LIB_SUFFIX "_static")
+endif()
+
+set(LZ4_STATIC_LIB_SUFFIX
+ "${LZ4_MSVC_STATIC_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}")
+
+set(LZ4_STATIC_LIB_NAME
+ ${CMAKE_STATIC_LIBRARY_PREFIX}lz4${LZ4_STATIC_LIB_SUFFIX})
+
+if ( _lz4_roots )
+ find_path(LZ4_INCLUDE_DIR NAMES lz4.h
+ PATHS ${_lz4_roots}
+ NO_DEFAULT_PATH
+ PATH_SUFFIXES "include" )
+ find_library(LZ4_SHARED_LIB NAMES lz4
+ PATHS ${_lz4_roots}
+ NO_DEFAULT_PATH
+ PATH_SUFFIXES "lib" )
+ find_library(LZ4_STATIC_LIB NAMES ${LZ4_STATIC_LIB_NAME}
+ PATHS ${_lz4_roots}
+ NO_DEFAULT_PATH
+ PATH_SUFFIXES "lib" )
+else()
+ find_path(LZ4_INCLUDE_DIR lz4.h
+ # make sure we don't accidentally pick up a different version
+ NO_CMAKE_SYSTEM_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH)
+ find_library(LZ4_SHARED_LIB lz4
+ NO_CMAKE_SYSTEM_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH)
+ find_library(LZ4_STATIC_LIB ${LZ4_STATIC_LIB_NAME}
+ NO_CMAKE_SYSTEM_PATH
+ NO_SYSTEM_ENVIRONMENT_PATH)
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(LZ4 REQUIRED_VARS
+ LZ4_SHARED_LIB LZ4_STATIC_LIB LZ4_INCLUDE_DIR)
http://git-wip-us.apache.org/repos/asf/arrow/blob/456330f6/cpp/cmake_modules/ThirdpartyToolchain.cmake
----------------------------------------------------------------------
diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index d77aa53..8da2087 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -27,6 +27,7 @@ set(FLATBUFFERS_VERSION "1.7.1")
set(JEMALLOC_VERSION "4.4.0")
set(SNAPPY_VERSION "1.1.3")
set(BROTLI_VERSION "v0.6.0")
+set(LZ4_VERSION "1.7.5")
string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_BUILD_TYPE)
@@ -47,6 +48,7 @@ if (NOT "$ENV{ARROW_BUILD_TOOLCHAIN}" STREQUAL "")
set(SNAPPY_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
set(ZLIB_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
set(BROTLI_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
+ set(LZ4_HOME "$ENV{ARROW_BUILD_TOOLCHAIN}")
if (NOT DEFINED ENV{BOOST_ROOT})
# Since we have to set this in the environment, we check whether
@@ -83,6 +85,10 @@ if (DEFINED ENV{BROTLI_HOME})
set(BROTLI_HOME "$ENV{BROTLI_HOME}")
endif()
+if (DEFINED ENV{LZ4_HOME})
+ set(LZ4_HOME "$ENV{LZ4_HOME}")
+endif()
+
# ----------------------------------------------------------------------
# Find pthreads
@@ -637,3 +643,42 @@ if (BROTLI_VENDORED)
add_dependencies(brotli_dec brotli_ep)
add_dependencies(brotli_common brotli_ep)
endif()
+
+# ----------------------------------------------------------------------
+# Lz4
+
+find_package(Lz4)
+if (NOT LZ4_FOUND)
+ set(LZ4_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/lz4_ep-prefix/src/lz4_ep")
+ set(LZ4_INCLUDE_DIR "${LZ4_BUILD_DIR}/lib")
+
+ if (MSVC)
+ set(LZ4_STATIC_LIB "${LZ4_BUILD_DIR}/visual/VS2010/bin/x64_Release/liblz4_static.lib")
+ set(LZ4_BUILD_COMMAND BUILD_COMMAND msbuild.exe /m /p:Configuration=Release /p:Platform=x64 /p:PlatformToolset=v140 /t:Build ${LZ4_BUILD_DIR}/visual/VS2010/lz4.sln)
+ else()
+ set(LZ4_STATIC_LIB "${LZ4_BUILD_DIR}/lib/liblz4.a")
+ set(LZ4_BUILD_COMMAND BUILD_COMMAND make -j4)
+ endif()
+
+ ExternalProject_Add(lz4_ep
+ URL "https://github.com/lz4/lz4/archive/v${LZ4_VERSION}.tar.gz"
+ UPDATE_COMMAND ""
+ PATCH_COMMAND ""
+ CONFIGURE_COMMAND ""
+ INSTALL_COMMAND ""
+ BINARY_DIR ${LZ4_BUILD_DIR}
+ ${LZ4_BUILD_COMMAND}
+ )
+
+ set(LZ4_VENDORED 1)
+else()
+ set(LZ4_VENDORED 0)
+endif()
+
+include_directories(SYSTEM ${LZ4_INCLUDE_DIR})
+ADD_THIRDPARTY_LIB(lz4_static
+ STATIC_LIB ${LZ4_STATIC_LIB})
+
+if (LZ4_VENDORED)
+ add_dependencies(lz4_static lz4_ep)
+endif()