summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/zstd/build/cmake
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/zstd/build/cmake')
-rw-r--r--3rdparty/zstd/build/cmake/.gitignore10
-rw-r--r--3rdparty/zstd/build/cmake/CMakeLists.txt212
-rw-r--r--3rdparty/zstd/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake121
-rw-r--r--3rdparty/zstd/build/cmake/CMakeModules/FindLibLZ4.cmake49
-rw-r--r--3rdparty/zstd/build/cmake/CMakeModules/GetZstdLibraryVersion.cmake10
-rw-r--r--3rdparty/zstd/build/cmake/CMakeModules/JoinPaths.cmake23
-rw-r--r--3rdparty/zstd/build/cmake/README.md104
-rw-r--r--3rdparty/zstd/build/cmake/contrib/CMakeLists.txt13
-rw-r--r--3rdparty/zstd/build/cmake/contrib/gen_html/CMakeLists.txt30
-rw-r--r--3rdparty/zstd/build/cmake/contrib/pzstd/CMakeLists.txt38
-rw-r--r--3rdparty/zstd/build/cmake/lib/.gitignore2
-rw-r--r--3rdparty/zstd/build/cmake/lib/CMakeLists.txt181
-rw-r--r--3rdparty/zstd/build/cmake/lib/cmake_uninstall.cmake.in22
-rw-r--r--3rdparty/zstd/build/cmake/programs/.gitignore5
-rw-r--r--3rdparty/zstd/build/cmake/programs/CMakeLists.txt137
-rw-r--r--3rdparty/zstd/build/cmake/tests/.gitignore6
-rw-r--r--3rdparty/zstd/build/cmake/tests/CMakeLists.txt118
-rw-r--r--3rdparty/zstd/build/cmake/zstdConfig.cmake1
18 files changed, 1082 insertions, 0 deletions
diff --git a/3rdparty/zstd/build/cmake/.gitignore b/3rdparty/zstd/build/cmake/.gitignore
new file mode 100644
index 00000000000..2e51e8954f0
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/.gitignore
@@ -0,0 +1,10 @@
+# cmake working directory
+cmakeBuild
+
+# cmake artefacts
+CMakeCache.txt
+CMakeFiles
+Makefile
+cmake_install.cmake
+cmake_uninstall.cmake
+*.1
diff --git a/3rdparty/zstd/build/cmake/CMakeLists.txt b/3rdparty/zstd/build/cmake/CMakeLists.txt
new file mode 100644
index 00000000000..0bffc87d933
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/CMakeLists.txt
@@ -0,0 +1,212 @@
+# ################################################################
+# Copyright (c) Meta Platforms, Inc. and affiliates.
+# All rights reserved.
+#
+# This source code is licensed under both the BSD-style license (found in the
+# LICENSE file in the root directory of this source tree) and the GPLv2 (found
+# in the COPYING file in the root directory of this source tree).
+# ################################################################
+
+cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
+
+# As of 2018-12-26 ZSTD has been validated to build with cmake version 3.13.2 new policies.
+# Set and use the newest cmake policies that are validated to work
+set(ZSTD_MAX_VALIDATED_CMAKE_MAJOR_VERSION "3")
+set(ZSTD_MAX_VALIDATED_CMAKE_MINOR_VERSION "13") #Policies never changed at PATCH level
+if("${CMAKE_MAJOR_VERSION}" LESS 3)
+ set(ZSTD_CMAKE_POLICY_VERSION "${CMAKE_VERSION}")
+elseif( "${ZSTD_MAX_VALIDATED_CMAKE_MAJOR_VERSION}" EQUAL "${CMAKE_MAJOR_VERSION}" AND
+ "${ZSTD_MAX_VALIDATED_CMAKE_MINOR_VERSION}" GREATER "${CMAKE_MINOR_VERSION}")
+ set(ZSTD_CMAKE_POLICY_VERSION "${CMAKE_VERSION}")
+else()
+ set(ZSTD_CMAKE_POLICY_VERSION "${ZSTD_MAX_VALIDATED_CMAKE_MAJOR_VERSION}.${ZSTD_MAX_VALIDATED_CMAKE_MINOR_VERSION}.0")
+endif()
+cmake_policy(VERSION ${ZSTD_CMAKE_POLICY_VERSION})
+
+set(CMAKE_BUILD_WITH_INSTALL_RPATH on)
+
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
+set(ZSTD_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..")
+set(LIBRARY_DIR ${ZSTD_SOURCE_DIR}/lib)
+# Parse version
+include(GetZstdLibraryVersion)
+GetZstdLibraryVersion(${LIBRARY_DIR}/zstd.h zstd_VERSION_MAJOR zstd_VERSION_MINOR zstd_VERSION_PATCH)
+
+if( CMAKE_MAJOR_VERSION LESS 3 )
+ ## Provide cmake 3+ behavior for older versions of cmake
+ project(zstd)
+ set(PROJECT_VERSION_MAJOR ${zstd_VERSION_MAJOR})
+ set(PROJECT_VERSION_MINOR ${zstd_VERSION_MINOR})
+ set(PROJECT_VERSION_PATCH ${zstd_VERSION_PATCH})
+ set(PROJECT_VERSION "${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH}")
+ enable_language(C) # Main library is in C
+ enable_language(ASM) # And ASM
+ enable_language(CXX) # Testing contributed code also utilizes CXX
+else()
+ project(zstd
+ VERSION "${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH}"
+ LANGUAGES C # Main library is in C
+ ASM # And ASM
+ CXX # Testing contributed code also utilizes CXX
+ )
+endif()
+message(STATUS "ZSTD VERSION: ${zstd_VERSION}")
+set(zstd_HOMEPAGE_URL "https://facebook.github.io/zstd")
+set(zstd_DESCRIPTION "Zstandard is a real-time compression algorithm, providing high compression ratios.")
+
+# Set a default build type if none was specified
+if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
+ message(STATUS "Setting build type to 'Release' as none was specified.")
+ set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
+ # Set the possible values of build type for cmake-gui
+ set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
+endif()
+
+include(GNUInstallDirs)
+
+#-----------------------------------------------------------------------------
+# Add extra compilation flags
+#-----------------------------------------------------------------------------
+include(AddZstdCompilationFlags)
+ADD_ZSTD_COMPILATION_FLAGS()
+
+# Always hide XXHash symbols
+add_definitions(-DXXH_NAMESPACE=ZSTD_)
+
+#-----------------------------------------------------------------------------
+# Installation variables
+#-----------------------------------------------------------------------------
+message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
+message(STATUS "CMAKE_INSTALL_LIBDIR: ${CMAKE_INSTALL_LIBDIR}")
+
+#-----------------------------------------------------------------------------
+# Options
+#-----------------------------------------------------------------------------
+
+# Legacy support
+option(ZSTD_LEGACY_SUPPORT "LEGACY SUPPORT" ON)
+
+if (ZSTD_LEGACY_SUPPORT)
+ message(STATUS "ZSTD_LEGACY_SUPPORT defined!")
+ set(ZSTD_LEGACY_LEVEL 5 CACHE STRING "")
+ add_definitions(-DZSTD_LEGACY_SUPPORT=${ZSTD_LEGACY_LEVEL})
+else ()
+ message(STATUS "ZSTD_LEGACY_SUPPORT not defined!")
+ add_definitions(-DZSTD_LEGACY_SUPPORT=0)
+endif ()
+
+if (ANDROID)
+ set(ZSTD_MULTITHREAD_SUPPORT_DEFAULT OFF)
+else()
+ set(ZSTD_MULTITHREAD_SUPPORT_DEFAULT ON)
+endif()
+
+# Multi-threading support
+option(ZSTD_MULTITHREAD_SUPPORT "MULTITHREADING SUPPORT" ${ZSTD_MULTITHREAD_SUPPORT_DEFAULT})
+
+if (ZSTD_MULTITHREAD_SUPPORT)
+ message(STATUS "ZSTD_MULTITHREAD_SUPPORT is enabled")
+else ()
+ message(STATUS "ZSTD_MULTITHREAD_SUPPORT is disabled")
+endif ()
+
+option(ZSTD_BUILD_PROGRAMS "BUILD PROGRAMS" ON)
+option(ZSTD_BUILD_CONTRIB "BUILD CONTRIB" OFF)
+
+# Respect the conventional CMake option for enabling tests if it was specified on the first configure
+if (BUILD_TESTING)
+ set(ZSTD_BUILD_TESTS_default ON)
+else()
+ set(ZSTD_BUILD_TESTS_default OFF)
+endif()
+option(ZSTD_BUILD_TESTS "BUILD TESTS" ${ZSTD_BUILD_TESTS_default})
+if (MSVC)
+ option(ZSTD_USE_STATIC_RUNTIME "LINK TO STATIC RUN-TIME LIBRARIES" OFF)
+endif ()
+
+#-----------------------------------------------------------------------------
+# External dependencies
+#-----------------------------------------------------------------------------
+if (ZSTD_MULTITHREAD_SUPPORT AND UNIX)
+ set(THREADS_PREFER_PTHREAD_FLAG ON)
+ find_package(Threads REQUIRED)
+ if(CMAKE_USE_PTHREADS_INIT)
+ set(THREADS_LIBS "${CMAKE_THREAD_LIBS_INIT}")
+ else()
+ message(SEND_ERROR "ZSTD currently does not support thread libraries other than pthreads")
+ endif()
+endif ()
+
+#-----------------------------------------------------------------------------
+# Add source directories
+#-----------------------------------------------------------------------------
+add_subdirectory(lib)
+
+option(ZSTD_PROGRAMS_LINK_SHARED "PROGRAMS LINK SHARED" OFF)
+
+if (ZSTD_BUILD_PROGRAMS)
+ if (NOT ZSTD_BUILD_STATIC AND NOT ZSTD_PROGRAMS_LINK_SHARED)
+ message(SEND_ERROR "You need to build static library to build zstd CLI")
+ elseif(NOT ZSTD_BUILD_SHARED AND ZSTD_PROGRAMS_LINK_SHARED)
+ message(SEND_ERROR "You need to build shared library to build zstd CLI")
+ endif ()
+
+ add_subdirectory(programs)
+endif ()
+
+if (ZSTD_BUILD_TESTS)
+ enable_testing()
+ if (NOT ZSTD_BUILD_STATIC)
+ message(SEND_ERROR "You need to build static library to build tests")
+ endif ()
+
+ add_subdirectory(tests)
+endif ()
+
+if (ZSTD_BUILD_CONTRIB)
+ add_subdirectory(contrib)
+endif ()
+
+#-----------------------------------------------------------------------------
+# Add clean-all target
+#-----------------------------------------------------------------------------
+add_custom_target(clean-all
+ COMMAND ${CMAKE_BUILD_TOOL} clean
+ COMMAND rm -rf ${CMAKE_BINARY_DIR}/
+)
+
+#-----------------------------------------------------------------------------
+# Generate Package Config files
+#
+# This section is based on the boiler plate code from:
+# https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-packages
+#-----------------------------------------------------------------------------
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/zstdConfigVersion.cmake"
+ VERSION ${zstd_VERSION}
+ COMPATIBILITY SameMajorVersion
+ )
+
+# A Package Config file that works from the build directory
+export(EXPORT zstdExports
+ FILE "${CMAKE_CURRENT_BINARY_DIR}/zstdTargets.cmake"
+ NAMESPACE zstd::
+ )
+configure_file(zstdConfig.cmake
+ "${CMAKE_CURRENT_BINARY_DIR}/zstdConfig.cmake"
+ COPYONLY
+ )
+
+# A Package Config file that works from the installation directory
+set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/zstd)
+install(EXPORT zstdExports
+ FILE zstdTargets.cmake
+ NAMESPACE zstd::
+ DESTINATION ${ConfigPackageLocation}
+ )
+install(FILES
+ zstdConfig.cmake
+ "${CMAKE_CURRENT_BINARY_DIR}/zstdConfigVersion.cmake"
+ DESTINATION ${ConfigPackageLocation}
+ )
diff --git a/3rdparty/zstd/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake b/3rdparty/zstd/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake
new file mode 100644
index 00000000000..5f179989b68
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake
@@ -0,0 +1,121 @@
+include(CheckCXXCompilerFlag)
+include(CheckCCompilerFlag)
+# VERSION_GREATER_EQUAL requires CMake 3.7 or later.
+# https://cmake.org/cmake/help/latest/command/if.html#version-greater-equal
+if (CMAKE_VERSION VERSION_LESS 3.18)
+ set(ZSTD_HAVE_CHECK_LINKER_FLAG false)
+else ()
+ set(ZSTD_HAVE_CHECK_LINKER_FLAG true)
+endif ()
+if (ZSTD_HAVE_CHECK_LINKER_FLAG)
+ include(CheckLinkerFlag)
+endif()
+
+function(EnableCompilerFlag _flag _C _CXX _LD)
+ string(REGEX REPLACE "\\+" "PLUS" varname "${_flag}")
+ string(REGEX REPLACE "[^A-Za-z0-9]+" "_" varname "${varname}")
+ string(REGEX REPLACE "^_+" "" varname "${varname}")
+ string(TOUPPER "${varname}" varname)
+ if (_C)
+ CHECK_C_COMPILER_FLAG(${_flag} C_FLAG_${varname})
+ if (C_FLAG_${varname})
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_flag}" PARENT_SCOPE)
+ endif ()
+ endif ()
+ if (_CXX)
+ CHECK_CXX_COMPILER_FLAG(${_flag} CXX_FLAG_${varname})
+ if (CXX_FLAG_${varname})
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}" PARENT_SCOPE)
+ endif ()
+ endif ()
+ if (_LD)
+ # We never add a linker flag with CMake < 3.18. We will
+ # implement CHECK_LINKER_FLAG() like feature for CMake < 3.18
+ # or require CMake >= 3.18 when we need to add a required
+ # linker flag in future.
+ #
+ # We also skip linker flags check for MSVC compilers (which includes
+ # clang-cl) since currently check_linker_flag() doesn't give correct
+ # results for this configuration,
+ # see: https://gitlab.kitware.com/cmake/cmake/-/issues/22023
+ if (ZSTD_HAVE_CHECK_LINKER_FLAG AND NOT MSVC)
+ CHECK_LINKER_FLAG(C ${_flag} LD_FLAG_${varname})
+ else ()
+ set(LD_FLAG_${varname} false)
+ endif ()
+ if (LD_FLAG_${varname})
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${_flag}" PARENT_SCOPE)
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${_flag}" PARENT_SCOPE)
+ endif ()
+ endif ()
+endfunction()
+
+macro(ADD_ZSTD_COMPILATION_FLAGS)
+ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" OR MINGW) #Not only UNIX but also WIN32 for MinGW
+ # It's possible to select the exact standard used for compilation.
+ # It's not necessary, but can be employed for specific purposes.
+ # Note that zstd source code is compatible with both C++98 and above
+ # and C-gnu90 (c90 + long long + variadic macros ) and above
+ # EnableCompilerFlag("-std=c++11" false true) # Set C++ compilation to c++11 standard
+ # EnableCompilerFlag("-std=c99" true false) # Set C compiation to c99 standard
+ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND MSVC)
+ # clang-cl normally maps -Wall to -Weverything.
+ EnableCompilerFlag("/clang:-Wall" true true false)
+ else ()
+ EnableCompilerFlag("-Wall" true true false)
+ endif ()
+ EnableCompilerFlag("-Wextra" true true false)
+ EnableCompilerFlag("-Wundef" true true false)
+ EnableCompilerFlag("-Wshadow" true true false)
+ EnableCompilerFlag("-Wcast-align" true true false)
+ EnableCompilerFlag("-Wcast-qual" true true false)
+ EnableCompilerFlag("-Wstrict-prototypes" true false false)
+ # Enable asserts in Debug mode
+ if (CMAKE_BUILD_TYPE MATCHES "Debug")
+ EnableCompilerFlag("-DDEBUGLEVEL=1" true true false)
+ endif ()
+ # Add noexecstack flags
+ # LDFLAGS
+ EnableCompilerFlag("-z noexecstack" false false true)
+ # CFLAGS & CXXFLAGS
+ EnableCompilerFlag("-Qunused-arguments" true true false)
+ EnableCompilerFlag("-Wa,--noexecstack" true true false)
+ elseif (MSVC) # Add specific compilation flags for Windows Visual
+
+ set(ACTIVATE_MULTITHREADED_COMPILATION "ON" CACHE BOOL "activate multi-threaded compilation (/MP flag)")
+ if (CMAKE_GENERATOR MATCHES "Visual Studio" AND ACTIVATE_MULTITHREADED_COMPILATION)
+ EnableCompilerFlag("/MP" true true false)
+ endif ()
+
+ # UNICODE SUPPORT
+ EnableCompilerFlag("/D_UNICODE" true true false)
+ EnableCompilerFlag("/DUNICODE" true true false)
+ # Enable asserts in Debug mode
+ if (CMAKE_BUILD_TYPE MATCHES "Debug")
+ EnableCompilerFlag("/DDEBUGLEVEL=1" true true false)
+ endif ()
+ endif ()
+
+ # Remove duplicates compilation flags
+ foreach (flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
+ CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
+ CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+ if( ${flag_var} )
+ separate_arguments(${flag_var})
+ string(REPLACE ";" " " ${flag_var} "${${flag_var}}")
+ endif()
+ endforeach ()
+
+ if (MSVC AND ZSTD_USE_STATIC_RUNTIME)
+ foreach (flag_var CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
+ CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
+ CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+ if ( ${flag_var} )
+ string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
+ endif()
+ endforeach ()
+ endif ()
+
+endmacro()
diff --git a/3rdparty/zstd/build/cmake/CMakeModules/FindLibLZ4.cmake b/3rdparty/zstd/build/cmake/CMakeModules/FindLibLZ4.cmake
new file mode 100644
index 00000000000..d0fac06da1b
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/CMakeModules/FindLibLZ4.cmake
@@ -0,0 +1,49 @@
+# Find LibLZ4
+#
+# Find LibLZ4 headers and library
+#
+# Result Variables
+#
+# LIBLZ4_FOUND - True if lz4 is found
+# LIBLZ4_INCLUDE_DIRS - lz4 headers directories
+# LIBLZ4_LIBRARIES - lz4 libraries
+# LIBLZ4_VERSION_MAJOR - The major version of lz4
+# LIBLZ4_VERSION_MINOR - The minor version of lz4
+# LIBLZ4_VERSION_RELEASE - The release version of lz4
+# LIBLZ4_VERSION_STRING - version number string (e.g. 1.8.3)
+#
+# Hints
+#
+# Set ``LZ4_ROOT_DIR`` to the directory of lz4.h and lz4 library
+
+set(_LIBLZ4_ROOT_HINTS
+ ENV LZ4_ROOT_DIR)
+
+find_path( LIBLZ4_INCLUDE_DIR lz4.h
+ HINTS ${_LIBLZ4_ROOT_HINTS})
+find_library( LIBLZ4_LIBRARY NAMES lz4 liblz4 liblz4_static
+ HINTS ${_LIBLZ4_ROOT_HINTS})
+
+if(LIBLZ4_INCLUDE_DIR)
+ file(STRINGS "${LIBLZ4_INCLUDE_DIR}/lz4.h" LIBLZ4_HEADER_CONTENT REGEX "#define LZ4_VERSION_[A-Z]+ +[0-9]+")
+
+ string(REGEX REPLACE ".*#define LZ4_VERSION_MAJOR +([0-9]+).*" "\\1" LIBLZ4_VERSION_MAJOR "${LIBLZ4_HEADER_CONTENT}")
+ string(REGEX REPLACE ".*#define LZ4_VERSION_MINOR +([0-9]+).*" "\\1" LIBLZ4_VERSION_MINOR "${LIBLZ4_HEADER_CONTENT}")
+ string(REGEX REPLACE ".*#define LZ4_VERSION_RELEASE +([0-9]+).*" "\\1" LIBLZ4_VERSION_RELEASE "${LIBLZ4_HEADER_CONTENT}")
+
+ set(LIBLZ4_VERSION_STRING "${LIBLZ4_VERSION_MAJOR}.${LIBLZ4_VERSION_MINOR}.${LIBLZ4_VERSION_RELEASE}")
+ unset(LIBLZ4_HEADER_CONTENT)
+endif()
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibLZ4 REQUIRED_VARS LIBLZ4_INCLUDE_DIR
+ LIBLZ4_LIBRARY
+ VERSION_VAR LIBLZ4_VERSION_STRING
+ FAIL_MESSAGE "Could NOT find LZ4, try to set the paths to lz4.h and lz4 library in environment variable LZ4_ROOT_DIR")
+
+if (LIBLZ4_FOUND)
+ set(LIBLZ4_LIBRARIES ${LIBLZ4_LIBRARY})
+ set(LIBLZ4_INCLUDE_DIRS ${LIBLZ4_INCLUDE_DIR})
+endif ()
+
+mark_as_advanced( LIBLZ4_INCLUDE_DIR LIBLZ4_LIBRARY )
diff --git a/3rdparty/zstd/build/cmake/CMakeModules/GetZstdLibraryVersion.cmake b/3rdparty/zstd/build/cmake/CMakeModules/GetZstdLibraryVersion.cmake
new file mode 100644
index 00000000000..e8ed6064c96
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/CMakeModules/GetZstdLibraryVersion.cmake
@@ -0,0 +1,10 @@
+function(GetZstdLibraryVersion _header _major _minor _patch)
+ # Read file content
+ file(READ ${_header} CONTENT)
+
+ string(REGEX MATCH ".*define ZSTD_VERSION_MAJOR *([0-9]+).*define ZSTD_VERSION_MINOR *([0-9]+).*define ZSTD_VERSION_RELEASE *([0-9]+)" VERSION_REGEX "${CONTENT}")
+ set(${_major} ${CMAKE_MATCH_1} PARENT_SCOPE)
+ set(${_minor} ${CMAKE_MATCH_2} PARENT_SCOPE)
+ set(${_patch} ${CMAKE_MATCH_3} PARENT_SCOPE)
+endfunction()
+
diff --git a/3rdparty/zstd/build/cmake/CMakeModules/JoinPaths.cmake b/3rdparty/zstd/build/cmake/CMakeModules/JoinPaths.cmake
new file mode 100644
index 00000000000..c68d91b84db
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/CMakeModules/JoinPaths.cmake
@@ -0,0 +1,23 @@
+# This module provides function for joining paths
+# known from most languages
+#
+# SPDX-License-Identifier: (MIT OR CC0-1.0)
+# Copyright 2020 Jan Tojnar
+# https://github.com/jtojnar/cmake-snips
+#
+# Modelled after Python’s os.path.join
+# https://docs.python.org/3.7/library/os.path.html#os.path.join
+# Windows not supported
+function(join_paths joined_path first_path_segment)
+ set(temp_path "${first_path_segment}")
+ foreach(current_segment IN LISTS ARGN)
+ if(NOT ("${current_segment}" STREQUAL ""))
+ if(IS_ABSOLUTE "${current_segment}")
+ set(temp_path "${current_segment}")
+ else()
+ set(temp_path "${temp_path}/${current_segment}")
+ endif()
+ endif()
+ endforeach()
+ set(${joined_path} "${temp_path}" PARENT_SCOPE)
+endfunction()
diff --git a/3rdparty/zstd/build/cmake/README.md b/3rdparty/zstd/build/cmake/README.md
new file mode 100644
index 00000000000..a460dd16187
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/README.md
@@ -0,0 +1,104 @@
+# Cmake contributions
+
+Contributions to the cmake build configurations are welcome. Please
+use case sensitivity that matches modern (i.e. cmake version 2.6 and above)
+conventions of using lower-case for commands, and upper-case for
+variables.
+
+## How to build
+
+As cmake doesn't support command like `cmake clean`, it's recommended to perform an "out of source build".
+To do this, you can create a new directory and build in it:
+```sh
+cd build/cmake
+mkdir builddir
+cd builddir
+cmake ..
+make
+```
+Then you can clean all cmake caches by simply delete the new directory:
+```sh
+rm -rf build/cmake/builddir
+```
+
+And of course, you can directly build in build/cmake:
+```sh
+cd build/cmake
+cmake
+make
+```
+
+To show cmake build options, you can:
+```sh
+cd build/cmake/builddir
+cmake -LH ..
+```
+
+Bool options can be set to `ON/OFF` with `-D[option]=[ON/OFF]`. You can configure cmake options like this:
+```sh
+cd build/cmake/builddir
+cmake -DZSTD_BUILD_TESTS=ON -DZSTD_LEGACY_SUPPORT=OFF ..
+make
+```
+
+### referring
+[Looking for a 'cmake clean' command to clear up CMake output](https://stackoverflow.com/questions/9680420/looking-for-a-cmake-clean-command-to-clear-up-cmake-output)
+
+## CMake Style Recommendations
+
+### Indent all code correctly, i.e. the body of
+
+ * if/else/endif
+ * foreach/endforeach
+ * while/endwhile
+ * macro/endmacro
+ * function/endfunction
+
+Use spaces for indenting, 2, 3 or 4 spaces preferably. Use the same amount of
+spaces for indenting as is used in the rest of the file. Do not use tabs.
+
+### Upper/lower casing
+
+Most important: use consistent upper- or lowercasing within one file !
+
+In general, the all-lowercase style is preferred.
+
+So, this is recommended:
+
+```
+add_executable(foo foo.c)
+```
+
+These forms are discouraged
+
+```
+ADD_EXECUTABLE(bar bar.c)
+Add_Executable(hello hello.c)
+aDd_ExEcUtAbLe(blub blub.c)
+```
+
+### End commands
+To make the code easier to read, use empty commands for endforeach(), endif(),
+endfunction(), endmacro() and endwhile(). Also, use empty else() commands.
+
+For example, do this:
+
+```
+if(FOOVAR)
+ some_command(...)
+else()
+ another_command(...)
+endif()
+```
+
+and not this:
+
+```
+if(BARVAR)
+ some_other_command(...)
+endif(BARVAR)
+```
+
+### Other resources for best practices
+
+https://cmake.org/cmake/help/latest/manual/cmake-developer.7.html#modules
diff --git a/3rdparty/zstd/build/cmake/contrib/CMakeLists.txt b/3rdparty/zstd/build/cmake/contrib/CMakeLists.txt
new file mode 100644
index 00000000000..8df2a17b3a8
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/contrib/CMakeLists.txt
@@ -0,0 +1,13 @@
+# ################################################################
+# Copyright (c) Meta Platforms, Inc. and affiliates.
+# All rights reserved.
+#
+# This source code is licensed under both the BSD-style license (found in the
+# LICENSE file in the root directory of this source tree) and the GPLv2 (found
+# in the COPYING file in the root directory of this source tree).
+# ################################################################
+
+project(contrib)
+
+add_subdirectory(pzstd)
+add_subdirectory(gen_html)
diff --git a/3rdparty/zstd/build/cmake/contrib/gen_html/CMakeLists.txt b/3rdparty/zstd/build/cmake/contrib/gen_html/CMakeLists.txt
new file mode 100644
index 00000000000..d1ff6c64bba
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/contrib/gen_html/CMakeLists.txt
@@ -0,0 +1,30 @@
+# ################################################################
+# Copyright (c) Meta Platforms, Inc. and affiliates.
+# All rights reserved.
+#
+# This source code is licensed under both the BSD-style license (found in the
+# LICENSE file in the root directory of this source tree) and the GPLv2 (found
+# in the COPYING file in the root directory of this source tree).
+# ################################################################
+
+project(gen_html)
+include(GetZstdLibraryVersion)
+
+set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
+
+# Define programs directory, where sources and header files are located
+set(LIBRARY_DIR ${ZSTD_SOURCE_DIR}/lib)
+set(PROGRAMS_DIR ${ZSTD_SOURCE_DIR}/programs)
+set(GENHTML_DIR ${ZSTD_SOURCE_DIR}/contrib/gen_html)
+set(GENHTML_BINARY ${PROJECT_BINARY_DIR}/gen_html${CMAKE_EXECUTABLE_SUFFIX})
+include_directories(${PROGRAMS_DIR} ${LIBRARY_DIR} ${LIBRARY_DIR}/common ${GENHTML_DIR})
+
+add_executable(gen_html ${GENHTML_DIR}/gen_html.cpp)
+
+GetZstdLibraryVersion(${LIBRARY_DIR}/zstd.h VMAJOR VMINOR VRELEASE)
+set(LIBVERSION "${VMAJOR}.${VMINOR}.${VRELEASE}")
+add_custom_target(zstd_manual.html ALL
+ ${GENHTML_BINARY} "${LIBVERSION}" "${LIBRARY_DIR}/zstd.h" "${PROJECT_BINARY_DIR}/zstd_manual.html"
+ DEPENDS gen_html COMMENT "Update zstd manual")
+
+install(FILES "${PROJECT_BINARY_DIR}/zstd_manual.html" DESTINATION "${CMAKE_INSTALL_DOCDIR}")
diff --git a/3rdparty/zstd/build/cmake/contrib/pzstd/CMakeLists.txt b/3rdparty/zstd/build/cmake/contrib/pzstd/CMakeLists.txt
new file mode 100644
index 00000000000..f7098fa0f7f
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/contrib/pzstd/CMakeLists.txt
@@ -0,0 +1,38 @@
+# ################################################################
+# Copyright (c) Meta Platforms, Inc. and affiliates.
+# All rights reserved.
+#
+# This source code is licensed under both the BSD-style license (found in the
+# LICENSE file in the root directory of this source tree) and the GPLv2 (found
+# in the COPYING file in the root directory of this source tree).
+# ################################################################
+
+project(pzstd)
+
+set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
+
+# Define programs directory, where sources and header files are located
+set(LIBRARY_DIR ${ZSTD_SOURCE_DIR}/lib)
+set(PROGRAMS_DIR ${ZSTD_SOURCE_DIR}/programs)
+set(PZSTD_DIR ${ZSTD_SOURCE_DIR}/contrib/pzstd)
+include_directories(${PROGRAMS_DIR} ${LIBRARY_DIR} ${LIBRARY_DIR}/common ${PZSTD_DIR})
+
+add_executable(pzstd ${PROGRAMS_DIR}/util.c ${PZSTD_DIR}/main.cpp ${PZSTD_DIR}/Options.cpp ${PZSTD_DIR}/Pzstd.cpp ${PZSTD_DIR}/SkippableFrame.cpp)
+set_property(TARGET pzstd APPEND PROPERTY COMPILE_DEFINITIONS "NDEBUG")
+set_property(TARGET pzstd APPEND PROPERTY COMPILE_OPTIONS "-Wno-shadow")
+
+if (ZSTD_BUILD_SHARED)
+ set(ZSTD_LIB libzstd_shared)
+else()
+ set(ZSTD_LIB libzstd_static)
+endif()
+
+set(THREADS_PREFER_PTHREAD_FLAG ON)
+find_package(Threads REQUIRED)
+if (CMAKE_USE_PTHREADS_INIT)
+ target_link_libraries(pzstd ${ZSTD_LIB} ${CMAKE_THREAD_LIBS_INIT})
+else()
+ message(SEND_ERROR "ZSTD currently does not support thread libraries other than pthreads")
+endif()
+
+install(TARGETS pzstd RUNTIME DESTINATION "bin")
diff --git a/3rdparty/zstd/build/cmake/lib/.gitignore b/3rdparty/zstd/build/cmake/lib/.gitignore
new file mode 100644
index 00000000000..a4444c8d3ed
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/lib/.gitignore
@@ -0,0 +1,2 @@
+# cmake build artefact
+libzstd.pc
diff --git a/3rdparty/zstd/build/cmake/lib/CMakeLists.txt b/3rdparty/zstd/build/cmake/lib/CMakeLists.txt
new file mode 100644
index 00000000000..30349586ba9
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/lib/CMakeLists.txt
@@ -0,0 +1,181 @@
+# ################################################################
+# Copyright (c) Meta Platforms, Inc. and affiliates.
+# All rights reserved.
+#
+# This source code is licensed under both the BSD-style license (found in the
+# LICENSE file in the root directory of this source tree) and the GPLv2 (found
+# in the COPYING file in the root directory of this source tree).
+# ################################################################
+
+project(libzstd C ASM)
+
+set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
+option(ZSTD_BUILD_STATIC "BUILD STATIC LIBRARIES" ON)
+option(ZSTD_BUILD_SHARED "BUILD SHARED LIBRARIES" ON)
+
+if(NOT ZSTD_BUILD_SHARED AND NOT ZSTD_BUILD_STATIC)
+ message(SEND_ERROR "You need to build at least one flavor of libzstd")
+endif()
+
+# Define library directory, where sources and header files are located
+include_directories(${LIBRARY_DIR} ${LIBRARY_DIR}/common)
+
+file(GLOB CommonSources ${LIBRARY_DIR}/common/*.c)
+file(GLOB CompressSources ${LIBRARY_DIR}/compress/*.c)
+if (MSVC)
+ file(GLOB DecompressSources ${LIBRARY_DIR}/decompress/*.c)
+ add_compile_options(-DZSTD_DISABLE_ASM)
+else ()
+ file(GLOB DecompressSources ${LIBRARY_DIR}/decompress/*.c ${LIBRARY_DIR}/decompress/*.S)
+endif ()
+file(GLOB DictBuilderSources ${LIBRARY_DIR}/dictBuilder/*.c)
+
+set(Sources
+ ${CommonSources}
+ ${CompressSources}
+ ${DecompressSources}
+ ${DictBuilderSources})
+
+file(GLOB CommonHeaders ${LIBRARY_DIR}/common/*.h)
+file(GLOB CompressHeaders ${LIBRARY_DIR}/compress/*.h)
+file(GLOB DecompressHeaders ${LIBRARY_DIR}/decompress/*.h)
+file(GLOB DictBuilderHeaders ${LIBRARY_DIR}/dictBuilder/*.h)
+
+set(Headers
+ ${LIBRARY_DIR}/zstd.h
+ ${CommonHeaders}
+ ${CompressHeaders}
+ ${DecompressHeaders}
+ ${DictBuilderHeaders})
+
+if (ZSTD_LEGACY_SUPPORT)
+ set(LIBRARY_LEGACY_DIR ${LIBRARY_DIR}/legacy)
+ include_directories(${LIBRARY_LEGACY_DIR})
+
+ set(Sources ${Sources}
+ ${LIBRARY_LEGACY_DIR}/zstd_v01.c
+ ${LIBRARY_LEGACY_DIR}/zstd_v02.c
+ ${LIBRARY_LEGACY_DIR}/zstd_v03.c
+ ${LIBRARY_LEGACY_DIR}/zstd_v04.c
+ ${LIBRARY_LEGACY_DIR}/zstd_v05.c
+ ${LIBRARY_LEGACY_DIR}/zstd_v06.c
+ ${LIBRARY_LEGACY_DIR}/zstd_v07.c)
+
+ set(Headers ${Headers}
+ ${LIBRARY_LEGACY_DIR}/zstd_legacy.h
+ ${LIBRARY_LEGACY_DIR}/zstd_v01.h
+ ${LIBRARY_LEGACY_DIR}/zstd_v02.h
+ ${LIBRARY_LEGACY_DIR}/zstd_v03.h
+ ${LIBRARY_LEGACY_DIR}/zstd_v04.h
+ ${LIBRARY_LEGACY_DIR}/zstd_v05.h
+ ${LIBRARY_LEGACY_DIR}/zstd_v06.h
+ ${LIBRARY_LEGACY_DIR}/zstd_v07.h)
+endif ()
+
+if (MSVC)
+ set(MSVC_RESOURCE_DIR ${ZSTD_SOURCE_DIR}/build/VS2010/libzstd-dll)
+ set(PlatformDependResources ${MSVC_RESOURCE_DIR}/libzstd-dll.rc)
+endif ()
+
+# Explicitly set the language to C for all files, including ASM files.
+# Our assembly expects to be compiled by a C compiler, and is only enabled for
+# __GNUC__ compatible compilers. Otherwise all the ASM code is disabled by
+# macros.
+set_source_files_properties(${Sources} PROPERTIES LANGUAGE C)
+
+# Split project to static and shared libraries build
+set(library_targets)
+if (ZSTD_BUILD_SHARED)
+ add_library(libzstd_shared SHARED ${Sources} ${Headers} ${PlatformDependResources})
+ list(APPEND library_targets libzstd_shared)
+ if (ZSTD_MULTITHREAD_SUPPORT)
+ set_property(TARGET libzstd_shared APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD")
+ if (UNIX)
+ target_link_libraries(libzstd_shared ${THREADS_LIBS})
+ endif ()
+ endif()
+endif ()
+if (ZSTD_BUILD_STATIC)
+ add_library(libzstd_static STATIC ${Sources} ${Headers})
+ list(APPEND library_targets libzstd_static)
+ if (ZSTD_MULTITHREAD_SUPPORT)
+ set_property(TARGET libzstd_static APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD")
+ if (UNIX)
+ target_link_libraries(libzstd_static ${THREADS_LIBS})
+ endif ()
+ endif ()
+endif ()
+
+# Add specific compile definitions for MSVC project
+if (MSVC)
+ if (ZSTD_BUILD_SHARED)
+ set_property(TARGET libzstd_shared APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_DLL_EXPORT=1;ZSTD_HEAPMODE=0;_CONSOLE;_CRT_SECURE_NO_WARNINGS")
+ endif ()
+ if (ZSTD_BUILD_STATIC)
+ set_property(TARGET libzstd_static APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_HEAPMODE=0;_CRT_SECURE_NO_WARNINGS")
+ endif ()
+endif ()
+
+# With MSVC static library needs to be renamed to avoid conflict with import library
+if (MSVC OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT MINGW))
+ set(STATIC_LIBRARY_BASE_NAME zstd_static)
+else ()
+ set(STATIC_LIBRARY_BASE_NAME zstd)
+endif ()
+
+# Define static and shared library names
+if (ZSTD_BUILD_SHARED)
+ set_target_properties(
+ libzstd_shared
+ PROPERTIES
+ OUTPUT_NAME zstd
+ VERSION ${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH}
+ SOVERSION ${zstd_VERSION_MAJOR})
+endif ()
+
+if (ZSTD_BUILD_STATIC)
+ set_target_properties(
+ libzstd_static
+ PROPERTIES
+ POSITION_INDEPENDENT_CODE On
+ OUTPUT_NAME ${STATIC_LIBRARY_BASE_NAME})
+endif ()
+
+# pkg-config
+include(JoinPaths) # can be replaced by cmake_path(APPEND) in CMake 3.20
+set(PREFIX "${CMAKE_INSTALL_PREFIX}")
+set(EXEC_PREFIX "\${prefix}")
+join_paths(LIBDIR "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}")
+join_paths(INCLUDEDIR "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
+set(LIBS_PRIVATE "${THREADS_LIBS}")
+set(VERSION "${zstd_VERSION}")
+
+configure_file("${LIBRARY_DIR}/libzstd.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libzstd.pc" @ONLY)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libzstd.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+
+# install target
+install(FILES
+ "${LIBRARY_DIR}/zstd.h"
+ "${LIBRARY_DIR}/zdict.h"
+ "${LIBRARY_DIR}/zstd_errors.h"
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
+
+install(TARGETS ${library_targets}
+ EXPORT zstdExports
+ INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ )
+
+# uninstall target
+if (NOT TARGET uninstall)
+ configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+ IMMEDIATE @ONLY)
+
+ add_custom_target(uninstall
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
+endif ()
diff --git a/3rdparty/zstd/build/cmake/lib/cmake_uninstall.cmake.in b/3rdparty/zstd/build/cmake/lib/cmake_uninstall.cmake.in
new file mode 100644
index 00000000000..9f1d045ddfa
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/lib/cmake_uninstall.cmake.in
@@ -0,0 +1,22 @@
+
+if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
+ message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
+endif()
+
+file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
+string(REGEX REPLACE "\n" ";" files "${files}")
+foreach(file ${files})
+ message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
+ if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ exec_program(
+ "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+ OUTPUT_VARIABLE rm_out
+ RETURN_VALUE rm_retval
+ )
+ if(NOT "${rm_retval}" STREQUAL 0)
+ message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
+ endif()
+ else()
+ message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
+ endif()
+endforeach()
diff --git a/3rdparty/zstd/build/cmake/programs/.gitignore b/3rdparty/zstd/build/cmake/programs/.gitignore
new file mode 100644
index 00000000000..ae3a8a356a1
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/programs/.gitignore
@@ -0,0 +1,5 @@
+# produced by make
+zstd
+zstd-frugal
+unzstd
+zstdcat
diff --git a/3rdparty/zstd/build/cmake/programs/CMakeLists.txt b/3rdparty/zstd/build/cmake/programs/CMakeLists.txt
new file mode 100644
index 00000000000..58d998e4275
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/programs/CMakeLists.txt
@@ -0,0 +1,137 @@
+# ################################################################
+# Copyright (c) Meta Platforms, Inc. and affiliates.
+# All rights reserved.
+#
+# This source code is licensed under both the BSD-style license (found in the
+# LICENSE file in the root directory of this source tree) and the GPLv2 (found
+# in the COPYING file in the root directory of this source tree).
+# ################################################################
+
+project(programs C)
+
+set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
+
+# Define programs directory, where sources and header files are located
+set(LIBRARY_DIR ${ZSTD_SOURCE_DIR}/lib)
+set(PROGRAMS_DIR ${ZSTD_SOURCE_DIR}/programs)
+include_directories(${PROGRAMS_DIR} ${LIBRARY_DIR} ${LIBRARY_DIR}/common ${LIBRARY_DIR}/compress ${LIBRARY_DIR}/dictBuilder)
+
+if (ZSTD_LEGACY_SUPPORT)
+ set(PROGRAMS_LEGACY_DIR ${PROGRAMS_DIR}/legacy)
+ include_directories(${PROGRAMS_LEGACY_DIR} ${LIBRARY_DIR}/legacy)
+endif ()
+
+if (ZSTD_PROGRAMS_LINK_SHARED)
+ set(PROGRAMS_ZSTD_LINK_TARGET libzstd_shared)
+else ()
+ set(PROGRAMS_ZSTD_LINK_TARGET libzstd_static)
+endif ()
+
+if (MSVC)
+ set(MSVC_RESOURCE_DIR ${ZSTD_SOURCE_DIR}/build/VS2010/zstd)
+ set(PlatformDependResources ${MSVC_RESOURCE_DIR}/zstd.rc)
+endif ()
+
+add_executable(zstd ${PROGRAMS_DIR}/zstdcli.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${PROGRAMS_DIR}/fileio.c ${PROGRAMS_DIR}/fileio_asyncio.c ${PROGRAMS_DIR}/benchfn.c ${PROGRAMS_DIR}/benchzstd.c ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/dibio.c ${PROGRAMS_DIR}/zstdcli_trace.c ${PlatformDependResources})
+target_link_libraries(zstd ${PROGRAMS_ZSTD_LINK_TARGET})
+if (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
+ target_link_libraries(zstd rt)
+endif ()
+install(TARGETS zstd
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}")
+
+if (UNIX)
+ add_custom_target(zstdcat ALL ${CMAKE_COMMAND} -E create_symlink zstd zstdcat DEPENDS zstd COMMENT "Creating zstdcat symlink")
+ add_custom_target(unzstd ALL ${CMAKE_COMMAND} -E create_symlink zstd unzstd DEPENDS zstd COMMENT "Creating unzstd symlink")
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zstdcat DESTINATION "${CMAKE_INSTALL_BINDIR}")
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unzstd DESTINATION "${CMAKE_INSTALL_BINDIR}")
+ install(PROGRAMS ${PROGRAMS_DIR}/zstdgrep DESTINATION "${CMAKE_INSTALL_BINDIR}")
+ install(PROGRAMS ${PROGRAMS_DIR}/zstdless DESTINATION "${CMAKE_INSTALL_BINDIR}")
+
+ add_custom_target(zstd.1 ALL
+ ${CMAKE_COMMAND} -E copy ${PROGRAMS_DIR}/zstd.1 .
+ COMMENT "Copying manpage zstd.1")
+ add_custom_target(zstdgrep.1 ALL
+ ${CMAKE_COMMAND} -E copy ${PROGRAMS_DIR}/zstdgrep.1 .
+ COMMENT "Copying manpage zstdgrep.1")
+ add_custom_target(zstdless.1 ALL
+ ${CMAKE_COMMAND} -E copy ${PROGRAMS_DIR}/zstdless.1 .
+ COMMENT "Copying manpage zstdless.1")
+ add_custom_target(zstdcat.1 ALL ${CMAKE_COMMAND} -E create_symlink zstd.1 zstdcat.1 DEPENDS zstd.1 COMMENT "Creating zstdcat.1 symlink")
+ add_custom_target(unzstd.1 ALL ${CMAKE_COMMAND} -E create_symlink zstd.1 unzstd.1 DEPENDS zstd.1 COMMENT "Creating unzstd.1 symlink")
+
+ # Define MAN_INSTALL_DIR if necessary
+ if (MAN_INSTALL_DIR)
+ else ()
+ set(MAN_INSTALL_DIR ${CMAKE_INSTALL_MANDIR}/man1)
+ endif ()
+
+ install(FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/zstd.1
+ ${CMAKE_CURRENT_BINARY_DIR}/zstdcat.1
+ ${CMAKE_CURRENT_BINARY_DIR}/unzstd.1
+ ${CMAKE_CURRENT_BINARY_DIR}/zstdgrep.1
+ ${CMAKE_CURRENT_BINARY_DIR}/zstdless.1
+ DESTINATION "${MAN_INSTALL_DIR}")
+
+ add_executable(zstd-frugal ${PROGRAMS_DIR}/zstdcli.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${PROGRAMS_DIR}/fileio.c ${PROGRAMS_DIR}/fileio_asyncio.c)
+ target_link_libraries(zstd-frugal ${PROGRAMS_ZSTD_LINK_TARGET})
+ set_property(TARGET zstd-frugal APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_NOBENCH;ZSTD_NODICT;ZSTD_NOTRACE")
+endif ()
+
+# Add multi-threading support definitions
+
+if (ZSTD_MULTITHREAD_SUPPORT)
+ set_property(TARGET zstd APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD")
+
+ if (UNIX)
+ target_link_libraries(zstd ${THREADS_LIBS})
+
+ add_custom_target(zstdmt ALL ${CMAKE_COMMAND} -E create_symlink zstd zstdmt DEPENDS zstd COMMENT "Creating zstdmt symlink")
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zstdmt DESTINATION "${CMAKE_INSTALL_BINDIR}")
+ endif ()
+endif ()
+
+option(ZSTD_ZLIB_SUPPORT "ZLIB SUPPORT" OFF)
+option(ZSTD_LZMA_SUPPORT "LZMA SUPPORT" OFF)
+option(ZSTD_LZ4_SUPPORT "LZ4 SUPPORT" OFF)
+
+# Add gzip support
+if (ZSTD_ZLIB_SUPPORT)
+ find_package(ZLIB REQUIRED)
+
+ if (ZLIB_FOUND)
+ include_directories(${ZLIB_INCLUDE_DIRS})
+ target_link_libraries(zstd ${ZLIB_LIBRARIES})
+ set_property(TARGET zstd APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_GZCOMPRESS;ZSTD_GZDECOMPRESS")
+ else ()
+ message(SEND_ERROR "zlib library is missing")
+ endif ()
+endif ()
+
+# Add lzma support
+if (ZSTD_LZMA_SUPPORT)
+ find_package(LibLZMA REQUIRED)
+
+ if (LIBLZMA_FOUND)
+ include_directories(${LIBLZMA_INCLUDE_DIRS})
+ target_link_libraries(zstd ${LIBLZMA_LIBRARIES})
+ set_property(TARGET zstd APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_LZMACOMPRESS;ZSTD_LZMADECOMPRESS")
+ else ()
+ message(SEND_ERROR "lzma library is missing")
+ endif ()
+endif ()
+
+# Add lz4 support
+if (ZSTD_LZ4_SUPPORT)
+ find_package(LibLZ4 REQUIRED)
+
+ if (LIBLZ4_FOUND)
+ include_directories(${LIBLZ4_INCLUDE_DIRS})
+ target_link_libraries(zstd ${LIBLZ4_LIBRARIES})
+ set_property(TARGET zstd APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_LZ4COMPRESS;ZSTD_LZ4DECOMPRESS")
+ else ()
+ message(SEND_ERROR "lz4 library is missing")
+ endif ()
+endif ()
diff --git a/3rdparty/zstd/build/cmake/tests/.gitignore b/3rdparty/zstd/build/cmake/tests/.gitignore
new file mode 100644
index 00000000000..ca2947f61f3
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/tests/.gitignore
@@ -0,0 +1,6 @@
+# produced by make
+datagen
+fullbench
+fuzzer
+paramgrill
+
diff --git a/3rdparty/zstd/build/cmake/tests/CMakeLists.txt b/3rdparty/zstd/build/cmake/tests/CMakeLists.txt
new file mode 100644
index 00000000000..250f0508f37
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/tests/CMakeLists.txt
@@ -0,0 +1,118 @@
+# ################################################################
+# zstd - Makefile
+# Copyright (c) Meta Platforms, Inc. and affiliates.
+# All rights reserved.
+#
+# BSD license
+#
+# Redistribution and use in source and binary forms, with or without modification,
+# are permitted provided that the following conditions are met:
+#
+# * Redistributions of source code must retain the above copyright notice, this
+# list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright notice, this
+# list of conditions and the following disclaimer in the documentation and/or
+# other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# You can contact the author at :
+# - zstd homepage : https://facebook.github.io/zstd/
+# ################################################################
+
+project(tests)
+
+# name: Cache variable name. The value is expected to be a semicolon-separated
+# list of command line flags
+# default_value: Value to initialize the option with. Can be space separated.
+function(AddTestFlagsOption name default_value doc)
+ string(STRIP "${default_value}" default_value)
+ string(REGEX REPLACE " +" ";" default_value "${default_value}")
+ set(${name} ${default_value} CACHE STRING "${doc}")
+ mark_as_advanced(${name})
+endfunction()
+
+set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
+
+# Define programs directory, where sources and header files are located
+set(LIBRARY_DIR ${ZSTD_SOURCE_DIR}/lib)
+set(PROGRAMS_DIR ${ZSTD_SOURCE_DIR}/programs)
+set(TESTS_DIR ${ZSTD_SOURCE_DIR}/tests)
+include_directories(${TESTS_DIR} ${PROGRAMS_DIR} ${LIBRARY_DIR} ${LIBRARY_DIR}/common ${LIBRARY_DIR}/compress ${LIBRARY_DIR}/dictBuilder)
+
+add_executable(datagen ${PROGRAMS_DIR}/datagen.c ${TESTS_DIR}/datagencli.c)
+target_link_libraries(datagen libzstd_static)
+
+#
+# fullbench
+#
+add_executable(fullbench ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${PROGRAMS_DIR}/benchfn.c ${PROGRAMS_DIR}/benchzstd.c ${TESTS_DIR}/fullbench.c)
+if (NOT MSVC)
+ target_compile_options(fullbench PRIVATE "-Wno-deprecated-declarations")
+endif()
+target_link_libraries(fullbench libzstd_static)
+add_test(NAME fullbench COMMAND fullbench ${ZSTD_FULLBENCH_FLAGS})
+
+#
+# fuzzer
+#
+add_executable(fuzzer ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${TESTS_DIR}/fuzzer.c)
+if (NOT MSVC)
+ target_compile_options(fuzzer PRIVATE "-Wno-deprecated-declarations")
+endif()
+target_link_libraries(fuzzer libzstd_static)
+AddTestFlagsOption(ZSTD_FUZZER_FLAGS "$ENV{FUZZERTEST} $ENV{FUZZER_FLAGS}"
+ "Semicolon-separated list of flags to pass to the fuzzer test (see `fuzzer -h` for usage)")
+add_test(NAME fuzzer COMMAND fuzzer ${ZSTD_FUZZER_FLAGS})
+# Disable the timeout since the run time is too long for the default timeout of
+# 1500 seconds and varies considerably between low-end and high-end CPUs.
+# set_tests_properties(fuzzer PROPERTIES TIMEOUT 0)
+
+#
+# zstreamtest
+#
+add_executable(zstreamtest ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${TESTS_DIR}/seqgen.c ${TESTS_DIR}/zstreamtest.c ${TESTS_DIR}/external_matchfinder.c)
+if (NOT MSVC)
+ target_compile_options(zstreamtest PRIVATE "-Wno-deprecated-declarations")
+endif()
+target_link_libraries(zstreamtest libzstd_static)
+AddTestFlagsOption(ZSTD_ZSTREAM_FLAGS "$ENV{ZSTREAM_TESTTIME} $ENV{FUZZER_FLAGS}"
+ "Semicolon-separated list of flags to pass to the zstreamtest test (see `zstreamtest -h` for usage)")
+add_test(NAME zstreamtest COMMAND zstreamtest ${ZSTD_ZSTREAM_FLAGS})
+
+#
+# playTests.sh
+#
+AddTestFlagsOption(ZSTD_PLAYTESTS_FLAGS "$ENV{PLAYTESTS_FLAGS}"
+ "Semicolon-separated list of flags to pass to the playTests.sh test")
+add_test(NAME playTests COMMAND sh -c "\"${TESTS_DIR}/playTests.sh\" ${ZSTD_PLAYTESTS_FLAGS}")
+find_program(UNAME uname) # Run script only in unix shell environments
+if (ZSTD_BUILD_PROGRAMS AND UNAME)
+ set_property(TEST playTests APPEND PROPERTY ENVIRONMENT
+ "ZSTD_BIN=$<TARGET_FILE:zstd>"
+ "DATAGEN_BIN=$<TARGET_FILE:datagen>"
+ )
+else()
+ message(STATUS "Disabling playTests.sh test because requirements not met")
+ set_tests_properties(playTests PROPERTIES DISABLED YES)
+endif()
+
+# Label the "Medium" set of tests (see TESTING.md)
+set_property(TEST fuzzer zstreamtest playTests APPEND PROPERTY LABELS Medium)
+
+add_executable(paramgrill ${PROGRAMS_DIR}/benchfn.c ${PROGRAMS_DIR}/benchzstd.c ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${TESTS_DIR}/paramgrill.c)
+if (UNIX)
+ target_link_libraries(paramgrill libzstd_static m) #m is math library
+else()
+ target_link_libraries(paramgrill libzstd_static)
+endif ()
diff --git a/3rdparty/zstd/build/cmake/zstdConfig.cmake b/3rdparty/zstd/build/cmake/zstdConfig.cmake
new file mode 100644
index 00000000000..ebbfcc38f6f
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/zstdConfig.cmake
@@ -0,0 +1 @@
+include("${CMAKE_CURRENT_LIST_DIR}/zstdTargets.cmake")