2016-01-10 11:20:52 +00:00
|
|
|
# ################################################################
|
2017-08-31 19:20:50 +00:00
|
|
|
# Copyright (c) 2015-present, Yann Collet, Facebook, Inc.
|
|
|
|
# All rights reserved.
|
2016-05-29 00:02:24 +00:00
|
|
|
#
|
2017-08-31 19:20:50 +00:00
|
|
|
# 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).
|
2016-01-10 11:20:52 +00:00
|
|
|
# ################################################################
|
|
|
|
|
|
|
|
PROJECT(libzstd)
|
|
|
|
|
|
|
|
SET(CMAKE_INCLUDE_CURRENT_DIR TRUE)
|
2017-05-24 08:48:10 +00:00
|
|
|
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()
|
2016-01-10 11:20:52 +00:00
|
|
|
|
|
|
|
# Define library directory, where sources and header files are located
|
2017-03-16 13:03:54 +00:00
|
|
|
SET(LIBRARY_DIR ${ZSTD_SOURCE_DIR}/lib)
|
2016-07-18 01:41:59 +00:00
|
|
|
INCLUDE_DIRECTORIES(${LIBRARY_DIR} ${LIBRARY_DIR}/common)
|
2016-01-10 11:20:52 +00:00
|
|
|
|
|
|
|
# Parse version
|
2017-04-20 22:46:44 +00:00
|
|
|
INCLUDE(GetZstdLibraryVersion)
|
|
|
|
GetZstdLibraryVersion(${LIBRARY_DIR}/zstd.h LIBVER_MAJOR LIBVER_MINOR LIBVER_RELEASE)
|
2016-01-10 11:20:52 +00:00
|
|
|
MESSAGE("ZSTD VERSION ${LIBVER_MAJOR}.${LIBVER_MINOR}.${LIBVER_RELEASE}")
|
|
|
|
|
|
|
|
SET(Sources
|
2016-05-13 09:27:56 +00:00
|
|
|
${LIBRARY_DIR}/common/entropy_common.c
|
2017-01-02 01:05:45 +00:00
|
|
|
${LIBRARY_DIR}/common/fse_decompress.c
|
|
|
|
${LIBRARY_DIR}/common/threading.c
|
|
|
|
${LIBRARY_DIR}/common/pool.c
|
2016-04-22 15:14:25 +00:00
|
|
|
${LIBRARY_DIR}/common/zstd_common.c
|
2016-10-12 17:23:53 +00:00
|
|
|
${LIBRARY_DIR}/common/error_private.c
|
2016-05-29 00:02:24 +00:00
|
|
|
${LIBRARY_DIR}/common/xxhash.c
|
2016-04-22 11:59:21 +00:00
|
|
|
${LIBRARY_DIR}/compress/fse_compress.c
|
|
|
|
${LIBRARY_DIR}/compress/huf_compress.c
|
|
|
|
${LIBRARY_DIR}/compress/zstd_compress.c
|
2017-01-02 01:05:45 +00:00
|
|
|
${LIBRARY_DIR}/compress/zstdmt_compress.c
|
2017-09-02 01:22:31 +00:00
|
|
|
${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
|
2017-09-07 00:56:01 +00:00
|
|
|
${LIBRARY_DIR}/compress/zstd_ldm.c
|
2016-04-22 11:59:21 +00:00
|
|
|
${LIBRARY_DIR}/decompress/huf_decompress.c
|
|
|
|
${LIBRARY_DIR}/decompress/zstd_decompress.c
|
2017-01-01 05:08:12 +00:00
|
|
|
${LIBRARY_DIR}/dictBuilder/cover.c
|
2016-04-22 11:59:21 +00:00
|
|
|
${LIBRARY_DIR}/dictBuilder/divsufsort.c
|
2016-12-06 03:28:19 +00:00
|
|
|
${LIBRARY_DIR}/dictBuilder/zdict.c
|
2016-12-16 21:27:30 +00:00
|
|
|
${LIBRARY_DIR}/deprecated/zbuff_common.c
|
2016-12-06 03:28:19 +00:00
|
|
|
${LIBRARY_DIR}/deprecated/zbuff_compress.c
|
|
|
|
${LIBRARY_DIR}/deprecated/zbuff_decompress.c)
|
2016-01-10 11:20:52 +00:00
|
|
|
|
|
|
|
SET(Headers
|
2016-12-06 03:28:19 +00:00
|
|
|
${LIBRARY_DIR}/zstd.h
|
2017-01-27 20:29:27 +00:00
|
|
|
${LIBRARY_DIR}/common/pool.h
|
|
|
|
${LIBRARY_DIR}/common/threading.h
|
2016-04-22 11:59:21 +00:00
|
|
|
${LIBRARY_DIR}/common/bitstream.h
|
|
|
|
${LIBRARY_DIR}/common/error_private.h
|
2016-10-12 17:23:53 +00:00
|
|
|
${LIBRARY_DIR}/common/zstd_errors.h
|
2016-04-22 11:59:21 +00:00
|
|
|
${LIBRARY_DIR}/common/fse.h
|
|
|
|
${LIBRARY_DIR}/common/huf.h
|
|
|
|
${LIBRARY_DIR}/common/mem.h
|
|
|
|
${LIBRARY_DIR}/common/zstd_internal.h
|
2017-09-02 01:22:31 +00:00
|
|
|
${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
|
2017-09-07 00:56:01 +00:00
|
|
|
${LIBRARY_DIR}/compress/zstd_ldm.h
|
2017-01-27 18:27:29 +00:00
|
|
|
${LIBRARY_DIR}/compress/zstdmt_compress.h
|
2016-12-06 03:28:19 +00:00
|
|
|
${LIBRARY_DIR}/dictBuilder/zdict.h
|
|
|
|
${LIBRARY_DIR}/deprecated/zbuff.h)
|
2016-01-10 11:20:52 +00:00
|
|
|
|
|
|
|
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
|
2016-02-12 02:50:05 +00:00
|
|
|
${LIBRARY_LEGACY_DIR}/zstd_v03.c
|
2016-05-31 15:19:05 +00:00
|
|
|
${LIBRARY_LEGACY_DIR}/zstd_v04.c
|
2016-06-09 16:12:06 +00:00
|
|
|
${LIBRARY_LEGACY_DIR}/zstd_v05.c
|
2016-07-25 15:49:49 +00:00
|
|
|
${LIBRARY_LEGACY_DIR}/zstd_v06.c
|
|
|
|
${LIBRARY_LEGACY_DIR}/zstd_v07.c)
|
2016-01-10 11:20:52 +00:00
|
|
|
|
|
|
|
SET(Headers ${Headers}
|
|
|
|
${LIBRARY_LEGACY_DIR}/zstd_legacy.h
|
|
|
|
${LIBRARY_LEGACY_DIR}/zstd_v01.h
|
|
|
|
${LIBRARY_LEGACY_DIR}/zstd_v02.h
|
2016-02-12 02:50:05 +00:00
|
|
|
${LIBRARY_LEGACY_DIR}/zstd_v03.h
|
2016-05-31 15:19:05 +00:00
|
|
|
${LIBRARY_LEGACY_DIR}/zstd_v04.h
|
2016-06-09 16:12:06 +00:00
|
|
|
${LIBRARY_LEGACY_DIR}/zstd_v05.h
|
2016-07-25 15:49:49 +00:00
|
|
|
${LIBRARY_LEGACY_DIR}/zstd_v06.h
|
|
|
|
${LIBRARY_LEGACY_DIR}/zstd_v07.h)
|
2016-01-10 11:20:52 +00:00
|
|
|
ENDIF (ZSTD_LEGACY_SUPPORT)
|
|
|
|
|
2016-05-31 15:19:05 +00:00
|
|
|
IF (MSVC)
|
2017-03-16 13:03:54 +00:00
|
|
|
SET(MSVC_RESOURCE_DIR ${ZSTD_SOURCE_DIR}/build/VS2010/libzstd-dll)
|
2016-12-18 16:17:25 +00:00
|
|
|
SET(PlatformDependResources ${MSVC_RESOURCE_DIR}/libzstd-dll.rc)
|
2016-05-31 15:19:05 +00:00
|
|
|
ENDIF (MSVC)
|
|
|
|
|
2016-01-10 11:20:52 +00:00
|
|
|
# Split project to static and shared libraries build
|
2017-05-24 08:48:10 +00:00
|
|
|
IF (ZSTD_BUILD_SHARED)
|
|
|
|
ADD_LIBRARY(libzstd_shared SHARED ${Sources} ${Headers} ${PlatformDependResources})
|
|
|
|
ENDIF (ZSTD_BUILD_SHARED)
|
2017-03-20 14:47:28 +00:00
|
|
|
IF (ZSTD_BUILD_STATIC)
|
|
|
|
ADD_LIBRARY(libzstd_static STATIC ${Sources} ${Headers})
|
|
|
|
ENDIF (ZSTD_BUILD_STATIC)
|
2016-01-10 11:20:52 +00:00
|
|
|
|
|
|
|
# Add specific compile definitions for MSVC project
|
|
|
|
IF (MSVC)
|
2017-05-24 08:48:10 +00:00
|
|
|
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)
|
2017-03-20 14:47:28 +00:00
|
|
|
IF (ZSTD_BUILD_STATIC)
|
2017-04-19 18:16:11 +00:00
|
|
|
SET_PROPERTY(TARGET libzstd_static APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_HEAPMODE=0;_CRT_SECURE_NO_WARNINGS")
|
2017-03-20 14:47:28 +00:00
|
|
|
ENDIF (ZSTD_BUILD_STATIC)
|
2016-01-10 11:20:52 +00:00
|
|
|
ENDIF (MSVC)
|
|
|
|
|
2017-05-24 08:48:10 +00:00
|
|
|
# With MSVC static library needs to be renamed to avoid conflict with import library
|
2016-05-31 11:39:36 +00:00
|
|
|
IF (MSVC)
|
2017-05-24 08:48:10 +00:00
|
|
|
SET(STATIC_LIBRARY_BASE_NAME zstd_static)
|
2016-12-06 21:45:42 +00:00
|
|
|
ELSE ()
|
2017-05-24 08:48:10 +00:00
|
|
|
SET(STATIC_LIBRARY_BASE_NAME zstd)
|
2016-01-10 11:20:52 +00:00
|
|
|
ENDIF (MSVC)
|
|
|
|
|
2016-12-06 21:45:42 +00:00
|
|
|
# Define static and shared library names
|
2017-05-24 08:48:10 +00:00
|
|
|
IF (ZSTD_BUILD_SHARED)
|
|
|
|
SET_TARGET_PROPERTIES(
|
|
|
|
libzstd_shared
|
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME zstd
|
|
|
|
SOVERSION ${LIBVER_MAJOR}.${LIBVER_MINOR}.${LIBVER_RELEASE})
|
|
|
|
ENDIF (ZSTD_BUILD_SHARED)
|
2016-01-10 11:20:52 +00:00
|
|
|
|
2017-03-20 14:47:28 +00:00
|
|
|
IF (ZSTD_BUILD_STATIC)
|
|
|
|
SET_TARGET_PROPERTIES(
|
|
|
|
libzstd_static
|
|
|
|
PROPERTIES
|
2017-05-24 08:48:10 +00:00
|
|
|
OUTPUT_NAME ${STATIC_LIBRARY_BASE_NAME})
|
2017-03-20 14:47:28 +00:00
|
|
|
ENDIF (ZSTD_BUILD_STATIC)
|
|
|
|
|
2016-01-10 11:20:52 +00:00
|
|
|
IF (UNIX)
|
2017-04-19 17:25:29 +00:00
|
|
|
# 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}"
|
2017-04-20 22:47:31 +00:00
|
|
|
-P "${CMAKE_CURRENT_SOURCE_DIR}/pkgconfig.cmake"
|
2017-04-19 17:25:29 +00:00
|
|
|
COMMENT "Creating pkg-config file")
|
|
|
|
|
|
|
|
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/libzstd.pc" DESTINATION "share/pkgconfig")
|
2017-05-24 08:48:10 +00:00
|
|
|
ENDIF (UNIX)
|
2016-01-10 11:20:52 +00:00
|
|
|
|
2017-05-24 08:48:10 +00:00
|
|
|
# install target
|
2017-08-31 19:20:50 +00:00
|
|
|
INSTALL(FILES
|
|
|
|
${LIBRARY_DIR}/zstd.h
|
|
|
|
${LIBRARY_DIR}/deprecated/zbuff.h
|
|
|
|
${LIBRARY_DIR}/dictBuilder/zdict.h
|
2017-05-24 08:48:10 +00:00
|
|
|
${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)
|
2016-01-10 11:20:52 +00:00
|
|
|
|
2017-05-24 08:48:10 +00:00
|
|
|
# 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)
|