mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-29 02:59:00 +08:00
Merge pull request #1030 from KindDragon/snappy
[snappy] Initial commit for Google Snappy library
This commit is contained in:
commit
63c613f1ed
164
ports/snappy/CMakeLists.txt
Normal file
164
ports/snappy/CMakeLists.txt
Normal file
@ -0,0 +1,164 @@
|
||||
# https://github.com/google/snappy/pull/29
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.4)
|
||||
PROJECT(snappy VERSION 1.1.4 LANGUAGES C CXX)
|
||||
|
||||
option(SNAPPY_BUILD_TESTS "Build snappy tests" OFF)
|
||||
|
||||
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
INCLUDE(CheckIncludeFiles)
|
||||
INCLUDE(CheckLibraryExists)
|
||||
INCLUDE(CheckCXXSourceCompiles)
|
||||
INCLUDE(CMakePackageConfigHelpers)
|
||||
|
||||
CHECK_INCLUDE_FILES("byteswap.h" HAVE_BYTESWAP_H)
|
||||
CHECK_INCLUDE_FILES("dlfcn.h" HAVE_DLFCN_H)
|
||||
CHECK_INCLUDE_FILES("inttypes.h" HAVE_INTTYPES_H)
|
||||
CHECK_INCLUDE_FILES("memory.h" HAVE_MEMORY_H)
|
||||
CHECK_INCLUDE_FILES("stddef.h" HAVE_STDDEF_H)
|
||||
CHECK_INCLUDE_FILES("stdint.h" HAVE_STDINT_H)
|
||||
CHECK_INCLUDE_FILES("stdlib.h" HAVE_STDLIB_H)
|
||||
CHECK_INCLUDE_FILES("strings.h" HAVE_STRINGS_H)
|
||||
CHECK_INCLUDE_FILES("string.h" HAVE_STRING_H)
|
||||
CHECK_INCLUDE_FILES("sys/byteswap.h" HAVE_SYS_BYTESWAP_H)
|
||||
CHECK_INCLUDE_FILES("sys/endian.h" HAVE_SYS_ENDIAN_H)
|
||||
CHECK_INCLUDE_FILES("sys/mman.h" HAVE_SYS_MMAN_H)
|
||||
CHECK_INCLUDE_FILES("sys/resource.h" HAVE_SYS_RESOURCE_H)
|
||||
CHECK_INCLUDE_FILES("sys/stat.h" HAVE_SYS_STAT_H)
|
||||
CHECK_INCLUDE_FILES("sys/time.h" HAVE_SYS_TIME_H)
|
||||
CHECK_INCLUDE_FILES("sys/types.h" HAVE_SYS_TYPES_H)
|
||||
CHECK_INCLUDE_FILES("sys/uio.h" HAVE_SYS_UIO_H)
|
||||
CHECK_INCLUDE_FILES("unistd.h" HAVE_UNISTD_H)
|
||||
CHECK_INCLUDE_FILES("windows.h" HAVE_WINDOWS_H)
|
||||
|
||||
IF (NOT HAVE_SYS_UIO_H)
|
||||
SET(HAVE_SYS_UIO_H 0)
|
||||
ENDIF (NOT HAVE_SYS_UIO_H)
|
||||
|
||||
IF (NOT HAVE_STDINT_H)
|
||||
SET(HAVE_STDINT_H 0)
|
||||
ENDIF (NOT HAVE_STDINT_H)
|
||||
|
||||
IF (NOT HAVE_STDDEF_H)
|
||||
SET(HAVE_STDDEF_H 0)
|
||||
ENDIF (NOT HAVE_STDDEF_H)
|
||||
|
||||
CHECK_CXX_SOURCE_COMPILES("int main(void) { return __builtin_expect(0, 1); }"
|
||||
HAVE_BUILTIN_EXPECT)
|
||||
|
||||
CHECK_CXX_SOURCE_COMPILES("int main(void) { return __builtin_ctzll(0); }"
|
||||
HAVE_BUILTIN_CTZ)
|
||||
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in config.h)
|
||||
|
||||
# Configure snappy-stubs-public.h.in
|
||||
SET(ac_cv_have_stdint_h ${HAVE_STDINT_H})
|
||||
SET(ac_cv_have_stddef_h ${HAVE_STDDEF_H})
|
||||
SET(ac_cv_have_sys_uio_h ${HAVE_SYS_UIO_H})
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/snappy-stubs-public.h.in
|
||||
snappy-stubs-public.h)
|
||||
|
||||
IF (MSVC AND (CMAKE_SIZEOF_VOID_P EQUAL 8))
|
||||
ADD_DEFINITIONS(-D__SSE2__)
|
||||
ENDIF (MSVC AND (CMAKE_SIZEOF_VOID_P EQUAL 8))
|
||||
|
||||
IF (WIN32)
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
|
||||
ENDIF (WIN32)
|
||||
|
||||
# Define the main library.
|
||||
ADD_LIBRARY(snappy
|
||||
snappy-c.cc
|
||||
snappy-c.h
|
||||
snappy-sinksource.cc
|
||||
snappy-sinksource.h
|
||||
snappy-stubs-internal.cc
|
||||
snappy-stubs-public.h
|
||||
snappy.cc
|
||||
snappy.h)
|
||||
|
||||
TARGET_COMPILE_DEFINITIONS(snappy PRIVATE -DHAVE_CONFIG_H)
|
||||
|
||||
SET_TARGET_PROPERTIES(snappy PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
|
||||
INSTALL(FILES snappy.h
|
||||
snappy-c.h
|
||||
snappy-sinksource.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/snappy-stubs-public.h
|
||||
DESTINATION include)
|
||||
|
||||
INSTALL(TARGETS snappy
|
||||
EXPORT SnappyTargets
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib)
|
||||
INSTALL(EXPORT SnappyTargets NAMESPACE Snappy:: DESTINATION share/snappy)
|
||||
|
||||
SET(INCLUDE_INSTALL_DIR include)
|
||||
SET(LIBRARY_INSTALL_DIR lib)
|
||||
SET(BINARY_INSTALL_DIR bin)
|
||||
|
||||
WRITE_BASIC_PACKAGE_VERSION_FILE(${CMAKE_CURRENT_BINARY_DIR}/SnappyConfigVersion.cmake
|
||||
COMPATIBILITY SameMajorVersion)
|
||||
CONFIGURE_PACKAGE_CONFIG_FILE(SnappyConfig.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/SnappyConfig.cmake
|
||||
INSTALL_DESTINATION share/snappy
|
||||
PATH_VARS INCLUDE_INSTALL_DIR LIBRARY_INSTALL_DIR BINARY_INSTALL_DIR
|
||||
)
|
||||
|
||||
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/SnappyConfig.cmake
|
||||
${CMAKE_CURRENT_BINARY_DIR}/SnappyConfigVersion.cmake
|
||||
DESTINATION share/snappy)
|
||||
|
||||
if (SNAPPY_BUILD_TESTS)
|
||||
FIND_PACKAGE(zlib QUIET)
|
||||
if (NOT ZLIB_FOUND)
|
||||
CHECK_LIBRARY_EXISTS(zlib zlibVersion "" HAVE_LIBZ)
|
||||
ENDIF (NOT ZLIB_FOUND)
|
||||
CHECK_LIBRARY_EXISTS(lzo2 lzo1x_1_15_compress "" HAVE_LIBLZO2)
|
||||
CHECK_LIBRARY_EXISTS(lzf lzf_compress "" HAVE_LIBLZF)
|
||||
CHECK_LIBRARY_EXISTS(fastlz fastlz_compress "" HAVE_LIBFASTLZ)
|
||||
CHECK_LIBRARY_EXISTS(quicklz qlz_compress "" HAVE_LIBQUICKLZ)
|
||||
|
||||
FIND_PACKAGE(GTest REQUIRED)
|
||||
SET(HAVE_GTEST 1)
|
||||
|
||||
FIND_PACKAGE(Gflags REQUIRED)
|
||||
SET(HAVE_GFLAGS 1)
|
||||
|
||||
ENABLE_TESTING()
|
||||
|
||||
IF (ZLIB_FOUND)
|
||||
set(HAVE_LIBZ 1)
|
||||
LIST(APPEND COMPRESSION_LIBS ${ZLIB_LIBRARIES})
|
||||
ELSE()
|
||||
LIST(APPEND COMPRESSION_LIBS zlib)
|
||||
ENDIF (ZLIB_FOUND)
|
||||
|
||||
IF (HAVE_LIBLZO2)
|
||||
LIST(APPEND COMPRESSION_LIBS lzo2)
|
||||
ENDIF (HAVE_LIBLZO2)
|
||||
|
||||
IF (HAVE_LIBLZF)
|
||||
LIST(APPEND COMPRESSION_LIBS lzf)
|
||||
ENDIF (HAVE_LIBLZF)
|
||||
|
||||
IF (HAVE_LIBFASTLZ)
|
||||
LIST(APPEND COMPRESSION_LIBS fastlz)
|
||||
ENDIF (HAVE_LIBFASTLZ)
|
||||
|
||||
IF (HAVE_LIBQUICKLZ)
|
||||
LIST(APPEND COMPRESSION_LIBS quicklz)
|
||||
ENDIF (HAVE_LIBQUICKLZ)
|
||||
|
||||
ADD_EXECUTABLE(snappy-unittest snappy_unittest.cc snappy-test.cc)
|
||||
TARGET_COMPILE_DEFINITIONS(snappy-unittest PRIVATE -DHAVE_CONFIG_H)
|
||||
TARGET_LINK_LIBRARIES(snappy-unittest snappy ${COMPRESSION_LIBS}
|
||||
${GFLAGS_LIBRARIES})
|
||||
TARGET_INCLUDE_DIRECTORIES(snappy-unittest BEFORE PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${GTEST_INCLUDE_DIRS} ${GFLAGS_INCLUDE_DIRS})
|
||||
|
||||
ADD_TEST(NAME snappy-unittest
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/snappy-unittest)
|
||||
endif (SNAPPY_BUILD_TESTS)
|
3
ports/snappy/CONTROL
Normal file
3
ports/snappy/CONTROL
Normal file
@ -0,0 +1,3 @@
|
||||
Source: snappy
|
||||
Version: 1.1.4-1
|
||||
Description: A fast compressor/decompressor.
|
9
ports/snappy/SnappyConfig.cmake.in
Normal file
9
ports/snappy/SnappyConfig.cmake.in
Normal file
@ -0,0 +1,9 @@
|
||||
set(SNAPPY_VERSION @SNAPPY_MAJOR@.@SNAPPY_MINOR@.@SNAPPY_PATCHLEVEL@)
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
set_and_check(SNAPPY_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
|
||||
set_and_check(SNAPPY_LIBRARY_DIR "@PACKAGE_LIBRARY_INSTALL_DIR@")
|
||||
set_and_check(SNAPPY_BINARY_DIR "@PACKAGE_BINARY_INSTALL_DIR@")
|
||||
|
||||
check_required_components(SNAPPY)
|
95
ports/snappy/config.h.in
Normal file
95
ports/snappy/config.h.in
Normal file
@ -0,0 +1,95 @@
|
||||
#ifndef SNAPPY_CONFIG_H
|
||||
#define SNAPPY_CONFIG_H 1
|
||||
|
||||
/* Define to 1 if the compiler supports __builtin_ctz and friends. */
|
||||
#cmakedefine HAVE_BUILTIN_CTZ ${HAVE_BUILTIN_CTZ}
|
||||
|
||||
/* Define to 1 if the compiler supports __builtin_expect. */
|
||||
#cmakedefine HAVE_BUILTIN_EXPECT ${HAVE_BUILTIN_EXPECT}
|
||||
|
||||
/* Define to 1 if you have the <byteswap.h> header file. */
|
||||
#cmakedefine HAVE_BYTESWAP_H ${HAVE_BYTESWAP_H}
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#cmakedefine HAVE_DLFCN_H ${HAVE_DLFCN_H}
|
||||
|
||||
/* Use the gflags package for command-line parsing. */
|
||||
#cmakedefine HAVE_GFLAGS ${HAVE_GFLAGS}
|
||||
|
||||
/* Defined when Google Test is available. */
|
||||
#cmakedefine HAVE_GTEST ${HAVE_GTEST}
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H}
|
||||
|
||||
/* Define to 1 if you have the `fastlz' library (-lfastlz). */
|
||||
#cmakedefine HAVE_LIBFASTLZ ${HAVE_LIBFASTLZ}
|
||||
|
||||
/* Define to 1 if you have the `lzf' library (-llzf). */
|
||||
#cmakedefine HAVE_LIBLZF ${HAVE_LIBLZF}
|
||||
|
||||
/* Define to 1 if you have the `lzo2' library (-llzo2). */
|
||||
#cmakedefine HAVE_LIBLZO2 ${HAVE_LIBLZO2}
|
||||
|
||||
/* Define to 1 if you have the `quicklz' library (-lquicklz). */
|
||||
#cmakedefine HAVE_LIBQUICKLZ ${HAVE_LIBQUICKLZ}
|
||||
|
||||
/* Define to 1 if you have the `z' library (-lz). */
|
||||
#cmakedefine HAVE_LIBZ ${HAVE_LIBZ}
|
||||
|
||||
/* Define to 1 if you have the <sys/uio.h> header file. */
|
||||
#cmakedefine HAVE_SYS_UIO_H ${HAVE_SYS_UIO_H}
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#cmakedefine HAVE_MEMORY_H ${HAVE_MEMORY_H}
|
||||
|
||||
/* Define to 1 if you have the <stddef.h> header file. */
|
||||
#cmakedefine HAVE_STDDEF_H ${HAVE_STDDEF_H}
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H}
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#cmakedefine HAVE_STDLIB_H ${HAVE_STDLIB_H}
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#cmakedefine HAVE_STRINGS_H ${HAVE_STRINGS_H}
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#cmakedefine HAVE_STRING_H ${HAVE_STRING_H}
|
||||
|
||||
/* Define to 1 if you have the <sys/byteswap.h> header file. */
|
||||
#cmakedefine HAVE_SYS_BYTESWAP_H ${HAVE_SYS_BYTESWAP_H}
|
||||
|
||||
/* Define to 1 if you have the <sys/endian.h> header file. */
|
||||
#cmakedefine HAVE_SYS_ENDIAN_H ${HAVE_SYS_ENDIAN_H}
|
||||
|
||||
/* Define to 1 if you have the <sys/mman.h> header file. */
|
||||
#cmakedefine HAVE_SYS_MMAN_H ${HAVE_SYS_MMAN_H}
|
||||
|
||||
/* Define to 1 if you have the <sys/resource.h> header file. */
|
||||
#cmakedefine HAVE_SYS_RESOURCE_H ${HAVE_SYS_RESOURCE_H}
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#cmakedefine HAVE_SYS_STAT_H ${HAVE_SYS_STAT_H}
|
||||
|
||||
/* Define to 1 if you have the <sys/time.h> header file. */
|
||||
#cmakedefine HAVE_SYS_TIME_H ${HAVE_SYS_TIME_H}
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#cmakedefine HAVE_SYS_TYPES_H ${HAVE_SYS_TYPES}
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#cmakedefine HAVE_UNISTD_H ${HAVE_UNISTD_H}
|
||||
|
||||
/* Define to 1 if you have the <windows.h> header file. */
|
||||
#cmakedefine HAVE_WINDOWS_H ${HAVE_WINDOWS_H}
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel and VAX). */
|
||||
#cmakedefine WORDS_BIGENDIAN
|
||||
|
||||
#endif
|
26
ports/snappy/portfile.cmake
Normal file
26
ports/snappy/portfile.cmake
Normal file
@ -0,0 +1,26 @@
|
||||
include(vcpkg_common_functions)
|
||||
|
||||
vcpkg_from_github(
|
||||
OUT_SOURCE_PATH SOURCE_PATH
|
||||
REPO google/snappy
|
||||
REF 1.1.4
|
||||
SHA512 873f655713611f4bdfc13ab2a6d09245681f427fbd4f6a7a880a49b8c526875dbdd623e203905450268f542be24a2dc9dae50e6acc1516af1d2ffff3f96553da
|
||||
HEAD_REF master
|
||||
)
|
||||
|
||||
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
|
||||
file(COPY ${CMAKE_CURRENT_LIST_DIR}/SnappyConfig.cmake.in DESTINATION ${SOURCE_PATH})
|
||||
file(COPY ${CMAKE_CURRENT_LIST_DIR}/config.h.in DESTINATION ${SOURCE_PATH})
|
||||
|
||||
vcpkg_configure_cmake(
|
||||
SOURCE_PATH ${SOURCE_PATH})
|
||||
|
||||
vcpkg_install_cmake()
|
||||
vcpkg_copy_pdbs()
|
||||
|
||||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
|
||||
file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/share/snappy/SnappyConfigVersion.cmake)
|
||||
vcpkg_fixup_cmake_targets()
|
||||
|
||||
file(COPY ${CURRENT_BUILDTREES_DIR}/src/snappy-1.1.4/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/snappy)
|
||||
file(RENAME ${CURRENT_PACKAGES_DIR}/share/snappy/COPYING ${CURRENT_PACKAGES_DIR}/share/snappy/copyright)
|
Loading…
Reference in New Issue
Block a user