libarchive: Simplify code selecting CMake-specific build options

Reduce differences from upstream libarchive `CMakeLists.txt` code.
Remove modifications inside code we disable anyway.
This commit is contained in:
Brad King 2022-02-16 08:06:23 -05:00
parent 4a7a5718c6
commit be9ebc104a
2 changed files with 35 additions and 34 deletions

View File

@ -606,25 +606,41 @@ macro (CMAKE_BUILD_UTILITIES)
set(ZLIB_INCLUDE_DIR ${CMAKE_ZLIB_INCLUDES})
set(ZLIB_LIBRARY ${CMAKE_ZLIB_LIBRARIES})
add_definitions(-DLIBARCHIVE_STATIC)
set(ENABLE_MBEDTLS OFF CACHE INTERNAL "Enable use of mbed TLS")
set(ENABLE_NETTLE OFF CACHE INTERNAL "Enable use of Nettle")
set(ENABLE_OPENSSL ${CMAKE_USE_OPENSSL} CACHE INTERNAL "Enable use of OpenSSL")
set(ENABLE_LIBB2 OFF CACHE INTERNAL "Enable the use of the system LIBB2 library if found")
set(ENABLE_LZMA ON CACHE INTERNAL "Enable the use of the system LZMA library if found")
set(ENABLE_LZ4 OFF CACHE INTERNAL "Enable the use of the system LZ4 library if found")
set(ENABLE_LZO OFF CACHE INTERNAL "Enable the use of the system LZO library if found")
set(ENABLE_ZLIB ON CACHE INTERNAL "Enable the use of the system ZLIB library if found")
set(ENABLE_BZip2 ON CACHE INTERNAL "Enable the use of the system BZip2 library if found")
set(ENABLE_ZSTD ON CACHE INTERNAL "Enable the use of the system zstd library if found")
set(ENABLE_LIBXML2 OFF CACHE INTERNAL "Enable the use of the system libxml2 library if found")
set(ENABLE_EXPAT OFF CACHE INTERNAL "Enable the use of the system EXPAT library if found")
set(ENABLE_PCREPOSIX OFF CACHE INTERNAL "Enable the use of the system PCREPOSIX library if found")
set(ENABLE_LibGCC OFF CACHE INTERNAL "Enable the use of the system LibGCC library if found")
set(ENABLE_XATTR OFF CACHE INTERNAL "Enable extended attribute support")
set(ENABLE_ACL OFF CACHE INTERNAL "Enable ACL support")
set(ENABLE_ICONV OFF CACHE INTERNAL "Enable iconv support")
set(ENABLE_CNG OFF CACHE INTERNAL "Enable the use of CNG(Crypto Next Generation)")
SET(POSIX_REGEX_LIB "" CACHE INTERNAL "Choose what library should provide POSIX regular expression support")
# FIXME: Once CMake 3.13+ is required, drop CACHE and use CMP0077.
set(ENABLE_MBEDTLS OFF CACHE INTERNAL "libarchive: No mbed TLS")
set(ENABLE_NETTLE OFF CACHE INTERNAL "libarchive: No Nettle")
if(DEFINED CMAKE_USE_OPENSSL)
set(ENABLE_OPENSSL ${CMAKE_USE_OPENSSL} CACHE INTERNAL "libarchive: Use OpenSSL?")
else()
set(ENABLE_OPENSSL OFF CACHE INTERNAL "libarchive: Use OpenSSL?")
endif()
set(ENABLE_LIBB2 OFF CACHE INTERNAL "libarchive: No LIBB2")
set(ENABLE_LZ4 OFF CACHE INTERNAL "libarchive: No LZ4")
set(ENABLE_LZO OFF CACHE INTERNAL "libarchive: No LZO")
set(ENABLE_LZMA ON CACHE INTERNAL "libarchive: Use LZMA")
set(ENABLE_ZSTD ON CACHE INTERNAL "libarchive: Use ZSTD")
set(ENABLE_ZLIB ON CACHE INTERNAL "libarchive: Use ZLIB")
set(ENABLE_BZip2 ON CACHE INTERNAL "libarchive: Use BZip2")
set(ENABLE_LIBXML2 OFF CACHE INTERNAL "libarchive: No LibXML2")
set(ENABLE_EXPAT OFF CACHE INTERNAL "libarchive: No Expat")
set(ENABLE_PCREPOSIX OFF CACHE INTERNAL "libarchive: No PCREPOSIX")
set(ENABLE_LibGCC OFF CACHE INTERNAL "libarchive: No LibGCC")
set(ENABLE_CNG OFF CACHE INTERNAL "libarchive: No CNG")
set(ENABLE_TAR OFF CACHE INTERNAL "libarchive: No tar command-line tool")
set(ENABLE_TAR_SHARED OFF CACHE INTERNAL "libarchive: No tar command-line tool")
set(ENABLE_CPIO OFF CACHE INTERNAL "libarchive: No cpio command-line tool")
set(ENABLE_CPIO_SHARED OFF CACHE INTERNAL "libarchive: No cpio command-line tool")
set(ENABLE_CAT OFF CACHE INTERNAL "libarchive: No cat command-line tool")
set(ENABLE_CAT_SHARED OFF CACHE INTERNAL "libarchive: No cat command-line tool")
set(ENABLE_XATTR OFF CACHE INTERNAL "libarchive: No extended attribute support")
set(ENABLE_ACL OFF CACHE INTERNAL "libarchive: No ACL support")
set(ENABLE_ICONV OFF CACHE INTERNAL "libarchive: No iconv support")
set(ENABLE_TEST OFF CACHE INTERNAL "libarchive: No tests")
set(ENABLE_COVERAGE OFF CACHE INTERNAL "libarchive: No coverage")
set(ENABLE_INSTALL OFF CACHE INTERNAL "libarchive: No installation")
set(POSIX_REGEX_LIB "" CACHE INTERNAL "libarchive: No POSIX regular expression support")
set(ENABLE_SAFESEH "" CACHE INTERNAL "libarchive: No /SAFESEH linker flag")
set(WINDOWS_VERSION "WIN7" CACHE INTERNAL "libarchive: Set Windows version to use (Windows only)")
add_subdirectory(Utilities/cmlibarchive)
CMAKE_SET_TARGET_FOLDER(cmlibarchive "Utilities/3rdParty")
set(CMAKE_TAR_LIBRARIES cmlibarchive ${BZIP2_LIBRARIES})

