Skip to content

Commit

Permalink
Enable OLP_SDK_ENABLE_DEFAULT_CACHE_LMDB flag
Browse files Browse the repository at this point in the history
lmdb is added to external libraries. CMakeLists.txt.lmdb.in and
lmdbConfig.cmake.in was created for lmdb.
Changes in olp-cpp-sdk-core and external CMakeLists.txt was made.
Added OLP_SDK_ENABLE_DEFAULT_CACHE_LMDB option to be able to
enable/disable build of lmdb. README.md was changed with
description of a new flag.

Relates-To: OLPEDGE-2645

Signed-off-by: Yevhen Krasilnyk <[email protected]>
  • Loading branch information
Smartkras committed Oct 8, 2021
1 parent 6c08481 commit 9119b13
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ option(OLP_SDK_BUILD_EXTERNAL_DEPS "Download and build external dependencies" ON
option(OLP_SDK_BUILD_EXAMPLES "Enable examples targets" OFF)
option(OLP_SDK_MSVC_PARALLEL_BUILD_ENABLE "Enable parallel build on MSVC" ON)
option(OLP_SDK_DISABLE_DEBUG_LOGGING "Disable debug and trace level logging" OFF)
option(OLP_SDK_ENABLE_DEFAULT_CACHE "Enable default cache implementation" ON)
option(OLP_SDK_ENABLE_DEFAULT_CACHE_LMDB "Enable default cache implementation based on LMDB" OFF)
option(OLP_SDK_ENABLE_DEFAULT_CACHE "Enable default cache implementation based on LevelDB" OFF)
option(OLP_SDK_ENABLE_DEFAULT_CACHE_LMDB "Enable default cache implementation based on LMDB" ON)

# C++ standard version. Minimum supported version is 11.
set(CMAKE_CXX_STANDARD 11)
Expand Down
4 changes: 4 additions & 0 deletions examples/android/app/CMakeLists.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ find_package(olp-cpp-sdk-dataservice-write REQUIRED)
find_package(leveldb REQUIRED)
find_package(Threads REQUIRED)

if(OLP_SDK_ENABLE_DEFAULT_CACHE_LMDB)
find_package(lmdb REQUIRED)
endif()

add_library(@OLP_SDK_EXAMPLE_TARGET_NAME@ SHARED
${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/Examples.h
${CMAKE_CURRENT_SOURCE_DIR}/src/main/cpp/ReadExample.h
Expand Down
5 changes: 4 additions & 1 deletion examples/android/app/build.gradle.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@ android {
// 2. OLP_SDK_HTTP_CLIENT_JAR - path to the OlpHttpClient.jar file; usually it stored in the <olp-build-folder>/olp-cpp-sdk-core/
// 3. (If not installed to the sysroot) path to the levelDB library:
// - leveldb_DIR;
// 4. (If not installed to the sysroot) - path to the OLP SDK cmake config files:
// 4. (If not installed to the sysroot) path to the lmdb library:
// - lmdb_DIR;
// 5. (If not installed to the sysroot) - path to the OLP SDK cmake config files:
// - olp-cpp-sdk-core_DIR;
// - olp-cpp-sdk-dataservice-write_DIR;
// - olp-cpp-sdk-authentication_DIR
arguments "@OLP_SDK_EXAMPLE_ANDROID_TOOLCHAIN_FILE@",
"@OLP_SDK_EXAMPLE_HTTP_CLIENT_JAR@",
"@OLP_SDK_EXAMPLE_LEVELDB_DIR@",
"@OLP_SDK_EXAMPLE_LMDB_DIR@",
// required for finding installed packages in sysroot
"-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH",
"-DBOOST_ROOT=@BOOST_ROOT@",
Expand Down
7 changes: 7 additions & 0 deletions examples/cmake/gen_android_example.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ function(gen_android_example_application
if (DEFINED leveldb_DIR)
set(OLP_SDK_EXAMPLE_LEVELDB_DIR "-Dleveldb_DIR=${leveldb_DIR}")
endif()

if(OLP_SDK_ENABLE_DEFAULT_CACHE_LMDB)
set(OLP_SDK_EXAMPLE_LMDB_DIR "-Dlmdb_DIR='path to the directory which contains LMDB cmake config files'")
if (DEFINED lmdb_DIR)
set(OLP_SDK_EXAMPLE_LMDB_DIR "-Dlmdb_DIR=${lmdb_DIR}")
endif()
endif()

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/android/app/build.gradle.in
Expand Down
1 change: 1 addition & 0 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ if(OLP_SDK_ENABLE_DEFAULT_CACHE_LMDB)
find_package(lmdb QUIET)
if(NOT TARGET lmdb AND NOT lmdb_FOUND)
add_subdirectory(lmdb)
set(lmdb_DIR ${EXTERNAL_lmdb_DIR} PARENT_SCOPE)
set(lmdb_INCLUDE_DIR ${EXTERNAL_lmdb_INCLUDE_DIR} PARENT_SCOPE)
endif()
endif()
Expand Down
1 change: 1 addition & 0 deletions external/lmdb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ if(result)
endif()

# Provide the dir to the lmdb cmake configuration files
set(EXTERNAL_lmdb_DIR ${EXTERNAL_BINARY_INSTALL_DIR}/lib/cmake/lmdb PARENT_SCOPE)
set(EXTERNAL_lmdb_INCLUDE_DIR ${EXTERNAL_BINARY_INSTALL_DIR}/include PARENT_SCOPE)
1 change: 1 addition & 0 deletions scripts/linux/psv/build_psv_no_cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ cd build
cmake \
-DOLP_SDK_ENABLE_TESTING=OFF \
-DOLP_SDK_ENABLE_DEFAULT_CACHE=OFF \
-DOLP_SDK_ENABLE_DEFAULT_CACHE_LMDB=OFF \
-DBUILD_SHARED_LIBS=ON \
..

Expand Down

0 comments on commit 9119b13

Please sign in to comment.