小组成员:谢瑞阳、徐翔宇
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

490 Zeilen
15 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
vor 6 Jahren
  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.22.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. function(leveldb_test test_file)
  272. get_filename_component(test_target_name "${test_file}" NAME_WE)
  273. add_executable("${test_target_name}" "")
  274. target_sources("${test_target_name}"
  275. PRIVATE
  276. "${PROJECT_BINARY_DIR}/${LEVELDB_PORT_CONFIG_DIR}/port_config.h"
  277. "util/testutil.cc"
  278. "util/testutil.h"
  279. "${test_file}"
  280. )
  281. target_link_libraries("${test_target_name}" leveldb gmock gtest)
  282. target_compile_definitions("${test_target_name}"
  283. PRIVATE
  284. ${LEVELDB_PLATFORM_NAME}=1
  285. )
  286. if (NOT HAVE_CXX17_HAS_INCLUDE)
  287. target_compile_definitions("${test_target_name}"
  288. PRIVATE
  289. LEVELDB_HAS_PORT_CONFIG_H=1
  290. )
  291. endif(NOT HAVE_CXX17_HAS_INCLUDE)
  292. add_test(NAME "${test_target_name}" COMMAND "${test_target_name}")
  293. endfunction(leveldb_test)
  294. leveldb_test("db/c_test.c")
  295. leveldb_test("db/fault_injection_test.cc")
  296. leveldb_test("issues/issue178_test.cc")
  297. leveldb_test("issues/issue200_test.cc")
  298. leveldb_test("issues/issue320_test.cc")
  299. leveldb_test("util/env_test.cc")
  300. leveldb_test("util/status_test.cc")
  301. leveldb_test("util/no_destructor_test.cc")
  302. if(NOT BUILD_SHARED_LIBS)
  303. leveldb_test("db/autocompact_test.cc")
  304. leveldb_test("db/corruption_test.cc")
  305. leveldb_test("db/db_test.cc")
  306. leveldb_test("db/dbformat_test.cc")
  307. leveldb_test("db/filename_test.cc")
  308. leveldb_test("db/log_test.cc")
  309. leveldb_test("db/recovery_test.cc")
  310. leveldb_test("db/skiplist_test.cc")
  311. leveldb_test("db/version_edit_test.cc")
  312. leveldb_test("db/version_set_test.cc")
  313. leveldb_test("db/write_batch_test.cc")
  314. leveldb_test("helpers/memenv/memenv_test.cc")
  315. leveldb_test("table/filter_block_test.cc")
  316. leveldb_test("table/table_test.cc")
  317. leveldb_test("util/arena_test.cc")
  318. leveldb_test("util/bloom_test.cc")
  319. leveldb_test("util/cache_test.cc")
  320. leveldb_test("util/coding_test.cc")
  321. leveldb_test("util/crc32c_test.cc")
  322. leveldb_test("util/hash_test.cc")
  323. leveldb_test("util/logging_test.cc")
  324. # TODO(costan): This test also uses
  325. # "util/env_{posix|windows}_test_helper.h"
  326. if (WIN32)
  327. leveldb_test("util/env_windows_test.cc")
  328. else (WIN32)
  329. leveldb_test("util/env_posix_test.cc")
  330. endif (WIN32)
  331. endif(NOT BUILD_SHARED_LIBS)
  332. endif(LEVELDB_BUILD_TESTS)
  333. if(LEVELDB_BUILD_BENCHMARKS)
  334. function(leveldb_benchmark bench_file)
  335. get_filename_component(bench_target_name "${bench_file}" NAME_WE)
  336. add_executable("${bench_target_name}" "")
  337. target_sources("${bench_target_name}"
  338. PRIVATE
  339. "${PROJECT_BINARY_DIR}/${LEVELDB_PORT_CONFIG_DIR}/port_config.h"
  340. "util/histogram.cc"
  341. "util/histogram.h"
  342. "util/testutil.cc"
  343. "util/testutil.h"
  344. "${bench_file}"
  345. )
  346. target_link_libraries("${bench_target_name}" leveldb gmock gtest)
  347. target_compile_definitions("${bench_target_name}"
  348. PRIVATE
  349. ${LEVELDB_PLATFORM_NAME}=1
  350. )
  351. if (NOT HAVE_CXX17_HAS_INCLUDE)
  352. target_compile_definitions("${bench_target_name}"
  353. PRIVATE
  354. LEVELDB_HAS_PORT_CONFIG_H=1
  355. )
  356. endif(NOT HAVE_CXX17_HAS_INCLUDE)
  357. endfunction(leveldb_benchmark)
  358. if(NOT BUILD_SHARED_LIBS)
  359. leveldb_benchmark("benchmarks/db_bench.cc")
  360. endif(NOT BUILD_SHARED_LIBS)
  361. check_library_exists(sqlite3 sqlite3_open "" HAVE_SQLITE3)
  362. if(HAVE_SQLITE3)
  363. leveldb_benchmark("benchmarks/db_bench_sqlite3.cc")
  364. target_link_libraries(db_bench_sqlite3 sqlite3)
  365. endif(HAVE_SQLITE3)
  366. # check_library_exists is insufficient here because the library names have
  367. # different manglings when compiled with clang or gcc, at least when installed
  368. # with Homebrew on Mac.
  369. set(OLD_CMAKE_REQURED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
  370. list(APPEND CMAKE_REQUIRED_LIBRARIES kyotocabinet)
  371. check_cxx_source_compiles("
  372. #include <kcpolydb.h>
  373. int main() {
  374. kyotocabinet::TreeDB* db = new kyotocabinet::TreeDB();
  375. delete db;
  376. return 0;
  377. }
  378. " HAVE_KYOTOCABINET)
  379. set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQURED_LIBRARIES})
  380. if(HAVE_KYOTOCABINET)
  381. leveldb_benchmark("benchmarks/db_bench_tree_db.cc")
  382. target_link_libraries(db_bench_tree_db kyotocabinet)
  383. endif(HAVE_KYOTOCABINET)
  384. endif(LEVELDB_BUILD_BENCHMARKS)
  385. if(LEVELDB_INSTALL)
  386. install(TARGETS leveldb
  387. EXPORT leveldbTargets
  388. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  389. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  390. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  391. )
  392. install(
  393. FILES
  394. "${LEVELDB_PUBLIC_INCLUDE_DIR}/c.h"
  395. "${LEVELDB_PUBLIC_INCLUDE_DIR}/cache.h"
  396. "${LEVELDB_PUBLIC_INCLUDE_DIR}/comparator.h"
  397. "${LEVELDB_PUBLIC_INCLUDE_DIR}/db.h"
  398. "${LEVELDB_PUBLIC_INCLUDE_DIR}/dumpfile.h"
  399. "${LEVELDB_PUBLIC_INCLUDE_DIR}/env.h"
  400. "${LEVELDB_PUBLIC_INCLUDE_DIR}/export.h"
  401. "${LEVELDB_PUBLIC_INCLUDE_DIR}/filter_policy.h"
  402. "${LEVELDB_PUBLIC_INCLUDE_DIR}/iterator.h"
  403. "${LEVELDB_PUBLIC_INCLUDE_DIR}/options.h"
  404. "${LEVELDB_PUBLIC_INCLUDE_DIR}/slice.h"
  405. "${LEVELDB_PUBLIC_INCLUDE_DIR}/status.h"
  406. "${LEVELDB_PUBLIC_INCLUDE_DIR}/table_builder.h"
  407. "${LEVELDB_PUBLIC_INCLUDE_DIR}/table.h"
  408. "${LEVELDB_PUBLIC_INCLUDE_DIR}/write_batch.h"
  409. DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/leveldb"
  410. )
  411. include(CMakePackageConfigHelpers)
  412. configure_package_config_file(
  413. "cmake/${PROJECT_NAME}Config.cmake.in"
  414. "${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake"
  415. INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
  416. )
  417. write_basic_package_version_file(
  418. "${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake"
  419. COMPATIBILITY SameMajorVersion
  420. )
  421. install(
  422. EXPORT leveldbTargets
  423. NAMESPACE leveldb::
  424. DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
  425. )
  426. install(
  427. FILES
  428. "${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake"
  429. "${PROJECT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake"
  430. DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
  431. )
  432. endif(LEVELDB_INSTALL)