Skip to content

Commit 72018ca

Browse files
Nikhil Rakuster
authored andcommitted
rocksdb: Add an option to set static library
Modify the CMakeLists.txt to add an Option for STATIC target import, as available for shared library. Link: facebook/rocksdb#12890 Configure static library default to switched off as shared libraries are sufficient in most cases. Signed-off-by: Bhabu Bindu <[email protected]> Signed-off-by: Khem Raj <[email protected]> (cherry picked from commit 233079a) Signed-off-by: Armin Kuster <[email protected]>
1 parent 6c9e661 commit 72018ca

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
From 285d306494bde3e9c24c8cd6fea1eb380a304d03 Mon Sep 17 00:00:00 2001
2+
From: Bindu-Bhabu <[email protected]>
3+
Date: Fri, 26 Jul 2024 15:14:45 +0530
4+
Subject: Add option to CMake for building static libraries
5+
6+
ROCKSDB creates a STATIC library target reference by default.
7+
Modify the cmake so that the STATIC library is also an option
8+
just like creating a SHARED library and set default to ON.
9+
10+
Upstream-Status: Submitted [https://github.com/facebook/rocksdb/pull/12890]
11+
12+
Signed-off-by: Nisha Parrakat <[email protected]>
13+
Signed-off-by: Bindu Bhabu <[email protected]>
14+
---
15+
CMakeLists.txt | 29 +++++++++++++++++------------
16+
1 file changed, 17 insertions(+), 12 deletions(-)
17+
18+
diff --git a/CMakeLists.txt b/CMakeLists.txt
19+
index 93b884dd9c1..2ca925d505c 100644
20+
--- a/CMakeLists.txt
21+
+++ b/CMakeLists.txt
22+
@@ -98,6 +98,7 @@ if (WITH_WINDOWS_UTF8_FILENAMES)
23+
add_definitions(-DROCKSDB_WINDOWS_UTF8_FILENAMES)
24+
endif()
25+
option(ROCKSDB_BUILD_SHARED "Build shared versions of the RocksDB libraries" ON)
26+
+option(ROCKSDB_BUILD_STATIC "Build static versions of the RocksDB libraries" ON)
27+
28+
if( NOT DEFINED CMAKE_CXX_STANDARD )
29+
set(CMAKE_CXX_STANDARD 17)
30+
@@ -1139,11 +1140,13 @@ string(REGEX REPLACE "[^0-9: /-]+" "" GIT_DATE "${GIT_DATE}")
31+
set(BUILD_VERSION_CC ${CMAKE_BINARY_DIR}/build_version.cc)
32+
configure_file(util/build_version.cc.in ${BUILD_VERSION_CC} @ONLY)
33+
34+
-add_library(${ROCKSDB_STATIC_LIB} STATIC ${SOURCES} ${BUILD_VERSION_CC})
35+
-target_include_directories(${ROCKSDB_STATIC_LIB} PUBLIC
36+
- $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
37+
-target_link_libraries(${ROCKSDB_STATIC_LIB} PRIVATE
38+
- ${THIRDPARTY_LIBS} ${SYSTEM_LIBS})
39+
+if(ROCKSDB_BUILD_STATIC)
40+
+ add_library(${ROCKSDB_STATIC_LIB} STATIC ${SOURCES} ${BUILD_VERSION_CC})
41+
+ target_include_directories(${ROCKSDB_STATIC_LIB} PUBLIC
42+
+ $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>)
43+
+ target_link_libraries(${ROCKSDB_STATIC_LIB} PRIVATE
44+
+ ${THIRDPARTY_LIBS} ${SYSTEM_LIBS})
45+
+endif()
46+
47+
if(ROCKSDB_BUILD_SHARED)
48+
add_library(${ROCKSDB_SHARED_LIB} SHARED ${SOURCES} ${BUILD_VERSION_CC})
49+
@@ -1238,13 +1241,15 @@ if(NOT WIN32 OR ROCKSDB_INSTALL_ON_WINDOWS)
50+
51+
install(DIRECTORY "${PROJECT_SOURCE_DIR}/cmake/modules" COMPONENT devel DESTINATION ${package_config_destination})
52+
53+
- install(
54+
- TARGETS ${ROCKSDB_STATIC_LIB}
55+
- EXPORT RocksDBTargets
56+
- COMPONENT devel
57+
- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
58+
- INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
59+
- )
60+
+ if(ROCKSDB_BUILD_STATIC)
61+
+ install(
62+
+ TARGETS ${ROCKSDB_STATIC_LIB}
63+
+ EXPORT RocksDBTargets
64+
+ COMPONENT devel
65+
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
66+
+ INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
67+
+ )
68+
+ endif()
69+
70+
if(ROCKSDB_BUILD_SHARED)
71+
install(

meta-oe/recipes-dbs/rocksdb/rocksdb_9.0.0.bb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ SRC_URI = "git://github.com/facebook/${BPN}.git;branch=${SRCBRANCH};protocol=htt
1717
file://0005-Implement-timer-implementation-for-mips-platform.patch \
1818
file://0006-Implement-timer-for-arm-v6.patch \
1919
file://0007-Fix-declaration-scope-of-LE_LOAD32-in-crc32c.patch \
20+
file://static_library_as_option.patch \
2021
"
2122

2223
SRC_URI:append:riscv32 = " file://0001-replace-old-sync-with-new-atomic-builtin-equivalents.patch"
@@ -43,6 +44,7 @@ EXTRA_OECMAKE = "\
4344
-DWITH_BENCHMARK_TOOLS=OFF \
4445
-DWITH_TOOLS=OFF \
4546
-DFAIL_ON_WARNINGS=OFF \
47+
-DROCKSDB_BUILD_STATIC=OFF \
4648
"
4749

4850
CXXFLAGS += "${@bb.utils.contains('SELECTED_OPTIMIZATION', '-Og', '-DXXH_NO_INLINE_HINTS', '', d)}"

0 commit comments

Comments
 (0)