Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MINIFICPP-2269 Upgrade LibLZMA/XZ utils to version 5.6.2 #1823

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 0 additions & 99 deletions cmake/BundledLibLZMA.cmake

This file was deleted.

45 changes: 45 additions & 0 deletions cmake/LibLZMA.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# 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.

include(FetchContent)

set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)

set(PATCH_FILE "${CMAKE_SOURCE_DIR}/thirdparty/liblzma/liblzma.patch")
set(PC ${Bash_EXECUTABLE} -c "set -x &&\
(\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE}\\\")")

FetchContent_Declare(liblzma
URL https://github.com/tukaani-project/xz/releases/download/v5.6.2/xz-5.6.2.tar.gz
URL_HASH SHA256=8bfd20c0e1d86f0402f2497cfa71c6ab62d4cd35fd704276e3140bfb71414519
PATCH_COMMAND "${PC}")

FetchContent_MakeAvailable(liblzma)

add_library(LibLZMA::LibLZMA ALIAS liblzma)

# Set exported variables for FindPackage.cmake

set(LIBLZMA_INCLUDE_DIR "${liblzma_SOURCE_DIR}/src/liblzma/api" CACHE STRING "" FORCE)
if (WIN32)
set(LIBLZMA_LIBRARY "${liblzma_BINARY_DIR}/liblzma.lib" CACHE STRING "" FORCE)
else()
set(LIBLZMA_LIBRARY "${liblzma_BINARY_DIR}/liblzma.a" CACHE STRING "" FORCE)
endif()

set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBLZMA_INCLUDE_DIR=${LIBLZMA_INCLUDE_DIR}" CACHE STRING "" FORCE)
set(PASSTHROUGH_VARIABLES ${PASSTHROUGH_VARIABLES} "-DEXPORTED_LIBLZMA_LIBRARY=${LIBLZMA_LIBRARY}" CACHE STRING "" FORCE)
szaszm marked this conversation as resolved.
Show resolved Hide resolved
17 changes: 4 additions & 13 deletions cmake/liblzma/dummy/FindLibLZMA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,10 @@
# specific language governing permissions and limitations
# under the License.

# Dummy zlib find for when we use bundled version
if(NOT LIBLZMA_FOUND)
set(LIBLZMA_FOUND "YES" CACHE STRING "" FORCE)
set(LIBLZMA_INCLUDE_DIR "${EXPORTED_LIBLZMA_INCLUDE_DIRS}" CACHE STRING "" FORCE)
set(LIBLZMA_INCLUDE_DIRS "${EXPORTED_LIBLZMA_INCLUDE_DIRS}" CACHE STRING "" FORCE)
set(LIBLZMA_LIBRARIES "${EXPORTED_LIBLZMA_LIBRARIES}" CACHE STRING "" FORCE)
endif()

if(NOT TARGET LibLZMA::LibLZMA)
add_library(LibLZMA::LibLZMA STATIC IMPORTED)
set_target_properties(LibLZMA::LibLZMA PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${LIBLZMA_INCLUDE_DIRS}")
set_target_properties(LibLZMA::LibLZMA PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${LIBLZMA_LIBRARIES}")
set(LIBLZMA_INCLUDE_DIR "${EXPORTED_LIBLZMA_INCLUDE_DIR}" CACHE STRING "" FORCE)
set(LIBLZMA_INCLUDE_DIRS "${EXPORTED_LIBLZMA_INCLUDE_DIR}" CACHE STRING "" FORCE)
set(LIBLZMA_LIBRARIES "${EXPORTED_LIBLZMA_LIBRARY}" CACHE STRING "" FORCE)
set(LIBLZMA_LIBRARIES "${EXPORTED_LIBLZMA_LIBRARY}" CACHE STRING "" FORCE)
endif()
3 changes: 1 addition & 2 deletions extensions/libarchive/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ if (NOT ENABLE_LIBARCHIVE)
endif()

if (ENABLE_LZMA)
include(BundledLibLZMA)
use_bundled_liblzma(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
include(LibLZMA)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/liblzma/dummy")
endif()

Expand Down
Loading