]> git.proxmox.com Git - ceph.git/blame - ceph/src/zstd/build/cmake/programs/CMakeLists.txt
import 15.2.0 Octopus source
[ceph.git] / ceph / src / zstd / build / cmake / programs / CMakeLists.txt
CommitLineData
7c673cae 1# ################################################################
11fdf7f2 2# Copyright (c) 2015-present, Yann Collet, Facebook, Inc.
7c673cae
FG
3# All rights reserved.
4#
11fdf7f2
TL
5# This source code is licensed under both the BSD-style license (found in the
6# LICENSE file in the root directory of this source tree) and the GPLv2 (found
7# in the COPYING file in the root directory of this source tree).
7c673cae
FG
8# ################################################################
9
9f95a23c 10project(programs)
7c673cae 11
9f95a23c 12set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
7c673cae 13
7c673cae 14# Define programs directory, where sources and header files are located
9f95a23c
TL
15set(LIBRARY_DIR ${ZSTD_SOURCE_DIR}/lib)
16set(PROGRAMS_DIR ${ZSTD_SOURCE_DIR}/programs)
17include_directories(${PROGRAMS_DIR} ${LIBRARY_DIR} ${LIBRARY_DIR}/common ${LIBRARY_DIR}/compress ${LIBRARY_DIR}/dictBuilder)
18
19if (ZSTD_LEGACY_SUPPORT)
20 set(PROGRAMS_LEGACY_DIR ${PROGRAMS_DIR}/legacy)
21 include_directories(${PROGRAMS_LEGACY_DIR} ${LIBRARY_DIR}/legacy)
22endif ()
23
24if (MSVC)
25 set(MSVC_RESOURCE_DIR ${ZSTD_SOURCE_DIR}/build/VS2010/zstd)
26 set(PlatformDependResources ${MSVC_RESOURCE_DIR}/zstd.rc)
27endif ()
28
29add_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})
30target_link_libraries(zstd libzstd_static)
31if (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
32 target_link_libraries(zstd rt)
33endif ()
34install(TARGETS zstd RUNTIME DESTINATION "bin")
35
36if (UNIX)
37 add_custom_target(zstdcat ALL ${CMAKE_COMMAND} -E create_symlink zstd zstdcat DEPENDS zstd COMMENT "Creating zstdcat symlink")
38 add_custom_target(unzstd ALL ${CMAKE_COMMAND} -E create_symlink zstd unzstd DEPENDS zstd COMMENT "Creating unzstd symlink")
39 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zstdcat DESTINATION "bin")
40 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unzstd DESTINATION "bin")
41
42 add_custom_target(zstd.1 ALL
11fdf7f2
TL
43 ${CMAKE_COMMAND} -E copy ${PROGRAMS_DIR}/zstd.1 .
44 COMMENT "Copying manpage zstd.1")
9f95a23c
TL
45 add_custom_target(zstdgrep.1 ALL
46 ${CMAKE_COMMAND} -E copy ${PROGRAMS_DIR}/zstdgrep.1 .
47 COMMENT "Copying manpage zstdgrep.1")
48 add_custom_target(zstdless.1 ALL
49 ${CMAKE_COMMAND} -E copy ${PROGRAMS_DIR}/zstdless.1 .
50 COMMENT "Copying manpage zstdless.1")
51 add_custom_target(zstdcat.1 ALL ${CMAKE_COMMAND} -E create_symlink zstd.1 zstdcat.1 DEPENDS zstd.1 COMMENT "Creating zstdcat.1 symlink")
52 add_custom_target(unzstd.1 ALL ${CMAKE_COMMAND} -E create_symlink zstd.1 unzstd.1 DEPENDS zstd.1 COMMENT "Creating unzstd.1 symlink")
53
54 # Define MAN_INSTALL_DIR if necessary
55 if (MAN_INSTALL_DIR)
56 else ()
57 set(MAN_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/share/man/man1)
58 endif ()
59
60 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zstd.1 DESTINATION "${MAN_INSTALL_DIR}")
61 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zstdcat.1 DESTINATION "${MAN_INSTALL_DIR}")
62 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/unzstd.1 DESTINATION "${MAN_INSTALL_DIR}")
63 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zstdgrep.1 DESTINATION "${MAN_INSTALL_DIR}")
64 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zstdless.1 DESTINATION "${MAN_INSTALL_DIR}")
65
66 add_executable(zstd-frugal ${PROGRAMS_DIR}/zstdcli.c ${PROGRAMS_DIR}/util.c ${PROGRAMS_DIR}/timefn.c ${PROGRAMS_DIR}/fileio.c)
67 target_link_libraries(zstd-frugal libzstd_static)
68 set_property(TARGET zstd-frugal APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_NOBENCH;ZSTD_NODICT")
69endif ()
70
71# Add multi-threading support definitions
72
73if (ZSTD_MULTITHREAD_SUPPORT)
74 set_property(TARGET zstd APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD")
75
76 if (UNIX)
77 target_link_libraries(zstd ${THREADS_LIBS})
78
79 add_custom_target(zstdmt ALL ${CMAKE_COMMAND} -E create_symlink zstd zstdmt DEPENDS zstd COMMENT "Creating zstdmt symlink")
80 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/zstdmt DESTINATION "bin")
81 endif ()
82endif ()
83
84option(ZSTD_ZLIB_SUPPORT "ZLIB SUPPORT" OFF)
85option(ZSTD_LZMA_SUPPORT "LZMA SUPPORT" OFF)
86
87if (ZSTD_ZLIB_SUPPORT)
88 find_package(ZLIB REQUIRED)
89
90 if (ZLIB_FOUND)
91 include_directories(${ZLIB_INCLUDE_DIRS})
92 target_link_libraries(zstd ${ZLIB_LIBRARIES})
93 set_property(TARGET zstd APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_GZCOMPRESS;ZSTD_GZDECOMPRESS")
94 else ()
95 message(SEND_ERROR "zlib library is missing")
96 endif ()
97endif ()
98
99if (ZSTD_LZMA_SUPPORT)
100 find_package(LibLZMA REQUIRED)
101
102 if (LIBLZMA_FOUND)
103 include_directories(${LIBLZMA_INCLUDE_DIRS})
104 target_link_libraries(zstd ${LIBLZMA_LIBRARIES})
105 set_property(TARGET zstd APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_LZMACOMPRESS;ZSTD_LZMADECOMPRESS")
106 else ()
107 message(SEND_ERROR "lzma library is missing")
108 endif ()
109endif ()