Browse Source

libarchive: Update to build within CMake

Hard-code more libarchive options as internal cache entries.  Doing so
makes some of our `IF(0)` conditions unnecessary, so remove those.
Brad King 6 years ago
parent
commit
b83d96f164

+ 5 - 1
CMakeLists.txt

@@ -547,21 +547,25 @@ 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 ON CACHE INTERNAL "Enable the use of the system EXPAT 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")
     add_subdirectory(Utilities/cmlibarchive)
     CMAKE_SET_TARGET_FOLDER(cmlibarchive "Utilities/3rdParty")
     set(CMAKE_TAR_LIBRARIES cmlibarchive ${BZIP2_LIBRARIES})

+ 4 - 0
Source/cm_get_date.c

@@ -2,6 +2,10 @@
    file Copyright.txt or https://cmake.org/licensing for details.  */
 #include "cm_get_date.h"
 
+// FIXME: This suppresses use of localtime_r because archive_getdate.c
+// depends the rest of libarchive's checks for that.
+#define CM_GET_DATE
+
 #define __archive_get_date cm_get_date
 
 #include "../Utilities/cmlibarchive/libarchive/archive_getdate.c"

+ 6 - 21
Utilities/cmlibarchive/CMakeLists.txt

@@ -91,11 +91,6 @@ SET(CMAKE_REQUIRED_DEFINITIONS)
 SET(CMAKE_REQUIRED_INCLUDES)
 SET(CMAKE_REQUIRED_LIBRARIES)
 SET(CMAKE_REQUIRED_FLAGS)
-if (CMAKE_BUILD_TYPE STREQUAL "Debug")
-  OPTION(ENABLE_WERROR "Treat warnings as errors - default is ON for Debug, OFF otherwise." ON)
-else ()
-  OPTION(ENABLE_WERROR "Treat warnings as errors - default is ON for Debug, OFF otherwise." OFF)
-endif ()
 
 # Disable warnings to avoid changing 3rd party code.
 IF(CMAKE_C_COMPILER_ID MATCHES
@@ -106,6 +101,12 @@ ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "PathScale")
 ENDIF()
 
 IF(0) # CMake does not need flags specific to libarchive upstream development.
+if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+  OPTION(ENABLE_WERROR "Treat warnings as errors - default is ON for Debug, OFF otherwise." ON)
+else ()
+  OPTION(ENABLE_WERROR "Treat warnings as errors - default is ON for Debug, OFF otherwise." OFF)
+endif ()
+
 # Especially for early development, we want to be a little
 # aggressive about diagnosing build problems; this can get
 # relaxed somewhat in final shipping versions.
@@ -255,7 +256,6 @@ ENDIF(ENABLE_TEST)
 ENDIF()
 
 IF(WIN32)
-  #ELSEIF(WINDOWS_VERSION STREQUAL "WINXP")
   SET(NTDDI_VERSION 0x05010000)
   SET(_WIN32_WINNT 0x0501)
   SET(WINVER 0x0501)
@@ -310,8 +310,6 @@ IF(MSVC)
 ENDIF(MSVC)
 ENDIF()
 
-set(HAVE_PTHREAD_H 0) # no threads in CMake
-
 IF("${CMAKE_C_PLATFORM_ID}" MATCHES "^(HP-UX)$")
   ADD_DEFINITIONS(-D_XOPEN_SOURCE=500) # Ask wchar.h for mbstate_t
 ENDIF()
@@ -499,7 +497,6 @@ IF(BZIP2_FOUND)
     ADD_DEFINITIONS(-DUSE_BZIP2_STATIC)
   ENDIF(USE_BZIP2_DLL)
 ENDIF(BZIP2_FOUND)
-MARK_AS_ADVANCED(CLEAR BZIP2_INCLUDE_DIR)
 
 
 #
@@ -536,7 +533,6 @@ IF(LIBLZMA_FOUND)
 ELSE(LIBLZMA_FOUND)
 # LZMA not found and will not be used.
 ENDIF(LIBLZMA_FOUND)
-IF(0) # CMake does not need LZO2 support in libarchive
 #
 # Find LZO2
 #
@@ -563,10 +559,6 @@ IF(LZO2_FOUND)
   # TODO: test for static library.
   #
 ENDIF(LZO2_FOUND)
-MARK_AS_ADVANCED(CLEAR LZO2_INCLUDE_DIR)
-MARK_AS_ADVANCED(CLEAR LZO2_LIBRARY)
-ENDIF()
-IF(0) # CMake does not need LZ4 support in libarchive
 #
 # Find libb2
 #
@@ -625,9 +617,6 @@ IF(LZ4_FOUND)
   # TODO: test for static library.
   #
 ENDIF(LZ4_FOUND)
-MARK_AS_ADVANCED(CLEAR LZ4_INCLUDE_DIR)
-MARK_AS_ADVANCED(CLEAR LZ4_LIBRARY)
-ENDIF()
 #
 # Find Zstd
 #
@@ -1183,7 +1172,6 @@ ELSE(ENABLE_ICONV)
   UNSET(LIBCHARSET_STATIC CACHE)
 ENDIF(ENABLE_ICONV)
 
-IF(0) # CMake does not need XML support in libarchive
 #
 # Find Libxml2
 #
@@ -1230,9 +1218,6 @@ ELSE(LIBXML2_FOUND)
     CMAKE_POP_CHECK_STATE()	# Restore the state of the variables
   ENDIF(EXPAT_FOUND)
 ENDIF(LIBXML2_FOUND)
-MARK_AS_ADVANCED(CLEAR LIBXML2_INCLUDE_DIR)
-MARK_AS_ADVANCED(CLEAR LIBXML2_LIBRARIES)
-ENDIF()
 
 #
 # POSIX Regular Expression support

+ 2 - 0
Utilities/cmlibarchive/libarchive/archive_getdate.c

@@ -27,7 +27,9 @@
 **  This code is in the public domain and has no copyright.
 */
 
+#ifndef CM_GET_DATE
 #include "archive_platform.h"
+#endif
 #ifdef __FreeBSD__
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD$");

+ 1 - 1
Utilities/cmlibarchive/libarchive/archive_read_support_format_rar5.c

@@ -31,7 +31,7 @@
 #endif
 #include <time.h>
 #ifdef HAVE_ZLIB_H
-#include <zlib.h> /* crc32 */
+#include <cm_zlib.h> /* crc32 */
 #endif
 #ifdef HAVE_LIMITS_H
 #include <limits.h>