summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/zstd/build/cmake/lib
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/zstd/build/cmake/lib')
-rw-r--r--3rdparty/zstd/build/cmake/lib/.gitignore2
-rw-r--r--3rdparty/zstd/build/cmake/lib/CMakeLists.txt181
-rw-r--r--3rdparty/zstd/build/cmake/lib/cmake_uninstall.cmake.in22
3 files changed, 205 insertions, 0 deletions
diff --git a/3rdparty/zstd/build/cmake/lib/.gitignore b/3rdparty/zstd/build/cmake/lib/.gitignore
new file mode 100644
index 00000000000..a4444c8d3ed
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/lib/.gitignore
@@ -0,0 +1,2 @@
+# cmake build artefact
+libzstd.pc
diff --git a/3rdparty/zstd/build/cmake/lib/CMakeLists.txt b/3rdparty/zstd/build/cmake/lib/CMakeLists.txt
new file mode 100644
index 00000000000..30349586ba9
--- /dev/null
+++ b/3rdparty/zstd/build/cmake/lib/CMakeLists.txt
@@ -0,0 +1,181 @@
+# ################################################################
+# Copyright (c) Meta Platforms, Inc. and affiliates.
+# 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 C ASM)
+
+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 libzstd")
+endif()
+
+# Define library directory, where sources and header files are located
+include_directories(${LIBRARY_DIR} ${LIBRARY_DIR}/common)
+
+file(GLOB CommonSources ${LIBRARY_DIR}/common/*.c)
+file(GLOB CompressSources ${LIBRARY_DIR}/compress/*.c)
+if (MSVC)
+ file(GLOB DecompressSources ${LIBRARY_DIR}/decompress/*.c)
+ add_compile_options(-DZSTD_DISABLE_ASM)
+else ()
+ file(GLOB DecompressSources ${LIBRARY_DIR}/decompress/*.c ${LIBRARY_DIR}/decompress/*.S)
+endif ()
+file(GLOB DictBuilderSources ${LIBRARY_DIR}/dictBuilder/*.c)
+
+set(Sources
+ ${CommonSources}
+ ${CompressSources}
+ ${DecompressSources}
+ ${DictBuilderSources})
+
+file(GLOB CommonHeaders ${LIBRARY_DIR}/common/*.h)
+file(GLOB CompressHeaders ${LIBRARY_DIR}/compress/*.h)
+file(GLOB DecompressHeaders ${LIBRARY_DIR}/decompress/*.h)
+file(GLOB DictBuilderHeaders ${LIBRARY_DIR}/dictBuilder/*.h)
+
+set(Headers
+ ${LIBRARY_DIR}/zstd.h
+ ${CommonHeaders}
+ ${CompressHeaders}
+ ${DecompressHeaders}
+ ${DictBuilderHeaders})
+
+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 ()
+
+if (MSVC)
+ set(MSVC_RESOURCE_DIR ${ZSTD_SOURCE_DIR}/build/VS2010/libzstd-dll)
+ set(PlatformDependResources ${MSVC_RESOURCE_DIR}/libzstd-dll.rc)
+endif ()
+
+# Explicitly set the language to C for all files, including ASM files.
+# Our assembly expects to be compiled by a C compiler, and is only enabled for
+# __GNUC__ compatible compilers. Otherwise all the ASM code is disabled by
+# macros.
+set_source_files_properties(${Sources} PROPERTIES LANGUAGE C)
+
+# Split project to static and shared libraries build
+set(library_targets)
+if (ZSTD_BUILD_SHARED)
+ add_library(libzstd_shared SHARED ${Sources} ${Headers} ${PlatformDependResources})
+ list(APPEND library_targets libzstd_shared)
+ if (ZSTD_MULTITHREAD_SUPPORT)
+ set_property(TARGET libzstd_shared APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD")
+ if (UNIX)
+ target_link_libraries(libzstd_shared ${THREADS_LIBS})
+ endif ()
+ endif()
+endif ()
+if (ZSTD_BUILD_STATIC)
+ add_library(libzstd_static STATIC ${Sources} ${Headers})
+ list(APPEND library_targets libzstd_static)
+ if (ZSTD_MULTITHREAD_SUPPORT)
+ set_property(TARGET libzstd_static APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_MULTITHREAD")
+ if (UNIX)
+ target_link_libraries(libzstd_static ${THREADS_LIBS})
+ endif ()
+ endif ()
+endif ()
+
+# 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 ()
+ if (ZSTD_BUILD_STATIC)
+ set_property(TARGET libzstd_static APPEND PROPERTY COMPILE_DEFINITIONS "ZSTD_HEAPMODE=0;_CRT_SECURE_NO_WARNINGS")
+ endif ()
+endif ()
+
+# With MSVC static library needs to be renamed to avoid conflict with import library
+if (MSVC OR (WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT MINGW))
+ set(STATIC_LIBRARY_BASE_NAME zstd_static)
+else ()
+ set(STATIC_LIBRARY_BASE_NAME zstd)
+endif ()
+
+# Define static and shared library names
+if (ZSTD_BUILD_SHARED)
+ set_target_properties(
+ libzstd_shared
+ PROPERTIES
+ OUTPUT_NAME zstd
+ VERSION ${zstd_VERSION_MAJOR}.${zstd_VERSION_MINOR}.${zstd_VERSION_PATCH}
+ SOVERSION ${zstd_VERSION_MAJOR})
+endif ()
+
+if (ZSTD_BUILD_STATIC)
+ set_target_properties(
+ libzstd_static
+ PROPERTIES
+ POSITION_INDEPENDENT_CODE On
+ OUTPUT_NAME ${STATIC_LIBRARY_BASE_NAME})
+endif ()
+
+# pkg-config
+include(JoinPaths) # can be replaced by cmake_path(APPEND) in CMake 3.20
+set(PREFIX "${CMAKE_INSTALL_PREFIX}")
+set(EXEC_PREFIX "\${prefix}")
+join_paths(LIBDIR "\${exec_prefix}" "${CMAKE_INSTALL_LIBDIR}")
+join_paths(INCLUDEDIR "\${prefix}" "${CMAKE_INSTALL_INCLUDEDIR}")
+set(LIBS_PRIVATE "${THREADS_LIBS}")
+set(VERSION "${zstd_VERSION}")
+
+configure_file("${LIBRARY_DIR}/libzstd.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/libzstd.pc" @ONLY)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libzstd.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+
+# install target
+install(FILES
+ "${LIBRARY_DIR}/zstd.h"
+ "${LIBRARY_DIR}/zdict.h"
+ "${LIBRARY_DIR}/zstd_errors.h"
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
+
+install(TARGETS ${library_targets}
+ EXPORT zstdExports
+ INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ BUNDLE DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ )
+
+# uninstall target
+if (NOT TARGET uninstall)
+ 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)
+endif ()
diff --git a/3rdparty/zstd/build/cmake/lib/cmake_uninstall.cmake.in b/3rdparty/zstd/build/cmake/lib/cmake_uninstall.cmake.in
new file mode 100644
index 00000000000..9f1d045ddfa
--- /dev/null
+++ b/3rdparty/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()
+
+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()
+ else()
+ message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
+ endif()
+endforeach()