10225501448 李度 10225101546 陈胤遒 10215501422 高宇菲
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

426 lines
15 KiB

Add move constructor to Status. This will result in smaller code generation when Status instances are passed around. Benchmarks don't indicate a significant change either way. CPU: 48 * Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz CPUCache: 30720 KB Keys: 16 bytes each Values: 100 bytes each (50 bytes after compression) Entries: 1000000 RawSize: 110.6 MB (estimated) FileSize: 62.9 MB (estimated) Baseline: fillseq : 3.589 micros/op; 30.8 MB/s fillsync : 4165.299 micros/op; 0.0 MB/s (1000 ops) fillrandom : 5.864 micros/op; 18.9 MB/s overwrite : 7.830 micros/op; 14.1 MB/s readrandom : 5.534 micros/op; (1000000 of 1000000 found) readrandom : 4.292 micros/op; (1000000 of 1000000 found) readseq : 0.312 micros/op; 354.1 MB/s readreverse : 0.501 micros/op; 220.8 MB/s compact : 886211.000 micros/op; readrandom : 3.518 micros/op; (1000000 of 1000000 found) readseq : 0.251 micros/op; 441.2 MB/s readreverse : 0.456 micros/op; 242.4 MB/s fill100K : 1329.723 micros/op; 71.7 MB/s (1000 ops) crc32c : 1.976 micros/op; 1976.7 MB/s (4K per op) snappycomp : 4.705 micros/op; 830.2 MB/s (output: 55.1%) snappyuncomp : 0.958 micros/op; 4079.1 MB/s acquireload : 0.727 micros/op; (each op is 1000 loads) New: fillseq : 3.129 micros/op; 35.4 MB/s fillsync : 2748.099 micros/op; 0.0 MB/s (1000 ops) fillrandom : 5.394 micros/op; 20.5 MB/s overwrite : 7.253 micros/op; 15.3 MB/s readrandom : 5.655 micros/op; (1000000 of 1000000 found) readrandom : 4.425 micros/op; (1000000 of 1000000 found) readseq : 0.298 micros/op; 371.3 MB/s readreverse : 0.508 micros/op; 217.9 MB/s compact : 885842.000 micros/op; readrandom : 3.545 micros/op; (1000000 of 1000000 found) readseq : 0.252 micros/op; 438.2 MB/s readreverse : 0.425 micros/op; 260.2 MB/s fill100K : 1418.347 micros/op; 67.2 MB/s (1000 ops) crc32c : 1.987 micros/op; 1966.0 MB/s (4K per op) snappycomp : 4.767 micros/op; 819.4 MB/s (output: 55.1%) snappyuncomp : 0.916 micros/op; 4264.9 MB/s acquireload : 0.665 micros/op; (each op is 1000 loads) ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=194002392
6 years ago
  1. # Copyright 2017 The LevelDB Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file. See the AUTHORS file for names of contributors.
  4. cmake_minimum_required(VERSION 3.9)
  5. project(leveldb VERSION 1.21.0 LANGUAGES C CXX)
  6. # This project can use C11, but will gracefully decay down to C89.
  7. set(CMAKE_C_STANDARD 11)
  8. set(CMAKE_C_STANDARD_REQUIRED OFF)
  9. set(CMAKE_C_EXTENSIONS OFF)
  10. # This project requires C++11.
  11. set(CMAKE_CXX_STANDARD 11)
  12. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  13. set(CMAKE_CXX_EXTENSIONS OFF)
  14. option(LEVELDB_BUILD_TESTS "Build LevelDB's unit tests" ON)
  15. option(LEVELDB_BUILD_BENCHMARKS "Build LevelDB's benchmarks" ON)
  16. option(LEVELDB_INSTALL "Install LevelDB's header and library" ON)
  17. include(TestBigEndian)
  18. test_big_endian(LEVELDB_IS_BIG_ENDIAN)
  19. include(CheckIncludeFile)
  20. check_include_file("unistd.h" HAVE_UNISTD_H)
  21. include(CheckLibraryExists)
  22. check_library_exists(crc32c crc32c_value "" HAVE_CRC32C)
  23. check_library_exists(snappy snappy_compress "" HAVE_SNAPPY)
  24. check_library_exists(tcmalloc malloc "" HAVE_TCMALLOC)
  25. include(CheckCXXSymbolExists)
  26. # Using check_cxx_symbol_exists() instead of check_c_symbol_exists() because
  27. # we're including the header from C++, and feature detection should use the same
  28. # compiler language that the project will use later. Principles aside, some
  29. # versions of do not expose fdatasync() in <unistd.h> in standard C mode
  30. # (-std=c11), but do expose the function in standard C++ mode (-std=c++11).
  31. check_cxx_symbol_exists(fdatasync "unistd.h" HAVE_FDATASYNC)
  32. include(CheckCXXSourceCompiles)
  33. # Test whether -Wthread-safety is available. See
  34. # https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
  35. # -Werror is necessary because unknown attributes only generate warnings.
  36. set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
  37. list(APPEND CMAKE_REQUIRED_FLAGS -Werror -Wthread-safety)
  38. check_cxx_source_compiles("
  39. struct __attribute__((lockable)) Lock {
  40. void Acquire() __attribute__((exclusive_lock_function()));
  41. void Release() __attribute__((unlock_function()));
  42. };
  43. struct ThreadSafeType {
  44. Lock lock_;
  45. int data_ __attribute__((guarded_by(lock_)));
  46. };
  47. int main() { return 0; }
  48. " HAVE_CLANG_THREAD_SAFETY)
  49. set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
  50. # Test whether C++17 __has_include is available.
  51. check_cxx_source_compiles("
  52. #if defined(__has_include) && __has_include(<string>)
  53. #include <string>
  54. #endif
  55. int main() { std::string str; return 0; }
  56. " HAVE_CXX17_HAS_INCLUDE)
  57. set(LEVELDB_PUBLIC_INCLUDE_DIR "include/leveldb")
  58. set(LEVELDB_PORT_CONFIG_DIR "include/port")
  59. configure_file(
  60. "${PROJECT_SOURCE_DIR}/port/port_config.h.in"
  61. "${PROJECT_BINARY_DIR}/${LEVELDB_PORT_CONFIG_DIR}/port_config.h"
  62. )
  63. include_directories(
  64. "${PROJECT_BINARY_DIR}/include"
  65. "${PROJECT_SOURCE_DIR}"
  66. )
  67. if(BUILD_SHARED_LIBS)
  68. # Only export LEVELDB_EXPORT symbols from the shared library.
  69. add_compile_options(-fvisibility=hidden)
  70. endif(BUILD_SHARED_LIBS)
  71. add_library(leveldb "")
  72. target_sources(leveldb
  73. PRIVATE
  74. "${PROJECT_BINARY_DIR}/${LEVELDB_PORT_CONFIG_DIR}/port_config.h"
  75. "${PROJECT_SOURCE_DIR}/db/builder.cc"
  76. "${PROJECT_SOURCE_DIR}/db/builder.h"
  77. "${PROJECT_SOURCE_DIR}/db/c.cc"
  78. "${PROJECT_SOURCE_DIR}/db/db_impl.cc"
  79. "${PROJECT_SOURCE_DIR}/db/db_impl.h"
  80. "${PROJECT_SOURCE_DIR}/db/db_iter.cc"
  81. "${PROJECT_SOURCE_DIR}/db/db_iter.h"
  82. "${PROJECT_SOURCE_DIR}/db/dbformat.cc"
  83. "${PROJECT_SOURCE_DIR}/db/dbformat.h"
  84. "${PROJECT_SOURCE_DIR}/db/dumpfile.cc"
  85. "${PROJECT_SOURCE_DIR}/db/filename.cc"
  86. "${PROJECT_SOURCE_DIR}/db/filename.h"
  87. "${PROJECT_SOURCE_DIR}/db/log_format.h"
  88. "${PROJECT_SOURCE_DIR}/db/log_reader.cc"
  89. "${PROJECT_SOURCE_DIR}/db/log_reader.h"
  90. "${PROJECT_SOURCE_DIR}/db/log_writer.cc"
  91. "${PROJECT_SOURCE_DIR}/db/log_writer.h"
  92. "${PROJECT_SOURCE_DIR}/db/memtable.cc"
  93. "${PROJECT_SOURCE_DIR}/db/memtable.h"
  94. "${PROJECT_SOURCE_DIR}/db/repair.cc"
  95. "${PROJECT_SOURCE_DIR}/db/skiplist.h"
  96. "${PROJECT_SOURCE_DIR}/db/snapshot.h"
  97. "${PROJECT_SOURCE_DIR}/db/table_cache.cc"
  98. "${PROJECT_SOURCE_DIR}/db/table_cache.h"
  99. "${PROJECT_SOURCE_DIR}/db/version_edit.cc"
  100. "${PROJECT_SOURCE_DIR}/db/version_edit.h"
  101. "${PROJECT_SOURCE_DIR}/db/version_set.cc"
  102. "${PROJECT_SOURCE_DIR}/db/version_set.h"
  103. "${PROJECT_SOURCE_DIR}/db/write_batch_internal.h"
  104. "${PROJECT_SOURCE_DIR}/db/write_batch.cc"
  105. "${PROJECT_SOURCE_DIR}/port/atomic_pointer.h"
  106. "${PROJECT_SOURCE_DIR}/port/port_stdcxx.h"
  107. "${PROJECT_SOURCE_DIR}/port/port.h"
  108. "${PROJECT_SOURCE_DIR}/port/thread_annotations.h"
  109. "${PROJECT_SOURCE_DIR}/table/block_builder.cc"
  110. "${PROJECT_SOURCE_DIR}/table/block_builder.h"
  111. "${PROJECT_SOURCE_DIR}/table/block.cc"
  112. "${PROJECT_SOURCE_DIR}/table/block.h"
  113. "${PROJECT_SOURCE_DIR}/table/filter_block.cc"
  114. "${PROJECT_SOURCE_DIR}/table/filter_block.h"
  115. "${PROJECT_SOURCE_DIR}/table/format.cc"
  116. "${PROJECT_SOURCE_DIR}/table/format.h"
  117. "${PROJECT_SOURCE_DIR}/table/iterator_wrapper.h"
  118. "${PROJECT_SOURCE_DIR}/table/iterator.cc"
  119. "${PROJECT_SOURCE_DIR}/table/merger.cc"
  120. "${PROJECT_SOURCE_DIR}/table/merger.h"
  121. "${PROJECT_SOURCE_DIR}/table/table_builder.cc"
  122. "${PROJECT_SOURCE_DIR}/table/table.cc"
  123. "${PROJECT_SOURCE_DIR}/table/two_level_iterator.cc"
  124. "${PROJECT_SOURCE_DIR}/table/two_level_iterator.h"
  125. "${PROJECT_SOURCE_DIR}/util/arena.cc"
  126. "${PROJECT_SOURCE_DIR}/util/arena.h"
  127. "${PROJECT_SOURCE_DIR}/util/bloom.cc"
  128. "${PROJECT_SOURCE_DIR}/util/cache.cc"
  129. "${PROJECT_SOURCE_DIR}/util/coding.cc"
  130. "${PROJECT_SOURCE_DIR}/util/coding.h"
  131. "${PROJECT_SOURCE_DIR}/util/comparator.cc"
  132. "${PROJECT_SOURCE_DIR}/util/crc32c.cc"
  133. "${PROJECT_SOURCE_DIR}/util/crc32c.h"
  134. "${PROJECT_SOURCE_DIR}/util/env.cc"
  135. "${PROJECT_SOURCE_DIR}/util/filter_policy.cc"
  136. "${PROJECT_SOURCE_DIR}/util/hash.cc"
  137. "${PROJECT_SOURCE_DIR}/util/hash.h"
  138. "${PROJECT_SOURCE_DIR}/util/logging.cc"
  139. "${PROJECT_SOURCE_DIR}/util/logging.h"
  140. "${PROJECT_SOURCE_DIR}/util/mutexlock.h"
  141. "${PROJECT_SOURCE_DIR}/util/no_destructor.h"
  142. "${PROJECT_SOURCE_DIR}/util/options.cc"
  143. "${PROJECT_SOURCE_DIR}/util/random.h"
  144. "${PROJECT_SOURCE_DIR}/util/status.cc"
  145. # Only CMake 3.3+ supports PUBLIC sources in targets exported by "install".
  146. $<$<VERSION_GREATER:CMAKE_VERSION,3.2>:PUBLIC>
  147. "${LEVELDB_PUBLIC_INCLUDE_DIR}/c.h"
  148. "${LEVELDB_PUBLIC_INCLUDE_DIR}/cache.h"
  149. "${LEVELDB_PUBLIC_INCLUDE_DIR}/comparator.h"
  150. "${LEVELDB_PUBLIC_INCLUDE_DIR}/db.h"
  151. "${LEVELDB_PUBLIC_INCLUDE_DIR}/dumpfile.h"
  152. "${LEVELDB_PUBLIC_INCLUDE_DIR}/env.h"
  153. "${LEVELDB_PUBLIC_INCLUDE_DIR}/export.h"
  154. "${LEVELDB_PUBLIC_INCLUDE_DIR}/filter_policy.h"
  155. "${LEVELDB_PUBLIC_INCLUDE_DIR}/iterator.h"
  156. "${LEVELDB_PUBLIC_INCLUDE_DIR}/options.h"
  157. "${LEVELDB_PUBLIC_INCLUDE_DIR}/slice.h"
  158. "${LEVELDB_PUBLIC_INCLUDE_DIR}/status.h"
  159. "${LEVELDB_PUBLIC_INCLUDE_DIR}/table_builder.h"
  160. "${LEVELDB_PUBLIC_INCLUDE_DIR}/table.h"
  161. "${LEVELDB_PUBLIC_INCLUDE_DIR}/write_batch.h"
  162. )
  163. # POSIX code is specified separately so we can leave it out in the future.
  164. target_sources(leveldb
  165. PRIVATE
  166. "${PROJECT_SOURCE_DIR}/util/env_posix.cc"
  167. "${PROJECT_SOURCE_DIR}/util/posix_logger.h"
  168. )
  169. # MemEnv is not part of the interface and could be pulled to a separate library.
  170. target_sources(leveldb
  171. PRIVATE
  172. "${PROJECT_SOURCE_DIR}/helpers/memenv/memenv.cc"
  173. "${PROJECT_SOURCE_DIR}/helpers/memenv/memenv.h"
  174. )
  175. target_include_directories(leveldb
  176. PUBLIC
  177. $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
  178. $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
  179. )
  180. target_compile_definitions(leveldb
  181. PRIVATE
  182. # Used by include/export.h when building shared libraries.
  183. LEVELDB_COMPILE_LIBRARY
  184. # Used by port/port.h.
  185. LEVELDB_PLATFORM_POSIX=1
  186. )
  187. if (NOT HAVE_CXX17_HAS_INCLUDE)
  188. target_compile_definitions(leveldb
  189. PRIVATE
  190. LEVELDB_HAS_PORT_CONFIG_H=1
  191. )
  192. endif(NOT HAVE_CXX17_HAS_INCLUDE)
  193. if(BUILD_SHARED_LIBS)
  194. target_compile_definitions(leveldb
  195. PUBLIC
  196. # Used by include/export.h.
  197. LEVELDB_SHARED_LIBRARY
  198. )
  199. endif(BUILD_SHARED_LIBS)
  200. if(HAVE_CLANG_THREAD_SAFETY)
  201. target_compile_options(leveldb
  202. PUBLIC
  203. -Werror -Wthread-safety)
  204. endif(HAVE_CLANG_THREAD_SAFETY)
  205. if(HAVE_CRC32C)
  206. target_link_libraries(leveldb crc32c)
  207. endif(HAVE_CRC32C)
  208. if(HAVE_SNAPPY)
  209. target_link_libraries(leveldb snappy)
  210. endif(HAVE_SNAPPY)
  211. if(HAVE_TCMALLOC)
  212. target_link_libraries(leveldb tcmalloc)
  213. endif(HAVE_TCMALLOC)
  214. # Needed by port_stdcxx.h
  215. find_package(Threads REQUIRED)
  216. target_link_libraries(leveldb Threads::Threads)
  217. add_executable(leveldbutil
  218. "${PROJECT_SOURCE_DIR}/db/leveldbutil.cc"
  219. )
  220. target_link_libraries(leveldbutil leveldb)
  221. if(LEVELDB_BUILD_TESTS)
  222. enable_testing()
  223. function(leveldb_test test_file)
  224. get_filename_component(test_target_name "${test_file}" NAME_WE)
  225. add_executable("${test_target_name}" "")
  226. target_sources("${test_target_name}"
  227. PRIVATE
  228. "${PROJECT_BINARY_DIR}/${LEVELDB_PORT_CONFIG_DIR}/port_config.h"
  229. "${PROJECT_SOURCE_DIR}/util/testharness.cc"
  230. "${PROJECT_SOURCE_DIR}/util/testharness.h"
  231. "${PROJECT_SOURCE_DIR}/util/testutil.cc"
  232. "${PROJECT_SOURCE_DIR}/util/testutil.h"
  233. "${test_file}"
  234. )
  235. target_link_libraries("${test_target_name}" leveldb)
  236. target_compile_definitions("${test_target_name}"
  237. PRIVATE
  238. LEVELDB_PLATFORM_POSIX=1
  239. )
  240. if (NOT HAVE_CXX17_HAS_INCLUDE)
  241. target_compile_definitions("${test_target_name}"
  242. PRIVATE
  243. LEVELDB_HAS_PORT_CONFIG_H=1
  244. )
  245. endif(NOT HAVE_CXX17_HAS_INCLUDE)
  246. add_test(NAME "${test_target_name}" COMMAND "${test_target_name}")
  247. endfunction(leveldb_test)
  248. leveldb_test("${PROJECT_SOURCE_DIR}/db/c_test.c")
  249. leveldb_test("${PROJECT_SOURCE_DIR}/db/fault_injection_test.cc")
  250. leveldb_test("${PROJECT_SOURCE_DIR}/issues/issue178_test.cc")
  251. leveldb_test("${PROJECT_SOURCE_DIR}/issues/issue200_test.cc")
  252. leveldb_test("${PROJECT_SOURCE_DIR}/util/env_test.cc")
  253. leveldb_test("${PROJECT_SOURCE_DIR}/util/status_test.cc")
  254. leveldb_test("${PROJECT_SOURCE_DIR}/util/no_destructor_test.cc")
  255. if(NOT BUILD_SHARED_LIBS)
  256. leveldb_test("${PROJECT_SOURCE_DIR}/db/autocompact_test.cc")
  257. leveldb_test("${PROJECT_SOURCE_DIR}/db/corruption_test.cc")
  258. leveldb_test("${PROJECT_SOURCE_DIR}/db/db_test.cc")
  259. leveldb_test("${PROJECT_SOURCE_DIR}/db/dbformat_test.cc")
  260. leveldb_test("${PROJECT_SOURCE_DIR}/db/filename_test.cc")
  261. leveldb_test("${PROJECT_SOURCE_DIR}/db/log_test.cc")
  262. leveldb_test("${PROJECT_SOURCE_DIR}/db/recovery_test.cc")
  263. leveldb_test("${PROJECT_SOURCE_DIR}/db/skiplist_test.cc")
  264. leveldb_test("${PROJECT_SOURCE_DIR}/db/version_edit_test.cc")
  265. leveldb_test("${PROJECT_SOURCE_DIR}/db/version_set_test.cc")
  266. leveldb_test("${PROJECT_SOURCE_DIR}/db/write_batch_test.cc")
  267. leveldb_test("${PROJECT_SOURCE_DIR}/helpers/memenv/memenv_test.cc")
  268. leveldb_test("${PROJECT_SOURCE_DIR}/table/filter_block_test.cc")
  269. leveldb_test("${PROJECT_SOURCE_DIR}/table/table_test.cc")
  270. leveldb_test("${PROJECT_SOURCE_DIR}/util/arena_test.cc")
  271. leveldb_test("${PROJECT_SOURCE_DIR}/util/bloom_test.cc")
  272. leveldb_test("${PROJECT_SOURCE_DIR}/util/cache_test.cc")
  273. leveldb_test("${PROJECT_SOURCE_DIR}/util/coding_test.cc")
  274. leveldb_test("${PROJECT_SOURCE_DIR}/util/crc32c_test.cc")
  275. leveldb_test("${PROJECT_SOURCE_DIR}/util/hash_test.cc")
  276. leveldb_test("${PROJECT_SOURCE_DIR}/util/logging_test.cc")
  277. # TODO(costan): This test also uses
  278. # "${PROJECT_SOURCE_DIR}/util/env_posix_test_helper.h"
  279. leveldb_test("${PROJECT_SOURCE_DIR}/util/env_posix_test.cc")
  280. endif(NOT BUILD_SHARED_LIBS)
  281. endif(LEVELDB_BUILD_TESTS)
  282. if(LEVELDB_BUILD_BENCHMARKS)
  283. function(leveldb_benchmark bench_file)
  284. get_filename_component(bench_target_name "${bench_file}" NAME_WE)
  285. add_executable("${bench_target_name}" "")
  286. target_sources("${bench_target_name}"
  287. PRIVATE
  288. "${PROJECT_BINARY_DIR}/${LEVELDB_PORT_CONFIG_DIR}/port_config.h"
  289. "${PROJECT_SOURCE_DIR}/util/histogram.cc"
  290. "${PROJECT_SOURCE_DIR}/util/histogram.h"
  291. "${PROJECT_SOURCE_DIR}/util/testharness.cc"
  292. "${PROJECT_SOURCE_DIR}/util/testharness.h"
  293. "${PROJECT_SOURCE_DIR}/util/testutil.cc"
  294. "${PROJECT_SOURCE_DIR}/util/testutil.h"
  295. "${bench_file}"
  296. )
  297. target_link_libraries("${bench_target_name}" leveldb)
  298. target_compile_definitions("${bench_target_name}"
  299. PRIVATE
  300. LEVELDB_PLATFORM_POSIX=1
  301. )
  302. if (NOT HAVE_CXX17_HAS_INCLUDE)
  303. target_compile_definitions("${bench_target_name}"
  304. PRIVATE
  305. LEVELDB_HAS_PORT_CONFIG_H=1
  306. )
  307. endif(NOT HAVE_CXX17_HAS_INCLUDE)
  308. endfunction(leveldb_benchmark)
  309. if(NOT BUILD_SHARED_LIBS)
  310. leveldb_benchmark("${PROJECT_SOURCE_DIR}/db/db_bench.cc")
  311. endif(NOT BUILD_SHARED_LIBS)
  312. check_library_exists(sqlite3 sqlite3_open "" HAVE_SQLITE3)
  313. if(HAVE_SQLITE3)
  314. leveldb_benchmark("${PROJECT_SOURCE_DIR}/doc/bench/db_bench_sqlite3.cc")
  315. target_link_libraries(db_bench_sqlite3 sqlite3)
  316. endif(HAVE_SQLITE3)
  317. # check_library_exists is insufficient here because the library names have
  318. # different manglings when compiled with clang or gcc, at least when installed
  319. # with Homebrew on Mac.
  320. set(OLD_CMAKE_REQURED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
  321. list(APPEND CMAKE_REQUIRED_LIBRARIES kyotocabinet)
  322. check_cxx_source_compiles("
  323. #include <kcpolydb.h>
  324. int main() {
  325. kyotocabinet::TreeDB* db = new kyotocabinet::TreeDB();
  326. delete db;
  327. return 0;
  328. }
  329. " HAVE_KYOTOCABINET)
  330. set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQURED_LIBRARIES})
  331. if(HAVE_KYOTOCABINET)
  332. leveldb_benchmark("${PROJECT_SOURCE_DIR}/doc/bench/db_bench_tree_db.cc")
  333. target_link_libraries(db_bench_tree_db kyotocabinet)
  334. endif(HAVE_KYOTOCABINET)
  335. endif(LEVELDB_BUILD_BENCHMARKS)
  336. if(LEVELDB_INSTALL)
  337. include(GNUInstallDirs)
  338. install(TARGETS leveldb
  339. EXPORT leveldbTargets
  340. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  341. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  342. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  343. )
  344. install(
  345. FILES
  346. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/c.h"
  347. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/cache.h"
  348. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/comparator.h"
  349. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/db.h"
  350. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/dumpfile.h"
  351. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/env.h"
  352. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/export.h"
  353. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/filter_policy.h"
  354. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/iterator.h"
  355. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/options.h"
  356. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/slice.h"
  357. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/status.h"
  358. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/table_builder.h"
  359. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/table.h"
  360. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/write_batch.h"
  361. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/leveldb
  362. )
  363. include(CMakePackageConfigHelpers)
  364. write_basic_package_version_file(
  365. "${PROJECT_BINARY_DIR}/leveldbConfigVersion.cmake"
  366. COMPATIBILITY SameMajorVersion
  367. )
  368. install(
  369. EXPORT leveldbTargets
  370. NAMESPACE leveldb::
  371. DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/leveldb"
  372. )
  373. install(
  374. FILES
  375. "${PROJECT_SOURCE_DIR}/cmake/leveldbConfig.cmake"
  376. "${PROJECT_BINARY_DIR}/leveldbConfigVersion.cmake"
  377. DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/leveldb"
  378. )
  379. endif(LEVELDB_INSTALL)