CMake: Enable use of liblzma in libarchive (#14504)
Build liblzma as part of CMake or find one on the system. Modify our port of libarchive to use the liblzma configured for use with CMake.
This commit is contained in:
parent
73eab246fb
commit
8436d18115
|
@ -57,7 +57,7 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES)
|
||||||
|
|
||||||
# Allow the user to enable/disable all system utility library options by
|
# Allow the user to enable/disable all system utility library options by
|
||||||
# defining CMAKE_USE_SYSTEM_LIBRARIES or CMAKE_USE_SYSTEM_LIBRARY_${util}.
|
# defining CMAKE_USE_SYSTEM_LIBRARIES or CMAKE_USE_SYSTEM_LIBRARY_${util}.
|
||||||
set(UTILITIES BZIP2 CURL EXPAT LIBARCHIVE ZLIB)
|
set(UTILITIES BZIP2 CURL EXPAT LIBARCHIVE LIBLZMA ZLIB)
|
||||||
foreach(util ${UTILITIES})
|
foreach(util ${UTILITIES})
|
||||||
if(NOT DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util}
|
if(NOT DEFINED CMAKE_USE_SYSTEM_LIBRARY_${util}
|
||||||
AND DEFINED CMAKE_USE_SYSTEM_LIBRARIES)
|
AND DEFINED CMAKE_USE_SYSTEM_LIBRARIES)
|
||||||
|
@ -93,6 +93,8 @@ macro(CMAKE_HANDLE_SYSTEM_LIBRARIES)
|
||||||
"${CMAKE_USE_SYSTEM_LIBRARY_ZLIB}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE;NOT CMAKE_USE_SYSTEM_CURL" ON)
|
"${CMAKE_USE_SYSTEM_LIBRARY_ZLIB}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE;NOT CMAKE_USE_SYSTEM_CURL" ON)
|
||||||
CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_BZIP2 "Use system-installed bzip2"
|
CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_BZIP2 "Use system-installed bzip2"
|
||||||
"${CMAKE_USE_SYSTEM_LIBRARY_BZIP2}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON)
|
"${CMAKE_USE_SYSTEM_LIBRARY_BZIP2}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON)
|
||||||
|
CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_LIBLZMA "Use system-installed liblzma"
|
||||||
|
"${CMAKE_USE_SYSTEM_LIBRARY_LIBLZMA}" "NOT CMAKE_USE_SYSTEM_LIBARCHIVE" ON)
|
||||||
|
|
||||||
# Mention to the user what system libraries are being used.
|
# Mention to the user what system libraries are being used.
|
||||||
foreach(util ${UTILITIES})
|
foreach(util ${UTILITIES})
|
||||||
|
@ -300,6 +302,23 @@ macro (CMAKE_BUILD_UTILITIES)
|
||||||
CMAKE_SET_TARGET_FOLDER(cmbzip2 "Utilities/3rdParty")
|
CMAKE_SET_TARGET_FOLDER(cmbzip2 "Utilities/3rdParty")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#---------------------------------------------------------------------
|
||||||
|
# Build or use system liblzma for libarchive.
|
||||||
|
if(CMAKE_USE_SYSTEM_LIBLZMA)
|
||||||
|
find_package(LibLZMA)
|
||||||
|
if(NOT LIBLZMA_FOUND)
|
||||||
|
message(FATAL_ERROR "CMAKE_USE_SYSTEM_LIBLZMA is ON but LibLZMA is not found!")
|
||||||
|
endif()
|
||||||
|
set(LZMA_INCLUDE_DIR ${LIBLZMA_INCLUDE_DIRS})
|
||||||
|
set(LZMA_LIBRARY ${LIBLZMA_LIBRARIES})
|
||||||
|
else()
|
||||||
|
add_subdirectory(Utilities/cmliblzma)
|
||||||
|
CMAKE_SET_TARGET_FOLDER(cmliblzma "Utilities/3rdParty")
|
||||||
|
set(LZMA_INCLUDE_DIR
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/Utilities/cmliblzma/liblzma/api")
|
||||||
|
set(LZMA_LIBRARY cmliblzma)
|
||||||
|
endif()
|
||||||
|
|
||||||
#---------------------------------------------------------------------
|
#---------------------------------------------------------------------
|
||||||
# Build or use system libarchive for CMake and CTest.
|
# Build or use system libarchive for CMake and CTest.
|
||||||
if(CMAKE_USE_SYSTEM_LIBARCHIVE)
|
if(CMAKE_USE_SYSTEM_LIBARCHIVE)
|
||||||
|
@ -315,7 +334,7 @@ macro (CMAKE_BUILD_UTILITIES)
|
||||||
add_definitions(-DLIBARCHIVE_STATIC)
|
add_definitions(-DLIBARCHIVE_STATIC)
|
||||||
set(ENABLE_NETTLE OFF CACHE INTERNAL "Enable use of Nettle")
|
set(ENABLE_NETTLE OFF CACHE INTERNAL "Enable use of Nettle")
|
||||||
set(ENABLE_OPENSSL ${CMAKE_USE_OPENSSL} CACHE INTERNAL "Enable use of OpenSSL")
|
set(ENABLE_OPENSSL ${CMAKE_USE_OPENSSL} CACHE INTERNAL "Enable use of OpenSSL")
|
||||||
set(ENABLE_LZMA OFF CACHE INTERNAL "Enable the use of the system found LZMA library if found")
|
set(ENABLE_LZMA ON CACHE INTERNAL "Enable the use of the system found LZMA library if found")
|
||||||
set(ENABLE_ZLIB ON CACHE INTERNAL "Enable the use of the system found ZLIB library if found")
|
set(ENABLE_ZLIB ON CACHE INTERNAL "Enable the use of the system found ZLIB library if found")
|
||||||
set(ENABLE_BZip2 ON CACHE INTERNAL "Enable the use of the system found BZip2 library if found")
|
set(ENABLE_BZip2 ON CACHE INTERNAL "Enable the use of the system found BZip2 library if found")
|
||||||
set(ENABLE_EXPAT OFF CACHE INTERNAL "Enable the use of the system found EXPAT library if found")
|
set(ENABLE_EXPAT OFF CACHE INTERNAL "Enable the use of the system found EXPAT library if found")
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#cmakedefine CMAKE_USE_SYSTEM_ZLIB
|
#cmakedefine CMAKE_USE_SYSTEM_ZLIB
|
||||||
#cmakedefine CMAKE_USE_SYSTEM_BZIP2
|
#cmakedefine CMAKE_USE_SYSTEM_BZIP2
|
||||||
#cmakedefine CMAKE_USE_SYSTEM_LIBARCHIVE
|
#cmakedefine CMAKE_USE_SYSTEM_LIBARCHIVE
|
||||||
|
#cmakedefine CMAKE_USE_SYSTEM_LIBLZMA
|
||||||
#cmakedefine CTEST_USE_XMLRPC
|
#cmakedefine CTEST_USE_XMLRPC
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*============================================================================
|
||||||
|
CMake - Cross Platform Makefile Generator
|
||||||
|
Copyright 2014 Kitware, Inc., Insight Software Consortium
|
||||||
|
|
||||||
|
Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
see accompanying file Copyright.txt for details.
|
||||||
|
|
||||||
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the License for more information.
|
||||||
|
============================================================================*/
|
||||||
|
#ifndef __cm_lzma_h
|
||||||
|
#define __cm_lzma_h
|
||||||
|
|
||||||
|
/* Use the liblzma configured for CMake. */
|
||||||
|
#include "cmThirdParty.h"
|
||||||
|
#ifdef CMAKE_USE_SYSTEM_LIBLZMA
|
||||||
|
# include <lzma.h>
|
||||||
|
#else
|
||||||
|
# include <cmliblzma/liblzma/api/lzma.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
|
@ -275,7 +275,6 @@ IF(BZIP2_FOUND)
|
||||||
ENDIF(BZIP2_FOUND)
|
ENDIF(BZIP2_FOUND)
|
||||||
MARK_AS_ADVANCED(CLEAR BZIP2_INCLUDE_DIR)
|
MARK_AS_ADVANCED(CLEAR BZIP2_INCLUDE_DIR)
|
||||||
MARK_AS_ADVANCED(CLEAR BZIP2_LIBRARIES)
|
MARK_AS_ADVANCED(CLEAR BZIP2_LIBRARIES)
|
||||||
IF(0) # CMake does not need LZMA or LZO2 support in libarchive
|
|
||||||
#
|
#
|
||||||
# Find LZMA
|
# Find LZMA
|
||||||
#
|
#
|
||||||
|
@ -291,15 +290,19 @@ IF(LZMA_FOUND)
|
||||||
SET(HAVE_LZMA_H 1)
|
SET(HAVE_LZMA_H 1)
|
||||||
INCLUDE_DIRECTORIES(${LZMA_INCLUDE_DIR})
|
INCLUDE_DIRECTORIES(${LZMA_INCLUDE_DIR})
|
||||||
LIST(APPEND ADDITIONAL_LIBS ${LZMA_LIBRARIES})
|
LIST(APPEND ADDITIONAL_LIBS ${LZMA_LIBRARIES})
|
||||||
# Test if a macro is needed for the library.
|
IF(CMAKE_USE_SYSTEM_LIBLZMA)
|
||||||
TRY_MACRO_FOR_LIBRARY(
|
# Test if a macro is needed for the library.
|
||||||
"${LZMA_INCLUDE_DIR}" "${LZMA_LIBRARIES}"
|
TRY_MACRO_FOR_LIBRARY(
|
||||||
COMPILES
|
"${LZMA_INCLUDE_DIR}" "${LZMA_LIBRARIES}"
|
||||||
"#include <lzma.h>\nint main() {return (int)lzma_version_number(); }"
|
COMPILES
|
||||||
"WITHOUT_LZMA_API_STATIC;LZMA_API_STATIC")
|
"#include <lzma.h>\nint main() {return (int)lzma_version_number(); }"
|
||||||
IF(NOT WITHOUT_LZMA_API_STATIC AND LZMA_API_STATIC)
|
"WITHOUT_LZMA_API_STATIC;LZMA_API_STATIC")
|
||||||
|
IF(NOT WITHOUT_LZMA_API_STATIC AND LZMA_API_STATIC)
|
||||||
|
ADD_DEFINITIONS(-DLZMA_API_STATIC)
|
||||||
|
ENDIF(NOT WITHOUT_LZMA_API_STATIC AND LZMA_API_STATIC)
|
||||||
|
ELSE()
|
||||||
ADD_DEFINITIONS(-DLZMA_API_STATIC)
|
ADD_DEFINITIONS(-DLZMA_API_STATIC)
|
||||||
ENDIF(NOT WITHOUT_LZMA_API_STATIC AND LZMA_API_STATIC)
|
ENDIF()
|
||||||
ELSEIF(LZMADEC_FOUND)
|
ELSEIF(LZMADEC_FOUND)
|
||||||
SET(HAVE_LIBLZMADEC 1)
|
SET(HAVE_LIBLZMADEC 1)
|
||||||
SET(HAVE_LZMADEC_H 1)
|
SET(HAVE_LZMADEC_H 1)
|
||||||
|
@ -308,6 +311,7 @@ ELSEIF(LZMADEC_FOUND)
|
||||||
ELSE(LZMA_FOUND)
|
ELSE(LZMA_FOUND)
|
||||||
# LZMA not found and will not be used.
|
# LZMA not found and will not be used.
|
||||||
ENDIF(LZMA_FOUND)
|
ENDIF(LZMA_FOUND)
|
||||||
|
IF(0) # CMake does not need LZO2 support in libarchive
|
||||||
#
|
#
|
||||||
# Find LZO2
|
# Find LZO2
|
||||||
#
|
#
|
||||||
|
|
|
@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$");
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_LZMA_H
|
#if HAVE_LZMA_H
|
||||||
#include <lzma.h>
|
#include <cm_lzma.h>
|
||||||
#elif HAVE_LZMADEC_H
|
#elif HAVE_LZMADEC_H
|
||||||
#include <lzmadec.h>
|
#include <lzmadec.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$");
|
||||||
#include <cm_bzlib.h>
|
#include <cm_bzlib.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_LZMA_H
|
#ifdef HAVE_LZMA_H
|
||||||
#include <lzma.h>
|
#include <cm_lzma.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_ZLIB_H
|
#ifdef HAVE_ZLIB_H
|
||||||
#include <cm_zlib.h>
|
#include <cm_zlib.h>
|
||||||
|
|
|
@ -42,7 +42,7 @@ __FBSDID("$FreeBSD$");
|
||||||
#include <cm_bzlib.h>
|
#include <cm_bzlib.h>
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_LZMA_H
|
#if HAVE_LZMA_H
|
||||||
#include <lzma.h>
|
#include <cm_lzma.h>
|
||||||
#elif HAVE_LZMADEC_H
|
#elif HAVE_LZMADEC_H
|
||||||
#include <lzmadec.h>
|
#include <lzmadec.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -49,7 +49,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_util.c 201098 2009-12-28 02:58:1
|
||||||
#include <cm_zlib.h>
|
#include <cm_zlib.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_LZMA_H
|
#ifdef HAVE_LZMA_H
|
||||||
#include <lzma.h>
|
#include <cm_lzma.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_BZLIB_H
|
#ifdef HAVE_BZLIB_H
|
||||||
#include <cm_bzlib.h>
|
#include <cm_bzlib.h>
|
||||||
|
|
|
@ -76,6 +76,7 @@
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#pragma warning(push,1)
|
#pragma warning(push,1)
|
||||||
|
#pragma warning(disable:4142) /* benign redefinition of type */
|
||||||
#pragma warning(disable:4761) /* integral size mismatch in argument; conversion supplied */
|
#pragma warning(disable:4761) /* integral size mismatch in argument; conversion supplied */
|
||||||
#endif
|
#endif
|
||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
|
|
|
@ -39,7 +39,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_compression_xz.c 20110
|
||||||
#endif
|
#endif
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#ifdef HAVE_LZMA_H
|
#ifdef HAVE_LZMA_H
|
||||||
#include <lzma.h>
|
#include <cm_lzma.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "archive.h"
|
#include "archive.h"
|
||||||
|
|
|
@ -34,7 +34,7 @@ __FBSDID("$FreeBSD$");
|
||||||
#include <cm_bzlib.h>
|
#include <cm_bzlib.h>
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_LZMA_H
|
#if HAVE_LZMA_H
|
||||||
#include <lzma.h>
|
#include <cm_lzma.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_ZLIB_H
|
#ifdef HAVE_ZLIB_H
|
||||||
#include <cm_zlib.h>
|
#include <cm_zlib.h>
|
||||||
|
|
|
@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$");
|
||||||
#include <cm_bzlib.h>
|
#include <cm_bzlib.h>
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_LZMA_H
|
#if HAVE_LZMA_H
|
||||||
#include <lzma.h>
|
#include <cm_lzma.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_ZLIB_H
|
#ifdef HAVE_ZLIB_H
|
||||||
#include <cm_zlib.h>
|
#include <cm_zlib.h>
|
||||||
|
|
Loading…
Reference in New Issue