From f4583f7480bd2134ee09ec38f369f68c81bfc7cb Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 18 Jun 2020 17:58:24 -0700 Subject: [PATCH] add WITH_EXAMPLES options to cmake and cleanups. (#6580) Summary: Pull Request resolved: https://github.com/facebook/rocksdb/pull/6580 Reviewed By: cheng-chang Differential Revision: D21846336 Pulled By: ajkr fbshipit-source-id: e5bb0152a0876061d4ff158e7144eb9cc5a88cad --- CMakeLists.txt | 5 +++++ examples/CMakeLists.txt | 45 ++++++++++++++++++++++++++++++++++++++ examples/simple_example.cc | 2 +- 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 examples/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 631c6d03c..7170dcc53 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1269,3 +1269,8 @@ if(WITH_TOOLS) add_custom_target(tools DEPENDS ${tool_deps}) endif() + +option(WITH_EXAMPLES "build with examples" OFF) +if(WITH_EXAMPLES) + add_subdirectory(examples) +endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 000000000..0b93a6d8d --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,45 @@ +add_executable(simple_example + simple_example.cc) +target_link_libraries(simple_example + ${ROCKSDB_LIB}) + +add_executable(column_families_example + column_families_example.cc) +target_link_libraries(column_families_example + ${ROCKSDB_LIB}) + +add_executable(compact_files_example + compact_files_example.cc) +target_link_libraries(compact_files_example + ${ROCKSDB_LIB}) + +add_executable(c_simple_example + c_simple_example.c) +target_link_libraries(c_simple_example + ${ROCKSDB_LIB}) + +add_executable(optimistic_transaction_example + optimistic_transaction_example.cc) +target_link_libraries(optimistic_transaction_example + ${ROCKSDB_LIB}) + +add_executable(transaction_example + transaction_example.cc) +target_link_libraries(transaction_example + ${ROCKSDB_LIB}) + +add_executable(compaction_filter_example + compaction_filter_example.cc) +target_link_libraries(compaction_filter_example + ${ROCKSDB_LIB}) + +add_executable(options_file_example + options_file_example.cc) +target_link_libraries(options_file_example + ${ROCKSDB_LIB}) + +add_executable(multi_processes_example + EXCLUDE_FROM_ALL + multi_processes_example.cc) +target_link_libraries(multi_processes_example + ${ROCKSDB_LIB}) diff --git a/examples/simple_example.cc b/examples/simple_example.cc index 256c965d7..98102c073 100644 --- a/examples/simple_example.cc +++ b/examples/simple_example.cc @@ -68,7 +68,7 @@ int main() { } PinnableSlice pinnable_val; - db->Get(ReadOptions(), db->DefaultColumnFamily(), "key1", &pinnable_val); + s = db->Get(ReadOptions(), db->DefaultColumnFamily(), "key1", &pinnable_val); assert(s.IsNotFound()); // Reset PinnableSlice after each use and before each reuse pinnable_val.Reset();