blob: de52666d2872262e3b39144d5c3c8c7b97ad6407 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
PROJECT(Snappy VERSION 1.1.6 LANGUAGES C CXX)
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
INCLUDE(CheckIncludeFiles)
INCLUDE(CheckLibraryExists)
INCLUDE(CheckCXXSourceCompiles)
INCLUDE(TestBigEndian)
INCLUDE(CMakePackageConfigHelpers)
TEST_BIG_ENDIAN(WORDS_BIG_ENDIAN)
IF (WORDS_BIG_ENDIAN)
MESSAGE(STATUS "Building on big endian system")
ADD_DEFINITIONS(-DWORDS_BIGENDIAN=1)
ENDIF (WORDS_BIG_ENDIAN)
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_LIBRARY_EXISTS(z zlibVersion "" HAVE_LIBZ)
CHECK_LIBRARY_EXISTS(lzo2 lzo1x_1_15_compress "" HAVE_LIBLZO2)
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)
FIND_PACKAGE(GTest QUIET)
IF(GTEST_FOUND)
SET(HAVE_GTEST 1)
ENDIF()
FIND_PACKAGE(Gflags QUIET)
IF(GFLAGS_FOUND)
SET(HAVE_GFLAGS 1)
ENDIF()
CONFIGURE_FILE(${Snappy_SOURCE_DIR}/cmake/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(${Snappy_SOURCE_DIR}/snappy-stubs-public.h.in
snappy-stubs-public.h)
IF (WIN32)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
ENDIF (WIN32)
# Define the main library.
ADD_LIBRARY(snappy SHARED
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
${Snappy_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 lib/cmake/Snappy)
SET_TARGET_PROPERTIES(snappy PROPERTIES VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR})
SET(INCLUDE_INSTALL_DIR include)
SET(LIBRARY_INSTALL_DIR lib)
SET(BINARY_INSTALL_DIR bin)
CONFIGURE_PACKAGE_CONFIG_FILE(cmake/SnappyConfig.cmake.in
${Snappy_BINARY_DIR}/SnappyConfig.cmake
INSTALL_DESTINATION lib/Snappy/cmake
PATH_VARS INCLUDE_INSTALL_DIR LIBRARY_INSTALL_DIR BINARY_INSTALL_DIR
)
WRITE_BASIC_PACKAGE_VERSION_FILE(${Snappy_BINARY_DIR}/SnappyConfigVersion.cmake
COMPATIBILITY SameMajorVersion)
INSTALL(FILES ${Snappy_BINARY_DIR}/SnappyConfig.cmake
${Snappy_BINARY_DIR}/SnappyConfigVersion.cmake
DESTINATION lib/cmake)
ENABLE_TESTING()
IF (HAVE_LIBZ)
LIST(APPEND COMPRESSION_LIBS z)
ENDIF (HAVE_LIBZ)
IF (HAVE_LIBLZO2)
LIST(APPEND COMPRESSION_LIBS lzo2)
ENDIF (HAVE_LIBLZO2)
IF (HAVE_LIBLZF)
LIST(APPEND COMPRESSION_LIBS lzf)
ENDIF (HAVE_LIBLZF)
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 ${Snappy_SOURCE_DIR}
${GTEST_INCLUDE_DIRS} ${GFLAGS_INCLUDE_DIRS})
ADD_TEST(NAME snappy-unittest
WORKING_DIRECTORY ${Snappy_SOURCE_DIR}
COMMAND ${Snappy_BINARY_DIR}/snappy-unittest)
|