2022-01-20 18:12:57 +08:00
|
|
|
# Copyright 2022 Google LLC
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
cmake_minimum_required(VERSION 3.13)
|
|
|
|
|
|
|
|
project(sapi_zstd CXX)
|
2022-04-21 16:14:48 +08:00
|
|
|
include(CTest)
|
2022-01-20 18:12:57 +08:00
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
|
|
|
|
2022-02-03 00:38:34 +08:00
|
|
|
if(NOT TARGET sapi::sapi)
|
|
|
|
set(SAPI_ROOT "../.." CACHE PATH "Path to the Sandboxed API source tree")
|
|
|
|
add_subdirectory("${SAPI_ROOT}"
|
|
|
|
"${CMAKE_BINARY_DIR}/sandboxed-api-build"
|
|
|
|
EXCLUDE_FROM_ALL)
|
|
|
|
endif()
|
2022-01-20 18:12:57 +08:00
|
|
|
|
2022-02-03 00:38:34 +08:00
|
|
|
FetchContent_Declare(libzstd
|
2022-01-20 18:12:57 +08:00
|
|
|
GIT_REPOSITORY https://github.com/facebook/zstd.git
|
2022-02-03 00:38:34 +08:00
|
|
|
GIT_TAG 4dfc4eca9a166b474b09542a9fc8e2da162eea99
|
2022-01-20 18:12:57 +08:00
|
|
|
SOURCE_SUBDIR build/cmake
|
|
|
|
)
|
|
|
|
FetchContent_MakeAvailable(libzstd)
|
|
|
|
|
2022-02-03 00:38:34 +08:00
|
|
|
set(libzstd_INCLUDE_DIR "${libzstd_SOURCE_DIR}/lib")
|
2022-02-03 04:45:58 +08:00
|
|
|
add_subdirectory(wrapper)
|
|
|
|
|
2022-01-20 18:12:57 +08:00
|
|
|
add_sapi_library(
|
|
|
|
sapi_zstd
|
|
|
|
|
|
|
|
FUNCTIONS
|
|
|
|
ZSTD_versionNumber
|
|
|
|
ZSTD_versionString
|
|
|
|
|
|
|
|
ZSTD_compressBound
|
|
|
|
ZSTD_isError
|
|
|
|
ZSTD_getErrorName
|
|
|
|
ZSTD_minCLevel
|
|
|
|
ZSTD_maxCLevel
|
|
|
|
ZSTD_defaultCLevel
|
|
|
|
|
|
|
|
ZSTD_createDCtx
|
|
|
|
ZSTD_freeDCtx
|
|
|
|
|
2022-02-03 01:34:05 +08:00
|
|
|
ZSTD_createCCtx
|
|
|
|
ZSTD_freeCCtx
|
|
|
|
|
2022-01-20 18:12:57 +08:00
|
|
|
ZSTD_CCtx_setParameter
|
|
|
|
|
|
|
|
ZSTD_compress
|
|
|
|
ZSTD_compressStream
|
|
|
|
ZSTD_compressStream2
|
|
|
|
ZSTD_flushStream
|
|
|
|
ZSTD_endStream
|
|
|
|
|
|
|
|
ZSTD_CStreamInSize
|
|
|
|
ZSTD_CStreamOutSize
|
|
|
|
|
|
|
|
ZSTD_decompress
|
|
|
|
ZSTD_decompressStream
|
|
|
|
|
|
|
|
ZSTD_getFrameContentSize
|
|
|
|
|
2022-02-03 04:45:58 +08:00
|
|
|
ZSTD_compress_fd
|
|
|
|
ZSTD_compressStream_fd
|
|
|
|
|
|
|
|
ZSTD_decompress_fd
|
|
|
|
ZSTD_decompressStream_fd
|
2022-01-20 18:12:57 +08:00
|
|
|
INPUTS
|
2022-02-09 20:41:01 +08:00
|
|
|
"${libzstd_INCLUDE_DIR}/zstd.h"
|
2022-02-03 04:45:58 +08:00
|
|
|
wrapper/wrapper_zstd.h
|
2022-01-20 18:12:57 +08:00
|
|
|
|
2022-02-03 04:45:58 +08:00
|
|
|
LIBRARY wrapper_zstd
|
2022-01-20 18:12:57 +08:00
|
|
|
LIBRARY_NAME Zstd
|
|
|
|
NAMESPACE ""
|
|
|
|
)
|
2022-02-03 00:38:34 +08:00
|
|
|
add_library(sapi_contrib::zstd ALIAS sapi_zstd)
|
2022-01-20 18:12:57 +08:00
|
|
|
target_include_directories(sapi_zstd INTERFACE
|
|
|
|
"${PROJECT_BINARY_DIR}"
|
2022-02-03 00:38:34 +08:00
|
|
|
"${SAPI_SOURCE_DIR}"
|
2022-01-20 18:12:57 +08:00
|
|
|
)
|
|
|
|
|
2022-04-21 16:17:08 +08:00
|
|
|
if(SAPI_BUILD_EXAMPLES)
|
2022-01-20 18:12:57 +08:00
|
|
|
add_subdirectory(example)
|
|
|
|
endif()
|
|
|
|
|
2022-04-21 16:17:08 +08:00
|
|
|
if(BUILD_TESTING AND SAPI_BUILD_TESTING)
|
2022-01-20 18:12:57 +08:00
|
|
|
add_subdirectory(test)
|
|
|
|
endif()
|