Skip to content
Permalink
Browse files
Merge pull request #8811 from JosJuice/zstd
Externals: Add zstd
  • Loading branch information
delroth committed May 13, 2020
2 parents 6705fd8 + d7389dc commit 30b166e
Show file tree
Hide file tree
Showing 72 changed files with 28,008 additions and 10 deletions.
@@ -608,6 +608,15 @@ else()
add_subdirectory(Externals/liblzma)
endif()

find_package(zstd)
if(ZSTD_FOUND)
message(STATUS "Using shared zstd")
else()
check_vendoring_approved(zstd)
message(STATUS "Shared zstd not found, falling back to the static library")
add_subdirectory(Externals/zstd)
endif()

find_package(ZLIB)
if(ZLIB_FOUND)
message(STATUS "Using shared zlib")
@@ -6,6 +6,8 @@ Dolphin includes or links code of the following third-party software projects:
[LGPLv2.1+](https://git.kernel.org/cgit/bluetooth/bluez.git/tree/COPYING.LIB)
- [Bochs](http://bochs.sourceforge.net/):
[LGPLv2.1+](http://bochs.sourceforge.net/cgi-bin/lxr/source/COPYING)
- [bzip2](https://www.sourceware.org/bzip2/):
bzip2 license (BSD-like)
- [cubeb](https://github.com/kinetiknz/cubeb):
[ISC](https://github.com/kinetiknz/cubeb/blob/master/LICENSE)
- [Discord-RPC](https://github.com/discordapp/discord-rpc):
@@ -26,6 +28,8 @@ Dolphin includes or links code of the following third-party software projects:
[GPLv3+](http://git.savannah.gnu.org/gitweb/?p=libcdio.git;a=blob_plain;f=COPYING)
- [libiconv](https://www.gnu.org/software/libiconv/):
[LGPLv2+](http://git.savannah.gnu.org/cgit/libiconv.git/tree/COPYING.LIB)
- [liblzma](https://tukaani.org/xz/):
[Public domain](https://git.tukaani.org/?p=xz.git;a=blob_plain;f=COPYING;hb=HEAD)
- [libpng](http://www.libpng.org/pub/png/libpng.html):
[libpng license](http://www.libpng.org/pub/png/src/libpng-LICENSE.txt)
- [libusb](http://libusb.info/):
@@ -66,3 +70,5 @@ Dolphin includes or links code of the following third-party software projects:
[2-clause BSD](https://github.com/Cyan4973/xxHash/blob/master/LICENSE)
- [zlib](http://www.zlib.net/):
[zlib license](http://www.zlib.net/zlib_license.html)
- [Zstandard](https://facebook.github.io/zstd/):
[3-clause BSD](https://github.com/facebook/zstd/blob/dev/LICENSE) or [GPLv2](https://github.com/facebook/zstd/blob/dev/COPYING)
@@ -0,0 +1,127 @@
project(bzip2 C)

include(CheckTypeSize)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CheckCSourceCompiles)

check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(stddef.h HAVE_STDDEF_H)

# Check to see if we have large file support
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
# We add these other definitions here because CheckTypeSize.cmake
# in CMake 2.4.x does not automatically do so and we want
# compatibility with CMake 2.4.x.
if(HAVE_SYS_TYPES_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
endif()
if(HAVE_STDINT_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
endif()
if(HAVE_STDDEF_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
endif()
check_type_size(off64_t OFF64_T)
if(HAVE_OFF64_T)
add_definitions(-D_LARGEFILE64_SOURCE=1)
endif()
set(CMAKE_REQUIRED_DEFINITIONS) # clear variable

# Check for fseeko
check_function_exists(fseeko HAVE_FSEEKO)
if(NOT HAVE_FSEEKO)
add_definitions(-DNO_FSEEKO)
endif()

#
# Check for unistd.h
#
check_include_file(unistd.h HAVE_UNISTD_H)
if(HAVE_UNISTD_H)
add_definitions(-DHAVE_UNISTD_H)
endif()

if(MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
endif()

# Always hide XXHash symbols
add_definitions(-DXXH_NAMESPACE=ZSTD_)

#============================================================================
# zstd
#============================================================================

set(ZSTD_PUBLIC_HDRS
lib/zstd.h
)
set(ZSTD_PRIVATE_HDRS
lib/common/bitstream.h
lib/common/compiler.h
lib/common/cpu.h
lib/common/debug.h
lib/common/error_private.h
lib/common/fse.h
lib/common/huf.h
lib/common/mem.h
lib/common/pool.h
lib/common/threading.h
lib/common/xxhash.h
lib/common/zstd_errors.h
lib/common/zstd_internal.h
lib/compress/hist.h
lib/compress/zstd_compress_internal.h
lib/compress/zstd_compress_literals.h
lib/compress/zstd_compress_sequences.h
lib/compress/zstd_cwksp.h
lib/compress/zstd_double_fast.h
lib/compress/zstd_fast.h
lib/compress/zstd_lazy.h
lib/compress/zstd_ldm.h
lib/compress/zstd_opt.h
lib/compress/zstdmt_compress.h
lib/decompress/zstd_ddict.h
lib/decompress/zstd_decompress_block.h
lib/decompress/zstd_decompress_internal.h
)
set(ZSTD_SRCS
lib/common/debug.c
lib/common/entropy_common.c
lib/common/error_private.c
lib/common/fse_decompress.c
lib/common/pool.c
lib/common/threading.c
lib/common/xxhash.c
lib/common/zstd_common.c
lib/compress/fse_compress.c
lib/compress/hist.c
lib/compress/huf_compress.c
lib/compress/zstd_compress.c
lib/compress/zstd_compress_literals.c
lib/compress/zstd_compress_sequences.c
lib/compress/zstd_double_fast.c
lib/compress/zstd_fast.c
lib/compress/zstd_lazy.c
lib/compress/zstd_ldm.c
lib/compress/zstd_opt.c
lib/compress/zstdmt_compress.c
lib/decompress/huf_decompress.c
lib/decompress/zstd_ddict.c
lib/decompress/zstd_decompress.c
lib/decompress/zstd_decompress_block.c
)

add_library(zstd STATIC ${ZSTD_SRCS} ${ZSTD_PUBLIC_HDRS} ${ZSTD_PRIVATE_HDRS})
add_library(zstd::zstd ALIAS zstd)

target_include_directories(zstd
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/lib
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/lib/common
${CMAKE_CURRENT_SOURCE_DIR}/lib/compress
${CMAKE_CURRENT_SOURCE_DIR}/lib/decompress
)

0 comments on commit 30b166e

Please sign in to comment.