2016-01-07 02:37:00 -08:00
|
|
|
# ################################################################
|
2017-08-31 12:11:57 -07:00
|
|
|
# Copyright (c) 2015-present, Yann Collet, Facebook, Inc.
|
|
|
|
# All rights reserved.
|
2016-01-07 02:37:00 -08:00
|
|
|
#
|
2017-08-31 12:11:57 -07: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-07 02:37:00 -08:00
|
|
|
# ################################################################
|
|
|
|
|
2018-12-22 17:31:59 -08:00
|
|
|
project(programs)
|
2016-01-07 02:37:00 -08:00
|
|
|
|
2018-12-22 17:31:59 -08:00
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
|
2016-01-10 03:20:52 -08:00
|
|
|
|
2016-01-11 08:50:57 -08:00
|
|
|
# Define programs directory, where sources and header files are located
|
2018-12-22 17:31:59 -08:00
|
|
|
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)
|
2018-12-22 17:31:50 -08:00
|
|
|
endif ()
|
2018-12-22 17:31:59 -08:00
|
|
|
|
2019-10-29 06:33:50 -07:00
|
|
|
if (ZSTD_PROGRAMS_LINK_SHARED)
|
|
|
|
set(PROGRAMS_ZSTD_LINK_TARGET libzstd_shared)
|
|
|
|
else ()
|
|
|
|
set(PROGRAMS_ZSTD_LINK_TARGET libzstd_static)
|
|
|
|
endif ()
|
|
|
|
|
2018-12-22 17:31:59 -08:00
|
|
|
if (MSVC)
|
|
|
|
set(MSVC_RESOURCE_DIR ${ZSTD_SOURCE_DIR}/build/VS2010/zstd)
|
|
|
|
set(PlatformDependResources ${MSVC_RESOURCE_DIR}/zstd.rc)
|
2018-12-22 17:31:50 -08:00
|
|
|
endif ()
|
2018-12-22 17:31:59 -08:00
|
|
|
|
2019-04-10 14:54:13 -07:00
|
|
|
add_executable(zstd ${PROGRAMS_DIR}/zstdcli.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${PROGRAMS_DIR}/fileio.c ${PROGRAMS_DIR}/benchfn.c ${PROGRAMS_DIR}/benchzstd.c ${PROGRAMS_DIR}/datagen.c ${PROGRAMS_DIR}/dibio.c ${PlatformDependResources})
|
2019-10-29 06:33:50 -07:00
|
|
|
target_link_libraries(zstd ${PROGRAMS_ZSTD_LINK_TARGET})
|
2018-12-22 17:31:59 -08:00
|
|
|
if (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
|
|
|
|
target_link_libraries(zstd rt)
|
2018-12-22 17:31:50 -08:00
|
|
|
endif ()
|
2019-09-16 01:36:37 -07:00
|
|
|
install(TARGETS zstd RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
2018-12-22 17:31:59 -08:00
|
|
|
|
|
|
|
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")
|
2019-09-16 01:36:37 -07:00
|
|
|
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}")
|
2018-12-22 17:31:59 -08:00
|
|
|
|
|
|
|
add_custom_target(zstd.1 ALL
|
2017-04-19 10:22:17 -07:00
|
|
|
${CMAKE_COMMAND} -E copy ${PROGRAMS_DIR}/zstd.1 .
|
|
|
|
COMMENT "Copying manpage zstd.1")
|
2018-12-22 17:31:59 -08:00
|
|
|
add_custom_target(zstdgrep.1 ALL
|
2018-10-15 02:20:10 -07:00
|
|
|
${CMAKE_COMMAND} -E copy ${PROGRAMS_DIR}/zstdgrep.1 .
|
|
|
|
COMMENT "Copying manpage zstdgrep.1")
|
2018-12-22 17:31:59 -08:00
|
|
|
add_custom_target(zstdless.1 ALL
|
2018-10-15 02:20:10 -07:00
|
|
|
${CMAKE_COMMAND} -E copy ${PROGRAMS_DIR}/zstdless.1 .
|
|
|
|
COMMENT "Copying manpage zstdless.1")
|
2018-12-22 17:31:59 -08:00
|
|
|
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")
|
2018-03-21 01:40:42 -07:00
|
|
|
|
2018-03-26 14:58:33 -07:00
|
|
|
# Define MAN_INSTALL_DIR if necessary
|
2018-12-22 17:31:59 -08:00
|
|
|
if (MAN_INSTALL_DIR)
|
2018-12-22 17:31:50 -08:00
|
|
|
else ()
|
2019-09-16 01:36:37 -07:00
|
|
|
set(MAN_INSTALL_DIR ${CMAKE_INSTALL_MANDIR}/man1)
|
2018-12-22 17:31:50 -08:00
|
|
|
endif ()
|
2018-12-22 17:31:59 -08:00
|
|
|
|
2019-09-16 01:36:37 -07:00
|
|
|
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}")
|
2018-12-22 17:31:59 -08:00
|
|
|
|
2019-04-10 14:54:13 -07:00
|
|
|
add_executable(zstd-frugal ${PROGRAMS_DIR}/zstdcli.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${PROGRAMS_DIR}/fileio.c)
|
2019-10-29 06:33:50 -07:00
|
|
|
target_link_libraries(zstd-frugal ${PROGRAMS_ZSTD_LINK_TARGET})
|
2018-12-22 17:31:59 -08:00
|
|
|
set_property(TARGET zstd-frugal APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_NOBENCH;ZSTD_NODICT")
|
2018-12-22 17:31:50 -08:00
|
|
|
endif ()
|
2017-02-09 06:11:05 -08:00
|
|
|
|
2018-01-16 23:27:52 -08:00
|
|
|
# Add multi-threading support definitions
|
|
|
|
|
2018-12-22 17:31:59 -08:00
|
|
|
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")
|
2019-09-16 01:36:37 -07:00
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zstdmt DESTINATION "${CMAKE_INSTALL_BINDIR}")
|
2018-12-22 17:31:50 -08:00
|
|
|
endif ()
|
|
|
|
endif ()
|
2018-12-22 17:31:59 -08:00
|
|
|
|
|
|
|
option(ZSTD_ZLIB_SUPPORT "ZLIB SUPPORT" OFF)
|
|
|
|
option(ZSTD_LZMA_SUPPORT "LZMA SUPPORT" OFF)
|
2019-06-03 03:19:59 -07:00
|
|
|
option(ZSTD_LZ4_SUPPORT "LZ4 SUPPORT" OFF)
|
2018-12-22 17:31:59 -08:00
|
|
|
|
2019-06-03 03:19:59 -07:00
|
|
|
# Add gzip support
|
2018-12-22 17:31:59 -08:00
|
|
|
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 ()
|
|
|
|
|
2019-06-03 03:19:59 -07:00
|
|
|
# Add lzma support
|
2018-12-22 17:31:59 -08:00
|
|
|
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 ()
|
2019-06-03 03:19:59 -07:00
|
|
|
|
|
|
|
# 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 ()
|