小组成员:10215300402-朱维清 & 10222140408 谷杰
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

450 rader
16 KiB

  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(CheckSymbolExists)
  26. check_symbol_exists(fdatasync "unistd.h" HAVE_FDATASYNC)
  27. include(CheckCXXSourceCompiles)
  28. # Test whether -Wthread-safety is available. See
  29. # https://clang.llvm.org/docs/ThreadSafetyAnalysis.html
  30. # -Werror is necessary because unknown attributes only generate warnings.
  31. set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
  32. list(APPEND CMAKE_REQUIRED_FLAGS -Werror -Wthread-safety)
  33. check_cxx_source_compiles("
  34. struct __attribute__((lockable)) Lock {
  35. void Acquire() __attribute__((exclusive_lock_function()));
  36. void Release() __attribute__((unlock_function()));
  37. };
  38. struct ThreadSafeType {
  39. Lock lock_;
  40. int data_ __attribute__((guarded_by(lock_)));
  41. };
  42. int main() { return 0; }
  43. " HAVE_CLANG_THREAD_SAFETY)
  44. set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
  45. # Test whether C++17 __has_include is available.
  46. check_cxx_source_compiles("
  47. #if defined(__has_include) && __has_include(<string>)
  48. #include <string>
  49. #endif
  50. int main() { std::string str; return 0; }
  51. " HAVE_CXX17_HAS_INCLUDE)
  52. set(LEVELDB_PUBLIC_INCLUDE_DIR "include/leveldb")
  53. set(LEVELDB_PORT_CONFIG_DIR "include/port")
  54. configure_file(
  55. "${PROJECT_SOURCE_DIR}/port/port_config.h.in"
  56. "${PROJECT_BINARY_DIR}/${LEVELDB_PORT_CONFIG_DIR}/port_config.h"
  57. )
  58. include_directories(
  59. "${PROJECT_BINARY_DIR}/include"
  60. "${PROJECT_SOURCE_DIR}"
  61. )
  62. if(BUILD_SHARED_LIBS)
  63. # Only export LEVELDB_EXPORT symbols from the shared library.
  64. add_compile_options(-fvisibility=hidden)
  65. endif(BUILD_SHARED_LIBS)
  66. # POSIX code is specified separately so we can leave it out in the future.
  67. add_library(leveldb_port_posix OBJECT "")
  68. target_sources(leveldb_port_posix
  69. PRIVATE
  70. "${PROJECT_SOURCE_DIR}/port/port_posix.cc"
  71. PUBLIC
  72. # The headers below are dependencies for leveldb, but aren't needed by users
  73. # that link to the installed version of leveldb and rely on its public API.
  74. $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/${LEVELDB_PORT_CONFIG_DIR}/port_config.h>
  75. $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/port/atomic_pointer.h>
  76. $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/port/port_posix.h>
  77. $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/port/port.h>
  78. )
  79. if (NOT HAVE_CXX17_HAS_INCLUDE)
  80. target_compile_definitions(leveldb_port_posix
  81. PRIVATE
  82. LEVELDB_HAS_PORT_CONFIG_H=1
  83. )
  84. endif(NOT HAVE_CXX17_HAS_INCLUDE)
  85. if(BUILD_SHARED_LIBS)
  86. set_property(TARGET leveldb_port_posix PROPERTY POSITION_INDEPENDENT_CODE ON)
  87. endif(BUILD_SHARED_LIBS)
  88. add_library(leveldb "")
  89. target_sources(leveldb
  90. PRIVATE
  91. "${PROJECT_SOURCE_DIR}/db/builder.cc"
  92. "${PROJECT_SOURCE_DIR}/db/builder.h"
  93. "${PROJECT_SOURCE_DIR}/db/c.cc"
  94. "${PROJECT_SOURCE_DIR}/db/db_impl.cc"
  95. "${PROJECT_SOURCE_DIR}/db/db_impl.h"
  96. "${PROJECT_SOURCE_DIR}/db/db_iter.cc"
  97. "${PROJECT_SOURCE_DIR}/db/db_iter.h"
  98. "${PROJECT_SOURCE_DIR}/db/dbformat.cc"
  99. "${PROJECT_SOURCE_DIR}/db/dbformat.h"
  100. "${PROJECT_SOURCE_DIR}/db/dumpfile.cc"
  101. "${PROJECT_SOURCE_DIR}/db/filename.cc"
  102. "${PROJECT_SOURCE_DIR}/db/filename.h"
  103. "${PROJECT_SOURCE_DIR}/db/log_format.h"
  104. "${PROJECT_SOURCE_DIR}/db/log_reader.cc"
  105. "${PROJECT_SOURCE_DIR}/db/log_reader.h"
  106. "${PROJECT_SOURCE_DIR}/db/log_writer.cc"
  107. "${PROJECT_SOURCE_DIR}/db/log_writer.h"
  108. "${PROJECT_SOURCE_DIR}/db/memtable.cc"
  109. "${PROJECT_SOURCE_DIR}/db/memtable.h"
  110. "${PROJECT_SOURCE_DIR}/db/repair.cc"
  111. "${PROJECT_SOURCE_DIR}/db/skiplist.h"
  112. "${PROJECT_SOURCE_DIR}/db/snapshot.h"
  113. "${PROJECT_SOURCE_DIR}/db/table_cache.cc"
  114. "${PROJECT_SOURCE_DIR}/db/table_cache.h"
  115. "${PROJECT_SOURCE_DIR}/db/version_edit.cc"
  116. "${PROJECT_SOURCE_DIR}/db/version_edit.h"
  117. "${PROJECT_SOURCE_DIR}/db/version_set.cc"
  118. "${PROJECT_SOURCE_DIR}/db/version_set.h"
  119. "${PROJECT_SOURCE_DIR}/db/write_batch_internal.h"
  120. "${PROJECT_SOURCE_DIR}/db/write_batch.cc"
  121. "${PROJECT_SOURCE_DIR}/port/port.h"
  122. "${PROJECT_SOURCE_DIR}/port/thread_annotations.h"
  123. "${PROJECT_SOURCE_DIR}/table/block_builder.cc"
  124. "${PROJECT_SOURCE_DIR}/table/block_builder.h"
  125. "${PROJECT_SOURCE_DIR}/table/block.cc"
  126. "${PROJECT_SOURCE_DIR}/table/block.h"
  127. "${PROJECT_SOURCE_DIR}/table/filter_block.cc"
  128. "${PROJECT_SOURCE_DIR}/table/filter_block.h"
  129. "${PROJECT_SOURCE_DIR}/table/format.cc"
  130. "${PROJECT_SOURCE_DIR}/table/format.h"
  131. "${PROJECT_SOURCE_DIR}/table/iterator_wrapper.h"
  132. "${PROJECT_SOURCE_DIR}/table/iterator.cc"
  133. "${PROJECT_SOURCE_DIR}/table/merger.cc"
  134. "${PROJECT_SOURCE_DIR}/table/merger.h"
  135. "${PROJECT_SOURCE_DIR}/table/table_builder.cc"
  136. "${PROJECT_SOURCE_DIR}/table/table.cc"
  137. "${PROJECT_SOURCE_DIR}/table/two_level_iterator.cc"
  138. "${PROJECT_SOURCE_DIR}/table/two_level_iterator.h"
  139. "${PROJECT_SOURCE_DIR}/util/arena.cc"
  140. "${PROJECT_SOURCE_DIR}/util/arena.h"
  141. "${PROJECT_SOURCE_DIR}/util/bloom.cc"
  142. "${PROJECT_SOURCE_DIR}/util/cache.cc"
  143. "${PROJECT_SOURCE_DIR}/util/coding.cc"
  144. "${PROJECT_SOURCE_DIR}/util/coding.h"
  145. "${PROJECT_SOURCE_DIR}/util/comparator.cc"
  146. "${PROJECT_SOURCE_DIR}/util/crc32c.cc"
  147. "${PROJECT_SOURCE_DIR}/util/crc32c.h"
  148. "${PROJECT_SOURCE_DIR}/util/env_posix.cc"
  149. "${PROJECT_SOURCE_DIR}/util/env.cc"
  150. "${PROJECT_SOURCE_DIR}/util/filter_policy.cc"
  151. "${PROJECT_SOURCE_DIR}/util/hash.cc"
  152. "${PROJECT_SOURCE_DIR}/util/hash.h"
  153. "${PROJECT_SOURCE_DIR}/util/logging.cc"
  154. "${PROJECT_SOURCE_DIR}/util/logging.h"
  155. "${PROJECT_SOURCE_DIR}/util/mutexlock.h"
  156. "${PROJECT_SOURCE_DIR}/util/options.cc"
  157. "${PROJECT_SOURCE_DIR}/util/posix_logger.h"
  158. "${PROJECT_SOURCE_DIR}/util/random.h"
  159. "${PROJECT_SOURCE_DIR}/util/status.cc"
  160. $<TARGET_OBJECTS:leveldb_port_posix>
  161. # Only CMake 3.3+ supports PUBLIC sources in targets exported by "install".
  162. $<$<VERSION_GREATER:CMAKE_VERSION,3.2>:PUBLIC>
  163. "${LEVELDB_PUBLIC_INCLUDE_DIR}/c.h"
  164. "${LEVELDB_PUBLIC_INCLUDE_DIR}/cache.h"
  165. "${LEVELDB_PUBLIC_INCLUDE_DIR}/comparator.h"
  166. "${LEVELDB_PUBLIC_INCLUDE_DIR}/db.h"
  167. "${LEVELDB_PUBLIC_INCLUDE_DIR}/dumpfile.h"
  168. "${LEVELDB_PUBLIC_INCLUDE_DIR}/env.h"
  169. "${LEVELDB_PUBLIC_INCLUDE_DIR}/export.h"
  170. "${LEVELDB_PUBLIC_INCLUDE_DIR}/filter_policy.h"
  171. "${LEVELDB_PUBLIC_INCLUDE_DIR}/iterator.h"
  172. "${LEVELDB_PUBLIC_INCLUDE_DIR}/options.h"
  173. "${LEVELDB_PUBLIC_INCLUDE_DIR}/slice.h"
  174. "${LEVELDB_PUBLIC_INCLUDE_DIR}/status.h"
  175. "${LEVELDB_PUBLIC_INCLUDE_DIR}/table_builder.h"
  176. "${LEVELDB_PUBLIC_INCLUDE_DIR}/table.h"
  177. "${LEVELDB_PUBLIC_INCLUDE_DIR}/write_batch.h"
  178. )
  179. # MemEnv is not part of the interface and could be pulled to a separate library.
  180. target_sources(leveldb
  181. PRIVATE
  182. "${PROJECT_SOURCE_DIR}/helpers/memenv/memenv.cc"
  183. "${PROJECT_SOURCE_DIR}/helpers/memenv/memenv.h"
  184. )
  185. target_include_directories(leveldb
  186. PUBLIC
  187. $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
  188. $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
  189. )
  190. target_compile_definitions(leveldb
  191. PRIVATE
  192. # Used by include/export.h when building shared libraries.
  193. LEVELDB_COMPILE_LIBRARY
  194. # Used by port/port.h.
  195. LEVELDB_PLATFORM_POSIX=1
  196. )
  197. if (NOT HAVE_CXX17_HAS_INCLUDE)
  198. target_compile_definitions(leveldb
  199. PRIVATE
  200. LEVELDB_HAS_PORT_CONFIG_H=1
  201. )
  202. endif(NOT HAVE_CXX17_HAS_INCLUDE)
  203. if(BUILD_SHARED_LIBS)
  204. target_compile_definitions(leveldb
  205. PUBLIC
  206. # Used by include/export.h.
  207. LEVELDB_SHARED_LIBRARY
  208. )
  209. endif(BUILD_SHARED_LIBS)
  210. if(HAVE_CLANG_THREAD_SAFETY)
  211. target_compile_options(leveldb
  212. PUBLIC
  213. -Werror -Wthread-safety)
  214. endif(HAVE_CLANG_THREAD_SAFETY)
  215. # TODO(costan): This is only needed for port_posix.
  216. set(THREADS_PREFER_PTHREAD_FLAG ON)
  217. find_package(Threads REQUIRED)
  218. target_link_libraries(leveldb Threads::Threads)
  219. if(HAVE_CRC32C)
  220. target_link_libraries(leveldb crc32c)
  221. endif(HAVE_CRC32C)
  222. if(HAVE_SNAPPY)
  223. target_link_libraries(leveldb snappy)
  224. endif(HAVE_SNAPPY)
  225. if(HAVE_TCMALLOC)
  226. target_link_libraries(leveldb tcmalloc)
  227. endif(HAVE_TCMALLOC)
  228. add_executable(leveldbutil
  229. "${PROJECT_SOURCE_DIR}/db/leveldbutil.cc"
  230. )
  231. target_link_libraries(leveldbutil leveldb)
  232. if(LEVELDB_BUILD_TESTS)
  233. enable_testing()
  234. function(leveldb_test test_file)
  235. get_filename_component(test_target_name "${test_file}" NAME_WE)
  236. add_executable("${test_target_name}" "")
  237. target_sources("${test_target_name}"
  238. PRIVATE
  239. "${PROJECT_BINARY_DIR}/${LEVELDB_PORT_CONFIG_DIR}/port_config.h"
  240. "${PROJECT_SOURCE_DIR}/util/testharness.cc"
  241. "${PROJECT_SOURCE_DIR}/util/testharness.h"
  242. "${PROJECT_SOURCE_DIR}/util/testutil.cc"
  243. "${PROJECT_SOURCE_DIR}/util/testutil.h"
  244. "${test_file}"
  245. )
  246. if(BUILD_SHARED_LIBS)
  247. # Port functions aren't exposed in the shared library build.
  248. target_sources("${test_target_name}"
  249. PRIVATE
  250. $<TARGET_OBJECTS:leveldb_port_posix>
  251. )
  252. endif(BUILD_SHARED_LIBS)
  253. target_link_libraries("${test_target_name}" leveldb)
  254. target_compile_definitions("${test_target_name}"
  255. PRIVATE
  256. LEVELDB_PLATFORM_POSIX=1
  257. )
  258. if (NOT HAVE_CXX17_HAS_INCLUDE)
  259. target_compile_definitions("${test_target_name}"
  260. PRIVATE
  261. LEVELDB_HAS_PORT_CONFIG_H=1
  262. )
  263. endif(NOT HAVE_CXX17_HAS_INCLUDE)
  264. add_test(NAME "${test_target_name}" COMMAND "${test_target_name}")
  265. endfunction(leveldb_test)
  266. leveldb_test("${PROJECT_SOURCE_DIR}/db/c_test.c")
  267. leveldb_test("${PROJECT_SOURCE_DIR}/db/fault_injection_test.cc")
  268. leveldb_test("${PROJECT_SOURCE_DIR}/issues/issue178_test.cc")
  269. leveldb_test("${PROJECT_SOURCE_DIR}/issues/issue200_test.cc")
  270. leveldb_test("${PROJECT_SOURCE_DIR}/util/env_test.cc")
  271. if(NOT BUILD_SHARED_LIBS)
  272. leveldb_test("${PROJECT_SOURCE_DIR}/db/autocompact_test.cc")
  273. leveldb_test("${PROJECT_SOURCE_DIR}/db/corruption_test.cc")
  274. leveldb_test("${PROJECT_SOURCE_DIR}/db/db_test.cc")
  275. leveldb_test("${PROJECT_SOURCE_DIR}/db/dbformat_test.cc")
  276. leveldb_test("${PROJECT_SOURCE_DIR}/db/filename_test.cc")
  277. leveldb_test("${PROJECT_SOURCE_DIR}/db/log_test.cc")
  278. leveldb_test("${PROJECT_SOURCE_DIR}/db/recovery_test.cc")
  279. leveldb_test("${PROJECT_SOURCE_DIR}/db/skiplist_test.cc")
  280. leveldb_test("${PROJECT_SOURCE_DIR}/db/version_edit_test.cc")
  281. leveldb_test("${PROJECT_SOURCE_DIR}/db/version_set_test.cc")
  282. leveldb_test("${PROJECT_SOURCE_DIR}/db/write_batch_test.cc")
  283. leveldb_test("${PROJECT_SOURCE_DIR}/helpers/memenv/memenv_test.cc")
  284. leveldb_test("${PROJECT_SOURCE_DIR}/table/filter_block_test.cc")
  285. leveldb_test("${PROJECT_SOURCE_DIR}/table/table_test.cc")
  286. leveldb_test("${PROJECT_SOURCE_DIR}/util/arena_test.cc")
  287. leveldb_test("${PROJECT_SOURCE_DIR}/util/bloom_test.cc")
  288. leveldb_test("${PROJECT_SOURCE_DIR}/util/cache_test.cc")
  289. leveldb_test("${PROJECT_SOURCE_DIR}/util/coding_test.cc")
  290. leveldb_test("${PROJECT_SOURCE_DIR}/util/crc32c_test.cc")
  291. leveldb_test("${PROJECT_SOURCE_DIR}/util/hash_test.cc")
  292. leveldb_test("${PROJECT_SOURCE_DIR}/util/logging_test.cc")
  293. # TODO(costan): This test also uses
  294. # "${PROJECT_SOURCE_DIR}/util/env_posix_test_helper.h"
  295. leveldb_test("${PROJECT_SOURCE_DIR}/util/env_posix_test.cc")
  296. endif(NOT BUILD_SHARED_LIBS)
  297. endif(LEVELDB_BUILD_TESTS)
  298. if(LEVELDB_BUILD_BENCHMARKS)
  299. function(leveldb_benchmark bench_file)
  300. get_filename_component(bench_target_name "${bench_file}" NAME_WE)
  301. add_executable("${bench_target_name}" "")
  302. target_sources("${bench_target_name}"
  303. PRIVATE
  304. "${PROJECT_BINARY_DIR}/${LEVELDB_PORT_CONFIG_DIR}/port_config.h"
  305. "${PROJECT_SOURCE_DIR}/util/histogram.cc"
  306. "${PROJECT_SOURCE_DIR}/util/histogram.h"
  307. "${PROJECT_SOURCE_DIR}/util/testharness.cc"
  308. "${PROJECT_SOURCE_DIR}/util/testharness.h"
  309. "${PROJECT_SOURCE_DIR}/util/testutil.cc"
  310. "${PROJECT_SOURCE_DIR}/util/testutil.h"
  311. "${bench_file}"
  312. )
  313. if(BUILD_SHARED_LIBS)
  314. # Port functions aren't exposed in the shared library build.
  315. target_sources("${bench_target_name}"
  316. PRIVATE
  317. $<TARGET_OBJECTS:leveldb_port_posix>
  318. )
  319. endif(BUILD_SHARED_LIBS)
  320. target_link_libraries("${bench_target_name}" leveldb)
  321. target_compile_definitions("${bench_target_name}"
  322. PRIVATE
  323. LEVELDB_PLATFORM_POSIX=1
  324. )
  325. if (NOT HAVE_CXX17_HAS_INCLUDE)
  326. target_compile_definitions("${bench_target_name}"
  327. PRIVATE
  328. LEVELDB_HAS_PORT_CONFIG_H=1
  329. )
  330. endif(NOT HAVE_CXX17_HAS_INCLUDE)
  331. endfunction(leveldb_benchmark)
  332. if(NOT BUILD_SHARED_LIBS)
  333. leveldb_benchmark("${PROJECT_SOURCE_DIR}/db/db_bench.cc")
  334. endif(NOT BUILD_SHARED_LIBS)
  335. check_library_exists(sqlite3 sqlite3_open "" HAVE_SQLITE3)
  336. if(HAVE_SQLITE3)
  337. leveldb_benchmark("${PROJECT_SOURCE_DIR}/doc/bench/db_bench_sqlite3.cc")
  338. target_link_libraries(db_bench_sqlite3 sqlite3)
  339. endif(HAVE_SQLITE3)
  340. # check_library_exists is insufficient here because the library names have
  341. # different manglings when compiled with clang or gcc, at least when installed
  342. # with Homebrew on Mac.
  343. set(OLD_CMAKE_REQURED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
  344. list(APPEND CMAKE_REQUIRED_LIBRARIES kyotocabinet)
  345. check_cxx_source_compiles("
  346. #include <kcpolydb.h>
  347. int main() {
  348. kyotocabinet::TreeDB* db = new kyotocabinet::TreeDB();
  349. delete db;
  350. return 0;
  351. }
  352. " HAVE_KYOTOCABINET)
  353. set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQURED_LIBRARIES})
  354. if(HAVE_KYOTOCABINET)
  355. leveldb_benchmark("${PROJECT_SOURCE_DIR}/doc/bench/db_bench_tree_db.cc")
  356. target_link_libraries(db_bench_tree_db kyotocabinet)
  357. endif(HAVE_KYOTOCABINET)
  358. endif(LEVELDB_BUILD_BENCHMARKS)
  359. if(LEVELDB_INSTALL)
  360. include(GNUInstallDirs)
  361. install(TARGETS leveldb
  362. EXPORT leveldbTargets
  363. RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  364. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  365. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  366. )
  367. install(
  368. FILES
  369. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/c.h"
  370. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/cache.h"
  371. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/comparator.h"
  372. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/db.h"
  373. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/dumpfile.h"
  374. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/env.h"
  375. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/export.h"
  376. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/filter_policy.h"
  377. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/iterator.h"
  378. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/options.h"
  379. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/slice.h"
  380. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/status.h"
  381. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/table_builder.h"
  382. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/table.h"
  383. "${PROJECT_SOURCE_DIR}/${LEVELDB_PUBLIC_INCLUDE_DIR}/write_batch.h"
  384. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/leveldb
  385. )
  386. include(CMakePackageConfigHelpers)
  387. write_basic_package_version_file(
  388. "${PROJECT_BINARY_DIR}/leveldbConfigVersion.cmake"
  389. COMPATIBILITY SameMajorVersion
  390. )
  391. install(
  392. EXPORT leveldbTargets
  393. NAMESPACE leveldb::
  394. DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/leveldb"
  395. )
  396. install(
  397. FILES
  398. "${PROJECT_SOURCE_DIR}/cmake/leveldbConfig.cmake"
  399. "${PROJECT_BINARY_DIR}/leveldbConfigVersion.cmake"
  400. DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/leveldb"
  401. )
  402. endif(LEVELDB_INSTALL)