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

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


The following commit(s) were added to refs/heads/master by this push:
     new b3116fa37e ARROW-17348: [C++] Add support for building bundled LZ4 
with Visual C++ 2019 or later (#13817)
b3116fa37e is described below

commit b3116fa37eba391ff2bcfa8536f894a50bf72975
Author: Sutou Kouhei <[email protected]>
AuthorDate: Wed Aug 10 08:42:23 2022 +0900

    ARROW-17348: [C++] Add support for building bundled LZ4 with Visual C++ 
2019 or later (#13817)
    
    LZ4 provides CMake configuration. We can add support for building
    bundled LZ4 with Visual C++ 2019 or later by using it.
    
    But this needs CMake 3.7 or later because
    ExternaProject_Add(SOURCE_SUBDIR) is supported since CMake 3.7.
    
    Authored-by: Sutou Kouhei <[email protected]>
    Signed-off-by: Sutou Kouhei <[email protected]>
---
 cpp/cmake_modules/ThirdpartyToolchain.cmake | 66 +++++++++++++----------------
 1 file changed, 29 insertions(+), 37 deletions(-)

diff --git a/cpp/cmake_modules/ThirdpartyToolchain.cmake 
b/cpp/cmake_modules/ThirdpartyToolchain.cmake
index 86ad058353..e51b2b44bf 100644
--- a/cpp/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cpp/cmake_modules/ThirdpartyToolchain.cmake
@@ -2306,43 +2306,34 @@ if(ARROW_WITH_ZLIB)
 endif()
 
 macro(build_lz4)
-  message(STATUS "Building lz4 from source")
-  set(LZ4_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/lz4_ep-prefix/src/lz4_ep")
-  set(LZ4_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/lz4_ep-prefix")
-
-  if(MSVC)
-    if(ARROW_USE_STATIC_CRT)
-      if(${UPPERCASE_BUILD_TYPE} STREQUAL "DEBUG")
-        set(LZ4_RUNTIME_LIBRARY_LINKAGE "/p:RuntimeLibrary=MultiThreadedDebug")
-      else()
-        set(LZ4_RUNTIME_LIBRARY_LINKAGE "/p:RuntimeLibrary=MultiThreaded")
-      endif()
-    endif()
-    set(LZ4_STATIC_LIB
-        
"${LZ4_BUILD_DIR}/build/VS2010/bin/x64_${CMAKE_BUILD_TYPE}/liblz4_static.lib")
-    set(LZ4_BUILD_COMMAND
-        BUILD_COMMAND msbuild.exe /m /p:Configuration=${CMAKE_BUILD_TYPE} 
/p:Platform=x64
-        /p:PlatformToolset=v140 ${LZ4_RUNTIME_LIBRARY_LINKAGE} /t:Build
-        ${LZ4_BUILD_DIR}/build/VS2010/lz4.sln)
-  else()
-    set(LZ4_STATIC_LIB "${LZ4_BUILD_DIR}/lib/liblz4.a")
-    # Must explicitly invoke sh on MinGW
-    set(LZ4_BUILD_COMMAND
-        BUILD_COMMAND sh 
"${CMAKE_CURRENT_SOURCE_DIR}/build-support/build-lz4-lib.sh"
-        "AR=${CMAKE_AR}" "OS=${CMAKE_SYSTEM_NAME}")
+  message(STATUS "Building LZ4 from source")
+  if(CMAKE_VERSION VERSION_LESS 3.7)
+    message(FATAL_ERROR "Building LZ4 using ExternalProject requires at least 
CMake 3.7")
   endif()
 
+  set(LZ4_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/lz4_ep-install")
+
+  set(LZ4_STATIC_LIB
+      
"${LZ4_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}lz4${CMAKE_STATIC_LIBRARY_SUFFIX}")
+
+  set(LZ4_CMAKE_ARGS
+      ${EP_COMMON_CMAKE_ARGS}
+      -DBUILD_SHARED_LIBS=OFF
+      -DBUILD_STATIC_LIBS=ON
+      -DCMAKE_INSTALL_LIBDIR=lib
+      -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
+      -DLZ4_BUILD_CLI=OFF
+      -DLZ4_BUILD_LEGACY_LZ4C=OFF)
+
   # We need to copy the header in lib to directory outside of the build
   externalproject_add(lz4_ep
-                      URL ${LZ4_SOURCE_URL} ${EP_LOG_OPTIONS}
+                      ${EP_LOG_OPTIONS}
+                      CMAKE_ARGS ${LZ4_CMAKE_ARGS}
+                      SOURCE_SUBDIR "build/cmake"
+                      INSTALL_DIR ${LZ4_PREFIX}
+                      URL ${LZ4_SOURCE_URL}
                       URL_HASH "SHA256=${ARROW_LZ4_BUILD_SHA256_CHECKSUM}"
-                      UPDATE_COMMAND ${CMAKE_COMMAND} -E copy_directory
-                                     "${LZ4_BUILD_DIR}/lib" 
"${LZ4_PREFIX}/include"
-                                     ${LZ4_PATCH_COMMAND}
-                      CONFIGURE_COMMAND ""
-                      INSTALL_COMMAND ""
-                      BINARY_DIR ${LZ4_BUILD_DIR}
-                      BUILD_BYPRODUCTS ${LZ4_STATIC_LIB} ${LZ4_BUILD_COMMAND})
+                      BUILD_BYPRODUCTS ${LZ4_STATIC_LIB})
 
   file(MAKE_DIRECTORY "${LZ4_PREFIX}/include")
   add_library(lz4::lz4 STATIC IMPORTED)
@@ -2364,7 +2355,12 @@ if(ARROW_WITH_LZ4)
 endif()
 
 macro(build_zstd)
-  message(STATUS "Building zstd from source")
+  message(STATUS "Building Zstandard from source")
+  if(CMAKE_VERSION VERSION_LESS 3.7)
+    message(FATAL_ERROR "Building Zstandard using ExternalProject requires at 
least CMake 3.7"
+    )
+  endif()
+
   set(ZSTD_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/zstd_ep-install")
 
   set(ZSTD_CMAKE_ARGS
@@ -2394,10 +2390,6 @@ macro(build_zstd)
         -DCMAKE_CXX_FLAGS=${EP_CXX_FLAGS})
   endif()
 
-  if(CMAKE_VERSION VERSION_LESS 3.7)
-    message(FATAL_ERROR "Building zstd using ExternalProject requires at least 
CMake 3.7")
-  endif()
-
   externalproject_add(zstd_ep
                       ${EP_LOG_OPTIONS}
                       CMAKE_ARGS ${ZSTD_CMAKE_ARGS}

Reply via email to