View File

@ -114,7 +114,6 @@ endif ()
# aggressive about diagnosing build problems; this can get
# relaxed somewhat in final shipping versions.
IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR
CMAKE_C_COMPILER_ID MATCHES "^LCC$" OR
CMAKE_C_COMPILER_ID MATCHES "^Clang$")
SET(CMAKE_REQUIRED_FLAGS "-Wall -Wformat -Wformat-security")
#################################################################
@ -233,18 +232,15 @@ OPTION(ENABLE_LibGCC "Enable the use of the system LibGCC library if found" ON)
# CNG is used for encrypt/decrypt Zip archives on Windows.
OPTION(ENABLE_CNG "Enable the use of CNG(Crypto Next Generation)" ON)
IF(0) # CMake does not build libarchive's command-line tools.
OPTION(ENABLE_TAR "Enable tar building" ON)
OPTION(ENABLE_TAR_SHARED "Enable dynamic build of tar" FALSE)
OPTION(ENABLE_CPIO "Enable cpio building" ON)
OPTION(ENABLE_CPIO_SHARED "Enable dynamic build of cpio" FALSE)
OPTION(ENABLE_CAT "Enable cat building" ON)
OPTION(ENABLE_CAT_SHARED "Enable dynamic build of cat" FALSE)
ENDIF()
OPTION(ENABLE_XATTR "Enable extended attribute support" ON)
OPTION(ENABLE_ACL "Enable ACL support" ON)
OPTION(ENABLE_ICONV "Enable iconv support" ON)
IF(0) # CMake does not build libarchive's tests.
OPTION(ENABLE_TEST "Enable unit and regression tests" ON)
OPTION(ENABLE_COVERAGE "Enable code coverage (GCC only, automatically sets ENABLE_TEST to ON)" FALSE)
OPTION(ENABLE_INSTALL "Enable installing of libraries" ON)
@ -260,15 +256,7 @@ ENDIF(ENABLE_COVERAGE)
IF(ENABLE_TEST)
ENABLE_TESTING()
ENDIF(ENABLE_TEST)
ENDIF()
IF(WIN32)
SET(NTDDI_VERSION 0x05010000)
SET(_WIN32_WINNT 0x0501)
SET(WINVER 0x0501)
ENDIF(WIN32)
IF(0) # CMake hard-codes its own supported version of Windows.
IF(WIN32)
IF(WINDOWS_VERSION STREQUAL "WIN8")
SET(NTDDI_VERSION 0x06020000)
@ -315,7 +303,6 @@ IF(MSVC)
SET(ENV{LDFLAGS} "$ENV{LDFLAGS} /SAFESEH:NO")
ENDIF(ENABLE_SAFESEH STREQUAL "YES")
ENDIF(MSVC)
ENDIF()
IF("${CMAKE_C_PLATFORM_ID}" MATCHES "^(HP-UX)$")
ADD_DEFINITIONS(-D_XOPEN_SOURCE=500) # Ask wchar.h for mbstate_t
@ -2036,11 +2023,9 @@ IF(APPLE)
ADD_DEFINITIONS(-Wno-deprecated-declarations)
ENDIF(APPLE)
IF(0) # CMake does not build libarchive's tests.
IF(ENABLE_TEST)
ADD_CUSTOM_TARGET(run_all_tests)
ENDIF(ENABLE_TEST)
ENDIF()
# We need CoreServices on Mac OS.
IF(APPLE)