作者: 谢瑞阳 10225101483 徐翔宇 10225101535
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.

515 lines
16 KiB

leveldb: Fix PosixWritableFile::Sync() on Apple systems. Apple doesn't follow POSIX specifications for fsync(). Instead, fsync() guarantees to flush the buffer cache to the device, which means the data will survive kernel panics, but may not survive power outages. Applications that need stronger guarantees (like databases) need to use fcntl(F_FULLFSYNC). This CL switches PosixWritableFile::Sync() to get the stronger guarantees on Apple systems. The improved implementation follows the same principles as SQLite [1] and node.js [2]. Research for the fcntl() to fsync() fallback strategy: Apple's released source code at https://opensource.apple.com/ shows at least three different error codes being returned when a filesystem does not support F_FULLFSYNC. fcntl() is implemented in xnu-4903.221.2 in bsd/kern/kern_descrip.c, where it delegates to fcntl_nocancel(). The documentation for fcntl_nocancel() mentions error codes for some operations, but does not include F_FULLFSYNC. The F_FULLSYNC branch in fcntl_nocancel() calls VNOP_IOCTL(_, F_FULLSYNC, NULL, 0, _), whose return value sets the error code. VNOP_IOCTL() is implemented in bsd/vfs/kpi_vfs.c and calls the ioctl function in the vnode's operation vector. The per-filesystem function names follow the pattern _vnop_ioctl() for all the instances in opensource code: {hfs,msdosfs,nfs,ntfs,smbfs,webdav,zfs}_vnop_ioctl(). hfs-407.30.1, msdosfs-229.200.3, and nfs in xnu-4903.221.2 handle F_FULLFSYNC. ntfs-94.200.1 and smb-759.40.1 do not handle F_FULLFSYNC, and the default branch returns ENOSUP. webdav-380.200.1 also does not handle F_FULLFSYNC, but the default branch returns EINVAL. zfs-59 also does not handle F_FULLSYNC, and its default branch returns ENOTTY. From a different angle, Apple's ntfs-94.200.1 includes utility code that uses fcntl(F_FULLFSYNC) and falls back to fsync() just like we do, supporting the hypothesis that there is no good way to detect lack of F_FULLFSYNC support. Also, Apple's fcntl() man page [3] does not mention a way to detect lack of F_FULLFSYNC support. [1] https://www.sqlite.org/src/doc/trunk/src/os_unix.c [2] https://github.com/libuv/libuv/blob/master/src/unix/fs.c [3] https://developer.apple.com/library/archive/documentatiVon/System/Conceptual/ManPages_iPhoneOS/man2/fcntl.2.html Tested: https://travis-ci.org/pwnall/leveldb/builds/477318498 TAP global presubmit ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=228593729
5 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. # Keep the version below in sync with the one in db.h
  6. project(leveldb VERSION 1.23.0 LANGUAGES C CXX)
  7. # C standard can be overridden when this is used as a sub-project.
  8. if(NOT CMAKE_C_STANDARD)
  9. # This project can use C11, but will gracefully decay down to C89.
  10. set(CMAKE_C_STANDARD 11)
  11. set(CMAKE_C_STANDARD_REQUIRED OFF)
  12. set(CMAKE_C_EXTENSIONS OFF)
  13. endif(NOT CMAKE_C_STANDARD)
  14. # C++ standard can be overridden when this is used as a sub-project.
  15. if(NOT CMAKE_CXX_STANDARD)
  16. # This project requires C++11.
  17. set(CMAKE_CXX_STANDARD 11)
  18. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  19. set(CMAKE_CXX_EXTENSIONS OFF)
  20. endif(NOT CMAKE_CXX_STANDARD)
  21. if (WIN32)
  22. set(LEVELDB_PLATFORM_NAME LEVELDB_PLATFORM_WINDOWS)
  23. # TODO(cmumford): Make UNICODE configurable for Windows.
  24. add_definitions(-D_UNICODE -DUNICODE)
  25. else (WIN32)
  26. set(LEVELDB_PLATFORM_NAME LEVELDB_PLATFORM_POSIX)
  27. endif (WIN32)
  28. option(LEVELDB_BUILD_TESTS "Build LevelDB's unit tests" ON)
  29. option(LEVELDB_BUILD_BENCHMARKS "Build LevelDB's benchmarks" ON)
  30. option(LEVELDB_INSTALL "Install LevelDB's header and library" ON)
  31. include(CheckIncludeFile)
  32. check_include_file("unistd.h" HAVE_UNISTD_H)
  33. include(CheckLibraryExists)
  34. check_library_exists(crc32c crc32c_value "" HAVE_CRC32C)
  35. check_library_exists(snappy snappy_compress "" HAVE_SNAPPY)
  36. check_library_exists(tcmalloc malloc "" HAVE_TCMALLOC)
  37. include(CheckCXXSymbolExists)
  38. # Using check_cxx_symbol_exists() instead of check_c_symbol_exists() because
  39. # we're including the header from C++, and feature detection should use the same
  40. # compiler language that the project will use later. Principles aside, some
  41. # versions of do not expose fdatasync() in <unistd.h> in standard C mode
  42. # (-std=c11), but do expose the function in standard C++ mode (-std=c++11).
  43. check_cxx_symbol_exists(fdatasync "unistd.h" HAVE_FDATASYNC)
  44. check_cxx_symbol_exists(F_FULLFSYNC "fcntl.h" HAVE_FULLFSYNC)
  45. check_cxx_symbol_exists(O_CLOEXEC "fcntl.h" HAVE_O_CLOEXEC)
  46. if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
  47. # Disable C++ exceptions.
  48. string(REGEX REPLACE "/EH[a-z]+" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
  49. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHs-c-")
  50. add_definitions(-D_HAS_EXCEPTIONS=0)
  51. # Disable RTTI.
  52. string(REGEX REPLACE "/GR" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
  53. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR-")
  54. else(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
  55. # Enable strict prototype warnings for C code in clang and gcc.
  56. if(NOT CMAKE_C_FLAGS MATCHES "-Wstrict-prototypes")
  57. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wstrict-prototypes")
  58. endif(NOT CMAKE_C_FLAGS MATCHES "-Wstrict-prototypes")
  59. # Disable C++ exceptions.
  60. string(REGEX REPLACE "-fexceptions" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
  61. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
  62. # Disable RTTI.
  63. string(REGEX REPLACE "-frtti" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
  64. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
  65. endif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
  66. # Test whether -Wthread-safety is available. See
  67. # https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
  68. include(CheckCXXCompilerFlag)
  69. check_cxx_compiler_flag(-Wthread-safety HAVE_CLANG_THREAD_SAFETY)
  70. # Used by googletest.
  71. check_cxx_compiler_flag(-Wno-missing-field-initializers
  72. LEVELDB_HAVE_NO_MISSING_FIELD_INITIALIZERS)
  73. include(CheckCXXSourceCompiles)
  74. # Test whether C++17 __has_include is available.
  75. check_cxx_source_compiles("
  76. #if defined(__has_include) && __has_include(<string>)
  77. #include <string>
  78. #endif
  79. int main() { std::string str; return 0; }
  80. " HAVE_CXX17_HAS_INCLUDE)
  81. set(LEVELDB_PUBLIC_INCLUDE_DIR "include/leveldb")
  82. set(LEVELDB_PORT_CONFIG_DIR "include/port")
  83. configure_file(
  84. "port/port_config.h.in"
  85. "${PROJECT_BINARY_DIR}/${LEVELDB_PORT_CONFIG_DIR}/port_config.h"
  86. )
  87. include_directories(
  88. "${PROJECT_BINARY_DIR}/include"
  89. "."
  90. )
  91. if(BUILD_SHARED_LIBS)
  92. # Only export LEVELDB_EXPORT symbols from the shared library.
  93. add_compile_options(-fvisibility=hidden)
  94. endif(BUILD_SHARED_LIBS)
  95. # Must be included before CMAKE_INSTALL_INCLUDEDIR is used.
  96. include(GNUInstallDirs)
  97. add_library(leveldb "")
  98. target_sources(leveldb
  99. PRIVATE
  100. "${PROJECT_BINARY_DIR}/${LEVELDB_PORT_CONFIG_DIR}/port_config.h"
  101. "db/builder.cc"
  102. "db/builder.h"
  103. "db/c.cc"
  104. "db/db_impl.cc"
  105. "db/db_impl.h"
  106. "db/db_iter.cc"
  107. "db/db_iter.h"
  108. "db/dbformat.cc"
  109. "db/dbformat.h"
  110. "db/dumpfile.cc"
  111. "db/filename.cc"
  112. "db/filename.h"
  113. "db/log_format.h"
  114. "db/log_reader.cc"
  115. "db/log_reader.h"
  116. "db/log_writer.cc"
  117. "db/log_writer.h"
  118. "db/memtable.cc"
  119. "db/memtable.h"
  120. "db/repair.cc"
  121. "db/skiplist.h"
  122. "db/snapshot.h"
  123. "db/table_cache.cc"
  124. "db/table_cache.h"
  125. "db/version_edit.cc"
  126. "db/version_edit.h"
  127. "db/version_set.cc"
  128. "db/version_set.h"
  129. "db/write_batch_internal.h"
  130. "db/write_batch.cc"
  131. "port/port_stdcxx.h"
  132. "port/port.h"
  133. "port/thread_annotations.h"
  134. "table/block_builder.cc"
  135. "table/block_builder.h"
  136. "table/block.cc"
  137. "table/block.h"
  138. "table/filter_block.cc"
  139. "table/filter_block.h"
  140. "table/format.cc"
  141. "table/format.h"
  142. "table/iterator_wrapper.h"
  143. "table/iterator.cc"
  144. "table/merger.cc"
  145. "table/merger.h"
  146. "table/table_builder.cc"
  147. "table/table.cc"
  148. "table/two_level_iterator.cc"
  149. "table/two_level_iterator.h"
  150. "util/arena.cc"
  151. "util/arena.h"
  152. "util/bloom.cc"
  153. "util/cache.cc"
  154. "util/coding.cc"
  155. "util/coding.h"
  156. "util/comparator.cc"
  157. "util/crc32c.cc"
  158. "util/crc32c.h"
  159. "util/env.cc"
  160. "util/filter_policy.cc"
  161. "util/hash.cc"
  162. "util/hash.h"
  163. "util/logging.cc"
  164. "util/logging.h"
  165. "util/mutexlock.h"
  166. "util/no_destructor.h"
  167. "util/options.cc"
  168. "util/random.h"
  169. "util/status.cc"
  170. # Only CMake 3.3+ supports PUBLIC sources in targets exported by "install".
  171. $<$<VERSION_GREATER:CMAKE_VERSION,3.2>:PUBLIC>
  172. "${LEVELDB_PUBLIC_INCLUDE_DIR}/c.h"
  173. "${LEVELDB_PUBLIC_INCLUDE_DIR}/cache.h"
  174. "${LEVELDB_PUBLIC_INCLUDE_DIR}/comparator.h"
  175. "${LEVELDB_PUBLIC_INCLUDE_DIR}/db.h"
  176. "${LEVELDB_PUBLIC_INCLUDE_DIR}/dumpfile.h"
  177. "${LEVELDB_PUBLIC_INCLUDE_DIR}/env.h"
  178. "${LEVELDB_PUBLIC_INCLUDE_DIR}/export.h"
  179. "${LEVELDB_PUBLIC_INCLUDE_DIR}/filter_policy.h"
  180. "${LEVELDB_PUBLIC_INCLUDE_DIR}/iterator.h"
  181. "${LEVELDB_PUBLIC_INCLUDE_DIR}/options.h"
  182. "${LEVELDB_PUBLIC_INCLUDE_DIR}/slice.h"
  183. "${LEVELDB_PUBLIC_INCLUDE_DIR}/status.h"
  184. "${LEVELDB_PUBLIC_INCLUDE_DIR}/table_builder.h"
  185. "${LEVELDB_PUBLIC_INCLUDE_DIR}/table.h"
  186. "${LEVELDB_PUBLIC_INCLUDE_DIR}/write_batch.h"
  187. )
  188. if (WIN32)
  189. target_sources(leveldb
  190. PRIVATE
  191. "util/env_windows.cc"
  192. "util/windows_logger.h"
  193. )
  194. else (WIN32)
  195. target_sources(leveldb
  196. PRIVATE
  197. "util/env_posix.cc"
  198. "util/posix_logger.h"
  199. )
  200. endif (WIN32)
  201. # MemEnv is not part of the interface and could be pulled to a separate library.
  202. target_sources(leveldb
  203. PRIVATE
  204. "helpers/memenv/memenv.cc"
  205. "helpers/memenv/memenv.h"
  206. )
  207. target_include_directories(leveldb
  208. PUBLIC
  209. $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
  210. $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
  211. )
  212. set_target_properties(leveldb
  213. PROPERTIES VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR})
  214. target_compile_definitions(leveldb
  215. PRIVATE
  216. # Used by include/export.h when building shared libraries.
  217. LEVELDB_COMPILE_LIBRARY
  218. # Used by port/port.h.
  219. ${LEVELDB_PLATFORM_NAME}=1
  220. )
  221. if (NOT HAVE_CXX17_HAS_INCLUDE)
  222. target_compile_definitions(leveldb
  223. PRIVATE
  224. LEVELDB_HAS_PORT_CONFIG_H=1
  225. )
  226. endif(NOT HAVE_CXX17_HAS_INCLUDE)
  227. if(BUILD_SHARED_LIBS)
  228. target_compile_definitions(leveldb
  229. PUBLIC
  230. # Used by include/export.h.
  231. LEVELDB_SHARED_LIBRARY
  232. )
  233. endif(BUILD_SHARED_LIBS)
  234. if(HAVE_CLANG_THREAD_SAFETY)
  235. target_compile_options(leveldb
  236. PUBLIC
  237. -Werror -Wthread-safety)
  238. endif(HAVE_CLANG_THREAD_SAFETY)
  239. if(HAVE_CRC32C)
  240. target_link_libraries(leveldb crc32c)
  241. endif(HAVE_CRC32C)
  242. if(HAVE_SNAPPY)
  243. target_link_libraries(leveldb snappy)
  244. endif(HAVE_SNAPPY)
  245. if(HAVE_TCMALLOC)
  246. target_link_libraries(leveldb tcmalloc)
  247. endif(HAVE_TCMALLOC)
  248. # Needed by port_stdcxx.h
  249. find_package(Threads REQUIRED)
  250. target_link_libraries(leveldb Threads::Threads)
  251. add_executable(leveldbutil
  252. "db/leveldbutil.cc"
  253. )
  254. target_link_libraries(leveldbutil leveldb)
  255. if(LEVELDB_BUILD_TESTS)
  256. enable_testing()
  257. # Prevent overriding the parent project's compiler/linker settings on Windows.
  258. set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
  259. set(install_gtest OFF)
  260. set(install_gmock OFF)
  261. set(build_gmock ON)
  262. # This project is tested using GoogleTest.
  263. add_subdirectory("third_party/googletest")
  264. # GoogleTest triggers a missing field initializers warning.
  265. if(LEVELDB_HAVE_NO_MISSING_FIELD_INITIALIZERS)
  266. set_property(TARGET gtest
  267. APPEND PROPERTY COMPILE_OPTIONS -Wno-missing-field-initializers)
  268. set_property(TARGET gmock
  269. APPEND PROPERTY COMPILE_OPTIONS -Wno-missing-field-initializers)
  270. endif(LEVELDB_HAVE_NO_MISSING_FIELD_INITIALIZERS)
  271. add_executable(leveldb_tests "")
  272. target_sources(leveldb_tests
  273. PRIVATE
  274. # "db/fault_injection_test.cc"
  275. # "issues/issue178_test.cc"
  276. # "issues/issue200_test.cc"
  277. # "issues/issue320_test.cc"
  278. "${PROJECT_BINARY_DIR}/${LEVELDB_PORT_CONFIG_DIR}/port_config.h"
  279. # "util/env_test.cc"
  280. "util/status_test.cc"
  281. "util/no_destructor_test.cc"
  282. "util/testutil.cc"
  283. "util/testutil.h"
  284. )
  285. if(NOT BUILD_SHARED_LIBS)
  286. target_sources(leveldb_tests
  287. PRIVATE
  288. "db/autocompact_test.cc"
  289. "db/corruption_test.cc"
  290. "db/db_test.cc"
  291. "db/dbformat_test.cc"
  292. "db/filename_test.cc"
  293. "db/log_test.cc"
  294. "db/recovery_test.cc"
  295. "db/skiplist_test.cc"
  296. "db/version_edit_test.cc"
  297. "db/version_set_test.cc"
  298. "db/write_batch_test.cc"
  299. "helpers/memenv/memenv_test.cc"
  300. "table/filter_block_test.cc"
  301. "table/table_test.cc"
  302. "util/arena_test.cc"
  303. "util/bloom_test.cc"
  304. "util/cache_test.cc"
  305. "util/coding_test.cc"
  306. "util/crc32c_test.cc"
  307. "util/hash_test.cc"
  308. "util/logging_test.cc"
  309. )
  310. endif(NOT BUILD_SHARED_LIBS)
  311. target_link_libraries(leveldb_tests leveldb gmock gtest gtest_main)
  312. target_compile_definitions(leveldb_tests
  313. PRIVATE
  314. ${LEVELDB_PLATFORM_NAME}=1
  315. )
  316. if (NOT HAVE_CXX17_HAS_INCLUDE)
  317. target_compile_definitions(leveldb_tests
  318. PRIVATE
  319. LEVELDB_HAS_PORT_CONFIG_H=1
  320. )
  321. endif(NOT HAVE_CXX17_HAS_INCLUDE)
  322. add_test(NAME "leveldb_tests" COMMAND "leveldb_tests")
  323. function(leveldb_test test_file)
  324. get_filename_component(test_target_name "${test_file}" NAME_WE)
  325. add_executable("${test_target_name}" "")
  326. target_sources("${test_target_name}"
  327. PRIVATE
  328. "${PROJECT_BINARY_DIR}/${LEVELDB_PORT_CONFIG_DIR}/port_config.h"
  329. "util/testutil.cc"
  330. "util/testutil.h"
  331. "${test_file}"
  332. )
  333. target_link_libraries("${test_target_name}" leveldb gmock gtest)
  334. target_compile_definitions("${test_target_name}"
  335. PRIVATE
  336. ${LEVELDB_PLATFORM_NAME}=1
  337. )
  338. if (NOT HAVE_CXX17_HAS_INCLUDE)
  339. target_compile_definitions("${test_target_name}"
  340. PRIVATE
  341. LEVELDB_HAS_PORT_CONFIG_H=1
  342. )
  343. endif(NOT HAVE_CXX17_HAS_INCLUDE)
  344. add_test(NAME "${test_target_name}" COMMAND "${test_target_name}")
  345. endfunction(leveldb_test)
  346. leveldb_test("db/c_test.c")
  347. if(NOT BUILD_SHARED_LIBS)
  348. # TODO(costan): This test also uses
  349. # "util/env_{posix|windows}_test_helper.h"
  350. if (WIN32)
  351. leveldb_test("util/env_windows_test.cc")
  352. else (WIN32)
  353. leveldb_test("util/env_posix_test.cc")
  354. endif (WIN32)
  355. endif(NOT BUILD_SHARED_LIBS)
  356. endif(LEVELDB_BUILD_TESTS)
  357. if(LEVELDB_BUILD_BENCHMARKS)
  358. # This project uses Google benchmark for benchmarking.
  359. set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "" FORCE)
  360. set(BENCHMARK_ENABLE_EXCEPTIONS OFF CACHE BOOL "" FORCE)
  361. add_subdirectory("third_party/benchmark")
  362. function(leveldb_benchmark bench_file)
  363. get_filename_component(bench_target_name "${bench_file}" NAME_WE)
  364. add_executable("${bench_target_name}" "")
  365. target_sources("${bench_target_name}"
  366. PRIVATE
  367. "${PROJECT_BINARY_DIR}/${LEVELDB_PORT_CONFIG_DIR}/port_config.h"
  368. "util/histogram.cc"
  369. "util/histogram.h"
  370. "util/testutil.cc"
  371. "util/testutil.h"
  372. "${bench_file}"
  373. )
  374. target_link_libraries("${bench_target_name}" leveldb gmock gtest benchmark)
  375. target_compile_definitions("${bench_target_name}"
  376. PRIVATE
  377. ${LEVELDB_PLATFORM_NAME}=1
  378. )
  379. if (NOT HAVE_CXX17_HAS_INCLUDE)
  380. target_compile_definitions("${bench_target_name}"
  381. PRIVATE
  382. LEVELDB_HAS_PORT_CONFIG_H=1
  383. )
  384. endif(NOT HAVE_CXX17_HAS_INCLUDE)
  385. endfunction(leveldb_benchmark)
  386. if(NOT BUILD_SHARED_LIBS)
  387. leveldb_benchmark("benchmarks/db_bench.cc")
  388. endif(NOT BUILD_SHARED_LIBS)
  389. check_library_exists(sqlite3 sqlite3_open "" HAVE_SQLITE3)
  390. if(HAVE_SQLITE3)
  391. leveldb_benchmark("benchmarks/db_bench_sqlite3.cc")
  392. target_link_libraries(db_bench_sqlite3 sqlite3)
  393. endif(HAVE_SQLITE3)
  394. # check_library_exists is insufficient here because the library names have
  395. # different manglings when compiled with clang or gcc, at least when installed
  396. # with Homebrew on Mac.
  397. set(OLD_CMAKE_REQURED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
  398. list(APPEND CMAKE_REQUIRED_LIBRARIES kyotocabinet)
  399. check_cxx_source_compiles("
  400. #include <kcpolydb.h>
  401. int main() {
  402. kyotocabinet::TreeDB* db = new kyotocabinet::TreeDB();
  403. delete db;
  404. return 0;
  405. }
  406. " HAVE_KYOTOCABINET)
  407. set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQURED_LIBRARIES})
  408. if(HAVE_KYOTOCABINET)
  409. leveldb_benchmark("benchmarks/db_bench_tree_db.cc")
  410. target_link_libraries(db_bench_tree_db kyotocabinet)
  411. endif(HAVE_KYOTOCABINET)
  412. endif(LEVELDB_BUILD_BENCHMARKS)
  413. if(LEVELDB_INSTALL)
  414. install(TARGETS leveldb
  415. EXPORT leveldbTargets
  416. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  417. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  418. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  419. )
  420. install(
  421. FILES
  422. "${LEVELDB_PUBLIC_INCLUDE_DIR}/c.h"
  423. "${LEVELDB_PUBLIC_INCLUDE_DIR}/cache.h"
  424. "${LEVELDB_PUBLIC_INCLUDE_DIR}/comparator.h"
  425. "${LEVELDB_PUBLIC_INCLUDE_DIR}/db.h"
  426. "${LEVELDB_PUBLIC_INCLUDE_DIR}/dumpfile.h"
  427. "${LEVELDB_PUBLIC_INCLUDE_DIR}/env.h"
  428. "${LEVELDB_PUBLIC_INCLUDE_DIR}/export.h"
  429. "${LEVELDB_PUBLIC_INCLUDE_DIR}/filter_policy.h"
  430. "${LEVELDB_PUBLIC_INCLUDE_DIR}/iterator.h"
  431. "${LEVELDB_PUBLIC_INCLUDE_DIR}/options.h"
  432. "${LEVELDB_PUBLIC_INCLUDE_DIR}/slice.h"
  433. "${LEVELDB_PUBLIC_INCLUDE_DIR}/status.h"
  434. "${LEVELDB_PUBLIC_INCLUDE_DIR}/table_builder.h"
  435. "${LEVELDB_PUBLIC_INCLUDE_DIR}/table.h"
  436. "${LEVELDB_PUBLIC_INCLUDE_DIR}/write_batch.h"
  437. DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/leveldb"
  438. )
  439. include(CMakePackageConfigHelpers)
  440. configure_package_config_file(
  441. "cmake/${PROJECT_NAME}Config.cmake.in"
  442. "${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake"
  443. INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
  444. )
  445. write_basic_package_version_file(
  446. "${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake"
  447. COMPATIBILITY SameMajorVersion
  448. )
  449. install(
  450. EXPORT leveldbTargets
  451. NAMESPACE leveldb::
  452. DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
  453. )
  454. install(
  455. FILES
  456. "${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake"
  457. "${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake"
  458. DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
  459. )
  460. endif(LEVELDB_INSTALL)