snappy 0.0.14-java → 0.2.0-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/main.yml +34 -0
  3. data/.github/workflows/publish.yml +34 -0
  4. data/Gemfile +4 -0
  5. data/README.md +28 -4
  6. data/Rakefile +32 -29
  7. data/ext/api.c +6 -1
  8. data/ext/extconf.rb +21 -24
  9. data/lib/snappy.rb +6 -4
  10. data/lib/snappy/hadoop.rb +22 -0
  11. data/lib/snappy/hadoop/reader.rb +62 -0
  12. data/lib/snappy/hadoop/writer.rb +51 -0
  13. data/lib/snappy/reader.rb +19 -11
  14. data/lib/snappy/shim.rb +30 -0
  15. data/lib/snappy/version.rb +3 -1
  16. data/lib/snappy/writer.rb +8 -9
  17. data/snappy.gemspec +17 -37
  18. data/test/hadoop/snappy_hadoop_reader_test.rb +115 -0
  19. data/test/hadoop/snappy_hadoop_writer_test.rb +48 -0
  20. data/test/snappy_hadoop_test.rb +26 -0
  21. data/test/snappy_reader_test.rb +148 -0
  22. data/test/snappy_test.rb +95 -0
  23. data/test/snappy_writer_test.rb +55 -0
  24. data/test/test_helper.rb +7 -0
  25. data/vendor/snappy/CMakeLists.txt +297 -0
  26. data/vendor/snappy/CONTRIBUTING.md +26 -0
  27. data/vendor/snappy/COPYING +1 -1
  28. data/vendor/snappy/NEWS +60 -0
  29. data/vendor/snappy/{README → README.md} +29 -16
  30. data/vendor/snappy/cmake/SnappyConfig.cmake.in +33 -0
  31. data/vendor/snappy/cmake/config.h.in +62 -0
  32. data/vendor/snappy/docs/README.md +72 -0
  33. data/vendor/snappy/snappy-c.h +3 -3
  34. data/vendor/snappy/snappy-internal.h +113 -32
  35. data/vendor/snappy/snappy-sinksource.cc +33 -0
  36. data/vendor/snappy/snappy-sinksource.h +51 -6
  37. data/vendor/snappy/snappy-stubs-internal.cc +1 -1
  38. data/vendor/snappy/snappy-stubs-internal.h +160 -45
  39. data/vendor/snappy/snappy-stubs-public.h.in +23 -47
  40. data/vendor/snappy/snappy-test.cc +31 -24
  41. data/vendor/snappy/snappy-test.h +46 -103
  42. data/vendor/snappy/snappy.cc +786 -431
  43. data/vendor/snappy/snappy.h +37 -14
  44. data/vendor/snappy/snappy_compress_fuzzer.cc +59 -0
  45. data/vendor/snappy/snappy_uncompress_fuzzer.cc +57 -0
  46. data/vendor/snappy/snappy_unittest.cc +441 -290
  47. metadata +35 -75
  48. data/.travis.yml +0 -4
  49. data/test/test-snappy-reader.rb +0 -129
  50. data/test/test-snappy-writer.rb +0 -55
  51. data/test/test-snappy.rb +0 -58
  52. data/vendor/snappy/ChangeLog +0 -1916
  53. data/vendor/snappy/Makefile.am +0 -23
  54. data/vendor/snappy/autogen.sh +0 -7
  55. data/vendor/snappy/configure.ac +0 -133
  56. data/vendor/snappy/m4/gtest.m4 +0 -74
  57. data/vendor/snappy/testdata/alice29.txt +0 -3609
  58. data/vendor/snappy/testdata/asyoulik.txt +0 -4122
  59. data/vendor/snappy/testdata/baddata1.snappy +0 -0
  60. data/vendor/snappy/testdata/baddata2.snappy +0 -0
  61. data/vendor/snappy/testdata/baddata3.snappy +0 -0
  62. data/vendor/snappy/testdata/fireworks.jpeg +0 -0
  63. data/vendor/snappy/testdata/geo.protodata +0 -0
  64. data/vendor/snappy/testdata/html +0 -1
  65. data/vendor/snappy/testdata/html_x_4 +0 -1
  66. data/vendor/snappy/testdata/kppkn.gtb +0 -0
  67. data/vendor/snappy/testdata/lcet10.txt +0 -7519
  68. data/vendor/snappy/testdata/paper-100k.pdf +2 -600
  69. data/vendor/snappy/testdata/plrabn12.txt +0 -10699
  70. data/vendor/snappy/testdata/urls.10K +0 -10000
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+
5
+ class SnappyTest < Test::Unit::TestCase
6
+ T = [*"a".."z", *"A".."Z", *"0".."9"].freeze
7
+
8
+ def random_data(length = 1024)
9
+ Array.new(length) { T.sample }.join
10
+ end
11
+
12
+ test "VERSION" do
13
+ assert do
14
+ ::Snappy.const_defined?(:VERSION)
15
+ end
16
+ end
17
+
18
+ test "well done" do
19
+ s = random_data
20
+ assert_equal s, Snappy.inflate(Snappy.deflate(s))
21
+ end
22
+
23
+ test "well done (pair)" do
24
+ s = random_data
25
+ [
26
+ %i[deflate inflate],
27
+ %i[compress uncompress],
28
+ %i[dump load]
29
+ ].each do |(i, o)|
30
+ assert_equal s, Snappy.__send__(o, Snappy.__send__(i, s))
31
+ end
32
+ end
33
+
34
+ sub_test_case ".deflate" do
35
+ test "can pass buffer" do
36
+ if defined? JRUBY_VERSION
37
+ notify "cannot pass buffer in jruby"
38
+ omit
39
+ end
40
+ s = random_data
41
+ d = " " * 1024
42
+ r = Snappy.deflate(s, d)
43
+ assert_equal r.object_id, d.object_id
44
+ end
45
+ end
46
+
47
+ sub_test_case ".inflate" do
48
+ test "can pass buffer" do
49
+ if defined? JRUBY_VERSION
50
+ notify "cannot pass buffer in jruby"
51
+ omit
52
+ end
53
+ s = Snappy.deflate(random_data)
54
+ d = " " * 1024
55
+ r = Snappy.inflate(s, d)
56
+ assert_equal r.object_id, d.object_id
57
+ end
58
+ end
59
+
60
+ sub_test_case ".valid?" do
61
+ test "return true when passed deflated data" do
62
+ if defined? JRUBY_VERSION
63
+ notify "snappy-jars does not have valid?"
64
+ omit
65
+ end
66
+ d = Snappy.deflate(random_data)
67
+ assert_true Snappy.valid?(d)
68
+ end
69
+
70
+ test "return false when passed invalid data" do
71
+ if defined? JRUBY_VERSION
72
+ notify "snappy-jars does not have valid?"
73
+ omit
74
+ end
75
+ d = Snappy.deflate(random_data).reverse
76
+ assert_false Snappy.valid?(d)
77
+ end
78
+ end
79
+
80
+ sub_test_case "Ractor safe" do
81
+ test "able to invoke non-main ractor" do
82
+ unless defined? ::Ractor
83
+ notify "Ractor not defined"
84
+ omit
85
+ end
86
+ s = random_data
87
+ a = Array.new(2) do
88
+ Ractor.new(s) do |s|
89
+ Snappy.inflate(Snappy.deflate(s)) == s
90
+ end
91
+ end
92
+ assert_equal [true, true], a.map(&:take)
93
+ end
94
+ end
95
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "test_helper"
4
+ require "stringio"
5
+
6
+ class SnappyWriterTest < Test::Unit::TestCase
7
+ def setup
8
+ @buffer = StringIO.new
9
+ end
10
+
11
+ def subject
12
+ @subject ||= Snappy::Writer.new @buffer
13
+ end
14
+
15
+ sub_test_case "#initialize" do
16
+ test "should yield itself to the block" do
17
+ yielded = nil
18
+ returned = Snappy::Writer.new @buffer do |w|
19
+ yielded = w
20
+ end
21
+ assert_equal returned, yielded
22
+ end
23
+
24
+ test "should write the header" do
25
+ assert_equal [Snappy::Writer::MAGIC,
26
+ Snappy::Writer::DEFAULT_VERSION,
27
+ Snappy::Writer::MINIMUM_COMPATIBLE_VERSION].pack("a8NN"), subject.io.string
28
+ end
29
+
30
+ test "should dump on the end of yield" do
31
+ Snappy::Writer.new @buffer do |w|
32
+ w << "foo"
33
+ end
34
+ foo = Snappy.deflate "foo"
35
+ assert_equal [foo.size, foo].pack("Na#{foo.size}"), @buffer.string[16, @buffer.size - 16]
36
+ end
37
+ end
38
+
39
+ sub_test_case "#io" do
40
+ test "should be a constructor argument" do
41
+ io = StringIO.new
42
+ assert_equal io, Snappy::Writer.new(io).io
43
+ end
44
+ end
45
+
46
+ sub_test_case "#block_size" do
47
+ test "should default to DEFAULT_BLOCK_SIZE" do
48
+ assert_equal Snappy::Writer::DEFAULT_BLOCK_SIZE, subject.block_size
49
+ end
50
+
51
+ test "should be settable via the constructor" do
52
+ assert_equal 42, Snappy::Writer.new(StringIO.new, 42).block_size
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
+ require "snappy"
5
+
6
+ require "test-unit"
7
+ require "test/unit/rr"
@@ -0,0 +1,297 @@
1
+ # Copyright 2019 Google Inc. All Rights Reserved.
2
+ #
3
+ # Redistribution and use in source and binary forms, with or without
4
+ # modification, are permitted provided that the following conditions are
5
+ # met:
6
+ #
7
+ # * Redistributions of source code must retain the above copyright
8
+ # notice, this list of conditions and the following disclaimer.
9
+ # * Redistributions in binary form must reproduce the above
10
+ # copyright notice, this list of conditions and the following disclaimer
11
+ # in the documentation and/or other materials provided with the
12
+ # distribution.
13
+ # * Neither the name of Google Inc. nor the names of its
14
+ # contributors may be used to endorse or promote products derived from
15
+ # this software without specific prior written permission.
16
+ #
17
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
29
+ cmake_minimum_required(VERSION 3.1)
30
+ project(Snappy VERSION 1.1.8 LANGUAGES C CXX)
31
+
32
+ # C++ standard can be overridden when this is used as a sub-project.
33
+ if(NOT CMAKE_CXX_STANDARD)
34
+ # This project requires C++11.
35
+ set(CMAKE_CXX_STANDARD 11)
36
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
37
+ set(CMAKE_CXX_EXTENSIONS OFF)
38
+ endif(NOT CMAKE_CXX_STANDARD)
39
+
40
+ # BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to make
41
+ # it prominent in the GUI.
42
+ option(BUILD_SHARED_LIBS "Build shared libraries(DLLs)." OFF)
43
+
44
+ option(SNAPPY_BUILD_TESTS "Build Snappy's own tests." ON)
45
+
46
+ option(SNAPPY_FUZZING_BUILD "Build Snappy for fuzzing." OFF)
47
+
48
+ option(SNAPPY_REQUIRE_AVX "Target processors with AVX support." OFF)
49
+
50
+ option(SNAPPY_REQUIRE_AVX2 "Target processors with AVX2 support." OFF)
51
+
52
+ option(SNAPPY_INSTALL "Install Snappy's header and library" ON)
53
+
54
+ include(TestBigEndian)
55
+ test_big_endian(SNAPPY_IS_BIG_ENDIAN)
56
+
57
+ include(CheckIncludeFile)
58
+ check_include_file("byteswap.h" HAVE_BYTESWAP_H)
59
+ check_include_file("sys/endian.h" HAVE_SYS_ENDIAN_H)
60
+ check_include_file("sys/mman.h" HAVE_SYS_MMAN_H)
61
+ check_include_file("sys/resource.h" HAVE_SYS_RESOURCE_H)
62
+ check_include_file("sys/time.h" HAVE_SYS_TIME_H)
63
+ check_include_file("sys/uio.h" HAVE_SYS_UIO_H)
64
+ check_include_file("unistd.h" HAVE_UNISTD_H)
65
+ check_include_file("windows.h" HAVE_WINDOWS_H)
66
+
67
+ include(CheckLibraryExists)
68
+ check_library_exists(z zlibVersion "" HAVE_LIBZ)
69
+ check_library_exists(lzo2 lzo1x_1_15_compress "" HAVE_LIBLZO2)
70
+
71
+ include(CheckCXXCompilerFlag)
72
+ CHECK_CXX_COMPILER_FLAG("/arch:AVX" HAVE_VISUAL_STUDIO_ARCH_AVX)
73
+ CHECK_CXX_COMPILER_FLAG("/arch:AVX2" HAVE_VISUAL_STUDIO_ARCH_AVX2)
74
+ CHECK_CXX_COMPILER_FLAG("-mavx" HAVE_CLANG_MAVX)
75
+ CHECK_CXX_COMPILER_FLAG("-mbmi2" HAVE_CLANG_MBMI2)
76
+ if(SNAPPY_REQUIRE_AVX2)
77
+ if(HAVE_VISUAL_STUDIO_ARCH_AVX2)
78
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX2")
79
+ endif(HAVE_VISUAL_STUDIO_ARCH_AVX2)
80
+ if(HAVE_CLANG_MAVX)
81
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
82
+ endif(HAVE_CLANG_MAVX)
83
+ if(HAVE_CLANG_MBMI2)
84
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mbmi2")
85
+ endif(HAVE_CLANG_MBMI2)
86
+ elseif (SNAPPY_REQUIRE_AVX)
87
+ if(HAVE_VISUAL_STUDIO_ARCH_AVX)
88
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:AVX")
89
+ endif(HAVE_VISUAL_STUDIO_ARCH_AVX)
90
+ if(HAVE_CLANG_MAVX)
91
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mavx")
92
+ endif(HAVE_CLANG_MAVX)
93
+ endif(SNAPPY_REQUIRE_AVX2)
94
+
95
+ include(CheckCXXSourceCompiles)
96
+ check_cxx_source_compiles("
97
+ int main() {
98
+ return __builtin_expect(0, 1);
99
+ }" HAVE_BUILTIN_EXPECT)
100
+
101
+ check_cxx_source_compiles("
102
+ int main() {
103
+ return __builtin_ctzll(0);
104
+ }" HAVE_BUILTIN_CTZ)
105
+
106
+ check_cxx_source_compiles("
107
+ #include <tmmintrin.h>
108
+
109
+ int main() {
110
+ const __m128i *src = 0;
111
+ __m128i dest;
112
+ const __m128i shuffle_mask = _mm_load_si128(src);
113
+ const __m128i pattern = _mm_shuffle_epi8(_mm_loadl_epi64(src), shuffle_mask);
114
+ _mm_storeu_si128(&dest, pattern);
115
+ return 0;
116
+ }" SNAPPY_HAVE_SSSE3)
117
+
118
+ check_cxx_source_compiles("
119
+ #include <immintrin.h>
120
+ int main() {
121
+ return _bzhi_u32(0, 1);
122
+ }" SNAPPY_HAVE_BMI2)
123
+
124
+ include(CheckSymbolExists)
125
+ check_symbol_exists("mmap" "sys/mman.h" HAVE_FUNC_MMAP)
126
+ check_symbol_exists("sysconf" "unistd.h" HAVE_FUNC_SYSCONF)
127
+
128
+ find_package(GTest QUIET)
129
+ if(GTEST_FOUND)
130
+ set(HAVE_GTEST 1)
131
+ endif(GTEST_FOUND)
132
+
133
+ find_package(Gflags QUIET)
134
+ if(GFLAGS_FOUND)
135
+ set(HAVE_GFLAGS 1)
136
+ endif(GFLAGS_FOUND)
137
+
138
+ configure_file(
139
+ "cmake/config.h.in"
140
+ "${PROJECT_BINARY_DIR}/config.h"
141
+ )
142
+
143
+ # We don't want to define HAVE_ macros in public headers. Instead, we use
144
+ # CMake's variable substitution with 0/1 variables, which will be seen by the
145
+ # preprocessor as constants.
146
+ set(HAVE_SYS_UIO_H_01 ${HAVE_SYS_UIO_H})
147
+ if(NOT HAVE_SYS_UIO_H_01)
148
+ set(HAVE_SYS_UIO_H_01 0)
149
+ endif(NOT HAVE_SYS_UIO_H_01)
150
+
151
+ if (SNAPPY_FUZZING_BUILD)
152
+ if (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
153
+ message(WARNING "Fuzzing builds are only supported with Clang")
154
+ endif (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
155
+
156
+ if(NOT CMAKE_CXX_FLAGS MATCHES "-fsanitize=address")
157
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
158
+ endif(NOT CMAKE_CXX_FLAGS MATCHES "-fsanitize=address")
159
+
160
+ if(NOT CMAKE_CXX_FLAGS MATCHES "-fsanitize=fuzzer-no-link")
161
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer-no-link")
162
+ endif(NOT CMAKE_CXX_FLAGS MATCHES "-fsanitize=fuzzer-no-link")
163
+ endif (SNAPPY_FUZZING_BUILD)
164
+
165
+ configure_file(
166
+ "snappy-stubs-public.h.in"
167
+ "${PROJECT_BINARY_DIR}/snappy-stubs-public.h")
168
+
169
+ add_library(snappy "")
170
+ target_sources(snappy
171
+ PRIVATE
172
+ "snappy-internal.h"
173
+ "snappy-stubs-internal.h"
174
+ "snappy-c.cc"
175
+ "snappy-sinksource.cc"
176
+ "snappy-stubs-internal.cc"
177
+ "snappy.cc"
178
+ "${PROJECT_BINARY_DIR}/config.h"
179
+
180
+ # Only CMake 3.3+ supports PUBLIC sources in targets exported by "install".
181
+ $<$<VERSION_GREATER:CMAKE_VERSION,3.2>:PUBLIC>
182
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-c.h>
183
+ $<INSTALL_INTERFACE:include/snappy-c.h>
184
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy-sinksource.h>
185
+ $<INSTALL_INTERFACE:include/snappy-sinksource.h>
186
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/snappy.h>
187
+ $<INSTALL_INTERFACE:include/snappy.h>
188
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/snappy-stubs-public.h>
189
+ $<INSTALL_INTERFACE:include/snappy-stubs-public.h>
190
+ )
191
+ target_include_directories(snappy
192
+ PUBLIC
193
+ $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>
194
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
195
+ $<INSTALL_INTERFACE:include>
196
+ )
197
+ set_target_properties(snappy
198
+ PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
199
+
200
+ target_compile_definitions(snappy PRIVATE -DHAVE_CONFIG_H)
201
+ if(BUILD_SHARED_LIBS)
202
+ set_target_properties(snappy PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS ON)
203
+ endif(BUILD_SHARED_LIBS)
204
+
205
+ if(SNAPPY_BUILD_TESTS)
206
+ enable_testing()
207
+
208
+ add_executable(snappy_unittest "")
209
+ target_sources(snappy_unittest
210
+ PRIVATE
211
+ "snappy_unittest.cc"
212
+ "snappy-test.cc"
213
+ )
214
+ target_compile_definitions(snappy_unittest PRIVATE -DHAVE_CONFIG_H)
215
+ target_link_libraries(snappy_unittest snappy ${GFLAGS_LIBRARIES})
216
+
217
+ if(HAVE_LIBZ)
218
+ target_link_libraries(snappy_unittest z)
219
+ endif(HAVE_LIBZ)
220
+ if(HAVE_LIBLZO2)
221
+ target_link_libraries(snappy_unittest lzo2)
222
+ endif(HAVE_LIBLZO2)
223
+
224
+ target_include_directories(snappy_unittest
225
+ BEFORE PRIVATE
226
+ "${PROJECT_SOURCE_DIR}"
227
+ "${GTEST_INCLUDE_DIRS}"
228
+ "${GFLAGS_INCLUDE_DIRS}"
229
+ )
230
+
231
+ add_test(
232
+ NAME snappy_unittest
233
+ WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
234
+ COMMAND "${PROJECT_BINARY_DIR}/snappy_unittest")
235
+ endif(SNAPPY_BUILD_TESTS)
236
+
237
+ if(SNAPPY_FUZZING_BUILD)
238
+ add_executable(snappy_compress_fuzzer "")
239
+ target_sources(snappy_compress_fuzzer
240
+ PRIVATE "snappy_compress_fuzzer.cc"
241
+ )
242
+ target_link_libraries(snappy_compress_fuzzer snappy)
243
+ set_target_properties(snappy_compress_fuzzer
244
+ PROPERTIES LINK_FLAGS "-fsanitize=fuzzer"
245
+ )
246
+
247
+ add_executable(snappy_uncompress_fuzzer "")
248
+ target_sources(snappy_uncompress_fuzzer
249
+ PRIVATE "snappy_uncompress_fuzzer.cc"
250
+ )
251
+ target_link_libraries(snappy_uncompress_fuzzer snappy)
252
+ set_target_properties(snappy_uncompress_fuzzer
253
+ PROPERTIES LINK_FLAGS "-fsanitize=fuzzer"
254
+ )
255
+ endif(SNAPPY_FUZZING_BUILD)
256
+
257
+ # Must be included before CMAKE_INSTALL_INCLUDEDIR is used.
258
+ include(GNUInstallDirs)
259
+
260
+ if(SNAPPY_INSTALL)
261
+ install(TARGETS snappy
262
+ EXPORT SnappyTargets
263
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
264
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
265
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
266
+ )
267
+ install(
268
+ FILES
269
+ "snappy-c.h"
270
+ "snappy-sinksource.h"
271
+ "snappy.h"
272
+ "${PROJECT_BINARY_DIR}/snappy-stubs-public.h"
273
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
274
+ )
275
+
276
+ include(CMakePackageConfigHelpers)
277
+ configure_package_config_file(
278
+ "cmake/${PROJECT_NAME}Config.cmake.in"
279
+ "${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake"
280
+ INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
281
+ )
282
+ write_basic_package_version_file(
283
+ "${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake"
284
+ COMPATIBILITY SameMajorVersion
285
+ )
286
+ install(
287
+ EXPORT SnappyTargets
288
+ NAMESPACE Snappy::
289
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
290
+ )
291
+ install(
292
+ FILES
293
+ "${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake"
294
+ "${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake"
295
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
296
+ )
297
+ endif(SNAPPY_INSTALL)