diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 18:24:20 +0000 |
commit | 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 (patch) | |
tree | e5d88d25d870d5dedacb6bbdbe2a966086a0a5cf /src/zstd/build/cmake | |
parent | Initial commit. (diff) | |
download | ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.tar.xz ceph-483eb2f56657e8e7f419ab1a4fab8dce9ade8609.zip |
Adding upstream version 14.2.21.upstream/14.2.21upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/zstd/build/cmake')
-rw-r--r-- | src/zstd/build/cmake/.gitignore | 7 | ||||
-rw-r--r-- | src/zstd/build/cmake/CMakeLists.txt | 79 | ||||
-rw-r--r-- | src/zstd/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake | 67 | ||||
-rw-r--r-- | src/zstd/build/cmake/CMakeModules/GetZstdLibraryVersion.cmake | 9 | ||||
-rw-r--r-- | src/zstd/build/cmake/contrib/CMakeLists.txt | 13 | ||||
-rw-r--r-- | src/zstd/build/cmake/contrib/gen_html/CMakeLists.txt | 30 | ||||
-rw-r--r-- | src/zstd/build/cmake/contrib/pzstd/CMakeLists.txt | 32 | ||||
-rw-r--r-- | src/zstd/build/cmake/lib/.gitignore | 2 | ||||
-rw-r--r-- | src/zstd/build/cmake/lib/CMakeLists.txt | 183 | ||||
-rw-r--r-- | src/zstd/build/cmake/lib/cmake_uninstall.cmake.in | 22 | ||||
-rw-r--r-- | src/zstd/build/cmake/lib/pkgconfig.cmake | 1 | ||||
-rw-r--r-- | src/zstd/build/cmake/programs/.gitignore | 5 | ||||
-rw-r--r-- | src/zstd/build/cmake/programs/CMakeLists.txt | 97 | ||||
-rw-r--r-- | src/zstd/build/cmake/tests/.gitignore | 7 | ||||
-rw-r--r-- | src/zstd/build/cmake/tests/CMakeLists.txt | 55 |
15 files changed, 609 insertions, 0 deletions
diff --git a/src/zstd/build/cmake/.gitignore b/src/zstd/build/cmake/.gitignore new file mode 100644 index 00000000..ad4283f9 --- /dev/null +++ b/src/zstd/build/cmake/.gitignore @@ -0,0 +1,7 @@ +# cmake artefacts +CMakeCache.txt +CMakeFiles +Makefile +cmake_install.cmake +cmake_uninstall.cmake +*.1 diff --git a/src/zstd/build/cmake/CMakeLists.txt b/src/zstd/build/cmake/CMakeLists.txt new file mode 100644 index 00000000..8e8824e7 --- /dev/null +++ b/src/zstd/build/cmake/CMakeLists.txt @@ -0,0 +1,79 @@ +# ################################################################ +# Copyright (c) 2016-present, Yann Collet, Facebook, Inc. +# 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(zstd) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9) +SET(ZSTD_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../..") +LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") + +#----------------------------------------------------------------------------- +# Add extra compilation flags +#----------------------------------------------------------------------------- +INCLUDE(AddZstdCompilationFlags) +ADD_ZSTD_COMPILATION_FLAGS() + +# Always hide XXHash symbols +ADD_DEFINITIONS(-DXXH_NAMESPACE=ZSTD_) + +#----------------------------------------------------------------------------- +# Options +#----------------------------------------------------------------------------- +OPTION(ZSTD_LEGACY_SUPPORT "LEGACY SUPPORT" OFF) +IF (UNIX) + OPTION(ZSTD_MULTITHREAD_SUPPORT "MULTITHREADING SUPPORT" ON) +ELSE (UNIX) + OPTION(ZSTD_MULTITHREAD_SUPPORT "MULTITHREADING SUPPORT" OFF) +ENDIF (UNIX) +OPTION(ZSTD_BUILD_PROGRAMS "BUILD PROGRAMS" ON) +OPTION(ZSTD_BUILD_CONTRIB "BUILD CONTRIB" OFF) +OPTION(ZSTD_BUILD_TESTS "BUILD TESTS" OFF) +if (MSVC) + OPTION(ZSTD_USE_STATIC_RUNTIME "LINK TO STATIC RUN-TIME LIBRARIES" OFF) +endif () + +IF (ZSTD_LEGACY_SUPPORT) + MESSAGE(STATUS "ZSTD_LEGACY_SUPPORT defined!") + ADD_DEFINITIONS(-DZSTD_LEGACY_SUPPORT=4) +ELSE (ZSTD_LEGACY_SUPPORT) + MESSAGE(STATUS "ZSTD_LEGACY_SUPPORT not defined!") + ADD_DEFINITIONS(-DZSTD_LEGACY_SUPPORT=0) +ENDIF (ZSTD_LEGACY_SUPPORT) + +#----------------------------------------------------------------------------- +# Add source directories +#----------------------------------------------------------------------------- +ADD_SUBDIRECTORY(lib) + +IF (ZSTD_BUILD_PROGRAMS) + IF (NOT ZSTD_BUILD_STATIC) + MESSAGE(SEND_ERROR "You need to build static library to build zstd CLI") + ENDIF (NOT ZSTD_BUILD_STATIC) + + ADD_SUBDIRECTORY(programs) +ENDIF (ZSTD_BUILD_PROGRAMS) + +IF (ZSTD_BUILD_TESTS) + IF (NOT ZSTD_BUILD_STATIC) + MESSAGE(SEND_ERROR "You need to build static library to build tests") + ENDIF (NOT ZSTD_BUILD_STATIC) + + ADD_SUBDIRECTORY(tests) +ENDIF (ZSTD_BUILD_TESTS) + +IF (ZSTD_BUILD_CONTRIB) + ADD_SUBDIRECTORY(contrib) +ENDIF (ZSTD_BUILD_CONTRIB) + +#----------------------------------------------------------------------------- +# Add clean-all target +#----------------------------------------------------------------------------- +ADD_CUSTOM_TARGET(clean-all + COMMAND ${CMAKE_BUILD_TOOL} clean + COMMAND rm -rf ${CMAKE_BINARY_DIR}/ +) diff --git a/src/zstd/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake b/src/zstd/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake new file mode 100644 index 00000000..a7dc08ea --- /dev/null +++ b/src/zstd/build/cmake/CMakeModules/AddZstdCompilationFlags.cmake @@ -0,0 +1,67 @@ +include(CheckCXXCompilerFlag) +include(CheckCCompilerFlag) + +function(EnableCompilerFlag _flag _C _CXX) + 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 () +endfunction() + +MACRO(ADD_ZSTD_COMPILATION_FLAGS) + if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" OR MINGW) #Not only UNIX but also WIN32 for MinGW + #Set c++11 by default + EnableCompilerFlag("-std=c++11" false true) + #Set c99 by default + EnableCompilerFlag("-std=c99" true false) + EnableCompilerFlag("-Wall" true true) + EnableCompilerFlag("-Wextra" true true) + EnableCompilerFlag("-Wundef" true true) + EnableCompilerFlag("-Wshadow" true true) + EnableCompilerFlag("-Wcast-align" true true) + EnableCompilerFlag("-Wcast-qual" true true) + EnableCompilerFlag("-Wstrict-prototypes" 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) + endif () + + # UNICODE SUPPORT + EnableCompilerFlag("/D_UNICODE" true true) + EnableCompilerFlag("/DUNICODE" true true) + 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) + separate_arguments(${flag_var}) + list(REMOVE_DUPLICATES ${flag_var}) + string(REPLACE ";" " " ${flag_var} "${${flag_var}}") + ENDFOREACH (flag_var) + + 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) + STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") + ENDFOREACH (flag_var) + endif () + +ENDMACRO(ADD_ZSTD_COMPILATION_FLAGS) diff --git a/src/zstd/build/cmake/CMakeModules/GetZstdLibraryVersion.cmake b/src/zstd/build/cmake/CMakeModules/GetZstdLibraryVersion.cmake new file mode 100644 index 00000000..8b6f394d --- /dev/null +++ b/src/zstd/build/cmake/CMakeModules/GetZstdLibraryVersion.cmake @@ -0,0 +1,9 @@ +function(GetZstdLibraryVersion _header _major _minor _release) + # 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(${_release} ${CMAKE_MATCH_3} PARENT_SCOPE) +endfunction() diff --git a/src/zstd/build/cmake/contrib/CMakeLists.txt b/src/zstd/build/cmake/contrib/CMakeLists.txt new file mode 100644 index 00000000..8c7bc78a --- /dev/null +++ b/src/zstd/build/cmake/contrib/CMakeLists.txt @@ -0,0 +1,13 @@ +# ################################################################ +# Copyright (c) 2016-present, Yann Collet, Facebook, Inc. +# 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/src/zstd/build/cmake/contrib/gen_html/CMakeLists.txt b/src/zstd/build/cmake/contrib/gen_html/CMakeLists.txt new file mode 100644 index 00000000..01d19067 --- /dev/null +++ b/src/zstd/build/cmake/contrib/gen_html/CMakeLists.txt @@ -0,0 +1,30 @@ +# ################################################################ +# Copyright (c) 2015-present, Yann Collet, Facebook, Inc. +# 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 "share/doc") diff --git a/src/zstd/build/cmake/contrib/pzstd/CMakeLists.txt b/src/zstd/build/cmake/contrib/pzstd/CMakeLists.txt new file mode 100644 index 00000000..e6db4719 --- /dev/null +++ b/src/zstd/build/cmake/contrib/pzstd/CMakeLists.txt @@ -0,0 +1,32 @@ +# ################################################################ +# Copyright (c) 2016-present, Facebook, Inc. +# 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 ${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") + +SET(THREADS_PREFER_PTHREAD_FLAG ON) +FIND_PACKAGE(Threads REQUIRED) +IF (CMAKE_USE_PTHREADS_INIT) + TARGET_LINK_LIBRARIES(pzstd libzstd_shared ${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/src/zstd/build/cmake/lib/.gitignore b/src/zstd/build/cmake/lib/.gitignore new file mode 100644 index 00000000..a4444c8d --- /dev/null +++ b/src/zstd/build/cmake/lib/.gitignore @@ -0,0 +1,2 @@ +# cmake build artefact +libzstd.pc diff --git a/src/zstd/build/cmake/lib/CMakeLists.txt b/src/zstd/build/cmake/lib/CMakeLists.txt new file mode 100644 index 00000000..f5d2eff9 --- /dev/null +++ b/src/zstd/build/cmake/lib/CMakeLists.txt @@ -0,0 +1,183 @@ +# ################################################################ +# Copyright (c) 2015-present, Yann Collet, Facebook, Inc. +# 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) + +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 libstd") +ENDIF() + +# Define library directory, where sources and header files are located +SET(LIBRARY_DIR ${ZSTD_SOURCE_DIR}/lib) +INCLUDE_DIRECTORIES(${LIBRARY_DIR} ${LIBRARY_DIR}/common) + +# Parse version +INCLUDE(GetZstdLibraryVersion) +GetZstdLibraryVersion(${LIBRARY_DIR}/zstd.h LIBVER_MAJOR LIBVER_MINOR LIBVER_RELEASE) +MESSAGE("ZSTD VERSION ${LIBVER_MAJOR}.${LIBVER_MINOR}.${LIBVER_RELEASE}") + +SET(Sources + ${LIBRARY_DIR}/common/entropy_common.c + ${LIBRARY_DIR}/common/fse_decompress.c + ${LIBRARY_DIR}/common/threading.c + ${LIBRARY_DIR}/common/pool.c + ${LIBRARY_DIR}/common/zstd_common.c + ${LIBRARY_DIR}/common/error_private.c + ${LIBRARY_DIR}/common/xxhash.c + ${LIBRARY_DIR}/compress/fse_compress.c + ${LIBRARY_DIR}/compress/huf_compress.c + ${LIBRARY_DIR}/compress/zstd_compress.c + ${LIBRARY_DIR}/compress/zstdmt_compress.c + ${LIBRARY_DIR}/compress/zstd_fast.c + ${LIBRARY_DIR}/compress/zstd_double_fast.c + ${LIBRARY_DIR}/compress/zstd_lazy.c + ${LIBRARY_DIR}/compress/zstd_opt.c + ${LIBRARY_DIR}/compress/zstd_ldm.c + ${LIBRARY_DIR}/decompress/huf_decompress.c + ${LIBRARY_DIR}/decompress/zstd_decompress.c + ${LIBRARY_DIR}/dictBuilder/cover.c + ${LIBRARY_DIR}/dictBuilder/divsufsort.c + ${LIBRARY_DIR}/dictBuilder/zdict.c + ${LIBRARY_DIR}/deprecated/zbuff_common.c + ${LIBRARY_DIR}/deprecated/zbuff_compress.c + ${LIBRARY_DIR}/deprecated/zbuff_decompress.c) + +SET(Headers + ${LIBRARY_DIR}/zstd.h + ${LIBRARY_DIR}/common/pool.h + ${LIBRARY_DIR}/common/threading.h + ${LIBRARY_DIR}/common/bitstream.h + ${LIBRARY_DIR}/common/error_private.h + ${LIBRARY_DIR}/common/zstd_errors.h + ${LIBRARY_DIR}/common/fse.h + ${LIBRARY_DIR}/common/huf.h + ${LIBRARY_DIR}/common/mem.h + ${LIBRARY_DIR}/common/zstd_internal.h + ${LIBRARY_DIR}/compress/zstd_compress.h + ${LIBRARY_DIR}/compress/zstd_fast.h + ${LIBRARY_DIR}/compress/zstd_double_fast.h + ${LIBRARY_DIR}/compress/zstd_lazy.h + ${LIBRARY_DIR}/compress/zstd_opt.h + ${LIBRARY_DIR}/compress/zstd_ldm.h + ${LIBRARY_DIR}/compress/zstdmt_compress.h + ${LIBRARY_DIR}/dictBuilder/zdict.h + ${LIBRARY_DIR}/deprecated/zbuff.h) + +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 (ZSTD_LEGACY_SUPPORT) + +IF (MSVC) + SET(MSVC_RESOURCE_DIR ${ZSTD_SOURCE_DIR}/build/VS2010/libzstd-dll) + SET(PlatformDependResources ${MSVC_RESOURCE_DIR}/libzstd-dll.rc) +ENDIF (MSVC) + +# Split project to static and shared libraries build +IF (ZSTD_BUILD_SHARED) + ADD_LIBRARY(libzstd_shared SHARED ${Sources} ${Headers} ${PlatformDependResources}) +ENDIF (ZSTD_BUILD_SHARED) +IF (ZSTD_BUILD_STATIC) + ADD_LIBRARY(libzstd_static STATIC ${Sources} ${Headers}) +ENDIF (ZSTD_BUILD_STATIC) + +# 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 (ZSTD_BUILD_SHARED) + IF (ZSTD_BUILD_STATIC) + SET_PROPERTY(TARGET libzstd_static APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_HEAPMODE=0;_CRT_SECURE_NO_WARNINGS") + ENDIF (ZSTD_BUILD_STATIC) +ENDIF (MSVC) + +# With MSVC static library needs to be renamed to avoid conflict with import library +IF (MSVC) + SET(STATIC_LIBRARY_BASE_NAME zstd_static) +ELSE () + SET(STATIC_LIBRARY_BASE_NAME zstd) +ENDIF (MSVC) + +# Define static and shared library names +IF (ZSTD_BUILD_SHARED) + SET_TARGET_PROPERTIES( + libzstd_shared + PROPERTIES + OUTPUT_NAME zstd + SOVERSION ${LIBVER_MAJOR}.${LIBVER_MINOR}.${LIBVER_RELEASE}) +ENDIF (ZSTD_BUILD_SHARED) + +IF (ZSTD_BUILD_STATIC) + SET_TARGET_PROPERTIES( + libzstd_static + PROPERTIES + OUTPUT_NAME ${STATIC_LIBRARY_BASE_NAME}) +ENDIF (ZSTD_BUILD_STATIC) + +IF (UNIX) + # pkg-config + SET(PREFIX "${CMAKE_INSTALL_PREFIX}") + SET(LIBDIR "${CMAKE_INSTALL_PREFIX}/lib") + SET(INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include") + SET(VERSION "${LIBVER_MAJOR}.${LIBVER_MINOR}.${LIBVER_RELEASE}") + ADD_CUSTOM_TARGET(libzstd.pc ALL + ${CMAKE_COMMAND} -DIN="${LIBRARY_DIR}/libzstd.pc.in" -DOUT="libzstd.pc" + -DPREFIX="${PREFIX}" -DLIBDIR="${LIBDIR}" -DINCLUDEDIR="${INCLUDEDIR}" -DVERSION="${VERSION}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig.cmake" + COMMENT "Creating pkg-config file") + + INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/libzstd.pc" DESTINATION "share/pkgconfig") +ENDIF (UNIX) + +# install target +INSTALL(FILES + ${LIBRARY_DIR}/zstd.h + ${LIBRARY_DIR}/deprecated/zbuff.h + ${LIBRARY_DIR}/dictBuilder/zdict.h + ${LIBRARY_DIR}/common/zstd_errors.h + DESTINATION "include") + +IF (ZSTD_BUILD_SHARED) + INSTALL(TARGETS libzstd_shared RUNTIME DESTINATION "bin" LIBRARY DESTINATION "lib" ARCHIVE DESTINATION "lib") +ENDIF() +IF (ZSTD_BUILD_STATIC) + INSTALL(TARGETS libzstd_static ARCHIVE DESTINATION "lib") +ENDIF (ZSTD_BUILD_STATIC) + +# uninstall target +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) diff --git a/src/zstd/build/cmake/lib/cmake_uninstall.cmake.in b/src/zstd/build/cmake/lib/cmake_uninstall.cmake.in new file mode 100644 index 00000000..e3774dc1 --- /dev/null +++ b/src/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(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + +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(NOT "${rm_retval}" STREQUAL 0) + else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") + message(STATUS "File $ENV{DESTDIR}${file} does not exist.") + endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") +endforeach(file) diff --git a/src/zstd/build/cmake/lib/pkgconfig.cmake b/src/zstd/build/cmake/lib/pkgconfig.cmake new file mode 100644 index 00000000..5434ff75 --- /dev/null +++ b/src/zstd/build/cmake/lib/pkgconfig.cmake @@ -0,0 +1 @@ +CONFIGURE_FILE("${IN}" "${OUT}" @ONLY) diff --git a/src/zstd/build/cmake/programs/.gitignore b/src/zstd/build/cmake/programs/.gitignore new file mode 100644 index 00000000..ae3a8a35 --- /dev/null +++ b/src/zstd/build/cmake/programs/.gitignore @@ -0,0 +1,5 @@ +# produced by make +zstd +zstd-frugal +unzstd +zstdcat diff --git a/src/zstd/build/cmake/programs/CMakeLists.txt b/src/zstd/build/cmake/programs/CMakeLists.txt new file mode 100644 index 00000000..9251fd29 --- /dev/null +++ b/src/zstd/build/cmake/programs/CMakeLists.txt @@ -0,0 +1,97 @@ +# ################################################################ +# Copyright (c) 2015-present, Yann Collet, Facebook, Inc. +# 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) + +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 (ZSTD_LEGACY_SUPPORT) + +IF (MSVC) + SET(MSVC_RESOURCE_DIR ${ZSTD_SOURCE_DIR}/build/VS2010/zstd) + SET(PlatformDependResources ${MSVC_RESOURCE_DIR}/zstd.rc) +ENDIF (MSVC) + +ADD_EXECUTABLE(zstd ${PROGRAMS_DIR}/zstdcli.c ${PROGRAMS_DIR}/fileio.c ${PROGRAMS_DIR}/bench.c ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/dibio.c ${PlatformDependResources}) +TARGET_LINK_LIBRARIES(zstd libzstd_static) +IF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") + TARGET_LINK_LIBRARIES(zstd rt) +ENDIF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") +INSTALL(TARGETS zstd RUNTIME DESTINATION "bin") + +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(TARGETS zstd RUNTIME DESTINATION "bin") + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/zstdcat DESTINATION "bin") + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/unzstd DESTINATION "bin") + + ADD_CUSTOM_TARGET(zstd.1 ALL + ${CMAKE_COMMAND} -E copy ${PROGRAMS_DIR}/zstd.1 . + COMMENT "Copying manpage zstd.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") + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/zstd.1 DESTINATION "share/man/man1") + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/zstdcat.1 DESTINATION "share/man/man1") + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/unzstd.1 DESTINATION "share/man/man1") + + ADD_EXECUTABLE(zstd-frugal ${PROGRAMS_DIR}/zstdcli.c ${PROGRAMS_DIR}/fileio.c) + TARGET_LINK_LIBRARIES(zstd-frugal libzstd_static) + SET_PROPERTY(TARGET zstd-frugal APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_NOBENCH;ZSTD_NODICT") +ENDIF (UNIX) + +IF (ZSTD_MULTITHREAD_SUPPORT) + SET_PROPERTY(TARGET zstd APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD") + + SET(THREADS_PREFER_PTHREAD_FLAG ON) + FIND_PACKAGE(Threads REQUIRED) + IF (CMAKE_USE_PTHREADS_INIT) + TARGET_LINK_LIBRARIES(zstd ${CMAKE_THREAD_LIBS_INIT}) + ELSE() + MESSAGE(SEND_ERROR "ZSTD currently does not support thread libraries other than pthreads") + ENDIF() + + 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 "bin") +ENDIF (ZSTD_MULTITHREAD_SUPPORT) + +OPTION(ZSTD_ZLIB_SUPPORT "ZLIB SUPPORT" OFF) +OPTION(ZSTD_LZMA_SUPPORT "LZMA SUPPORT" OFF) + +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 () + +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 () diff --git a/src/zstd/build/cmake/tests/.gitignore b/src/zstd/build/cmake/tests/.gitignore new file mode 100644 index 00000000..2ab62a3e --- /dev/null +++ b/src/zstd/build/cmake/tests/.gitignore @@ -0,0 +1,7 @@ +# produced by make +datagen +fullbench +fuzzer +paramgrill +zbufftest + diff --git a/src/zstd/build/cmake/tests/CMakeLists.txt b/src/zstd/build/cmake/tests/CMakeLists.txt new file mode 100644 index 00000000..cb327e48 --- /dev/null +++ b/src/zstd/build/cmake/tests/CMakeLists.txt @@ -0,0 +1,55 @@ +# ################################################################ +# zstd - Makefile +# Copyright (C) Yann Collet 2014-2016 +# 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 : http://www.zstd.net/ +# ################################################################ + +PROJECT(tests) + +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(fullbench ${PROGRAMS_DIR}/datagen.c ${TESTS_DIR}/fullbench.c) +TARGET_LINK_LIBRARIES(fullbench libzstd_static) + +ADD_EXECUTABLE(fuzzer ${PROGRAMS_DIR}/datagen.c ${TESTS_DIR}/fuzzer.c) +TARGET_LINK_LIBRARIES(fuzzer libzstd_static) + +IF (UNIX) + ADD_EXECUTABLE(paramgrill ${PROGRAMS_DIR}/datagen.c ${TESTS_DIR}/paramgrill.c) + TARGET_LINK_LIBRARIES(paramgrill libzstd_static m) #m is math library + + ADD_EXECUTABLE(datagen ${PROGRAMS_DIR}/datagen.c ${TESTS_DIR}/datagencli.c) + TARGET_LINK_LIBRARIES(datagen libzstd_static) +ENDIF (UNIX) |