| Message ID | 20260210133500.30649-1-zahir.basha@kpit.com |
|---|---|
| State | New |
| Headers | show |
| Series | [meta-oe,kirkstone] rocksdb: Add an option to set static library | expand |
On 2/10/26 14:35, aszh07 via lists.openembedded.org wrote: > Modify the CMakeLists.txt to add an Option for > STATIC target import, as available for shared library. > > Link: https://github.com/facebook/rocksdb/pull/12890 > > Configure static library default to switched off > as shared libraries are sufficient in most cases. > > Signed-off-by: Bhabu Bindu <bindu.bhabu@kpit.com> > Signed-off-by: Khem Raj <raj.khem@gmail.com> > (cherry picked from commit 233079a41caded6b68972317f01dc09435ba1ae0) > Signed-off-by: Armin Kuster <akuster808@gmail.com> > (cherry picked from commit 72018ca1b1a471226917e8246e8bbf9a374ccf97) > Signed-off-by: Zahir Hussain <zahir.basha@kpit.com> > --- > .../files/static_library_as_option.patch | 72 +++++++++++++++++++ > meta-oe/recipes-dbs/rocksdb/rocksdb_6.20.3.bb | 2 + > 2 files changed, 74 insertions(+) > create mode 100644 meta-oe/recipes-dbs/rocksdb/files/static_library_as_option.patch > > diff --git a/meta-oe/recipes-dbs/rocksdb/files/static_library_as_option.patch b/meta-oe/recipes-dbs/rocksdb/files/static_library_as_option.patch > new file mode 100644 > index 0000000000..09b30681f8 > --- /dev/null > +++ b/meta-oe/recipes-dbs/rocksdb/files/static_library_as_option.patch > @@ -0,0 +1,72 @@ > +From 285d306494bde3e9c24c8cd6fea1eb380a304d03 Mon Sep 17 00:00:00 2001 > +From: Bindu-Bhabu <bindudaniel1996@gmail.com> > +Date: Fri, 26 Jul 2024 15:14:45 +0530 > +Subject: Add option to CMake for building static libraries > + > +ROCKSDB creates a STATIC library target reference by default. > +Modify the cmake so that the STATIC library is also an option > +just like creating a SHARED library and set default to ON. > +refersh the patch according to kirkstone version. > + > +Upstream-Status: Submitted [https://github.com/facebook/rocksdb/pull/12890] > + > +Signed-off-by: Nisha Parrakat <nisha.m.parrakat@bmw.de> > +Signed-off-by: Bindu Bhabu <bhabu.bindu@kpit.com> > +Signed-off-by: Zahir Hussain <zahir.basha@kpit.com> > +--- > + CMakeLists.txt | 25 +++++++++++++++---------- > + 1 file changed, 15 insertions(+), 10 deletions(-) > + > +diff --git a/CMakeLists.txt b/CMakeLists.txt > +index b68a82b..6f0de6f 100644 > +--- a/CMakeLists.txt > ++++ b/CMakeLists.txt > +@@ -919,6 +919,7 @@ set(ROCKSDB_STATIC_LIB rocksdb${ARTIFACT_SUFFIX}) > + set(ROCKSDB_SHARED_LIB rocksdb-shared${ARTIFACT_SUFFIX}) > + > + option(ROCKSDB_BUILD_SHARED "Build shared versions of the RocksDB libraries" ON) > ++option(ROCKSDB_BUILD_STATIC "Build static versions of the RocksDB libraries" ON) > + > + option(WITH_LIBRADOS "Build with librados" OFF) > + if(WITH_LIBRADOS) > +@@ -938,9 +939,11 @@ else() > + endif() > + endif() > + > +-add_library(${ROCKSDB_STATIC_LIB} STATIC ${SOURCES} ${BUILD_VERSION_CC}) > +-target_link_libraries(${ROCKSDB_STATIC_LIB} PRIVATE > +- ${THIRDPARTY_LIBS} ${SYSTEM_LIBS}) > ++if(ROCKSDB_BUILD_STATIC) > ++ add_library(${ROCKSDB_STATIC_LIB} STATIC ${SOURCES} ${BUILD_VERSION_CC}) > ++ target_link_libraries(${ROCKSDB_STATIC_LIB} PRIVATE > ++ ${THIRDPARTY_LIBS} ${SYSTEM_LIBS}) > ++endif() > + > + if(ROCKSDB_BUILD_SHARED) > + add_library(${ROCKSDB_SHARED_LIB} SHARED ${SOURCES} ${BUILD_VERSION_CC}) > +@@ -1021,13 +1024,15 @@ if(NOT WIN32 OR ROCKSDB_INSTALL_ON_WINDOWS) > + > + install(DIRECTORY "${PROJECT_SOURCE_DIR}/cmake/modules" COMPONENT devel DESTINATION ${package_config_destination}) > + > +- install( > +- TARGETS ${ROCKSDB_STATIC_LIB} > +- EXPORT RocksDBTargets > +- COMPONENT devel > +- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" > +- INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" > +- ) > ++ if(ROCKSDB_BUILD_STATIC) > ++ install( > ++ TARGETS ${ROCKSDB_STATIC_LIB} > ++ EXPORT RocksDBTargets > ++ COMPONENT devel > ++ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" > ++ INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" > ++ ) > ++ endif() > + > + if(ROCKSDB_BUILD_SHARED) > + install( > +-- > +2.34.1 > + > diff --git a/meta-oe/recipes-dbs/rocksdb/rocksdb_6.20.3.bb b/meta-oe/recipes-dbs/rocksdb/rocksdb_6.20.3.bb > index 8164f856e2..9cdc2edf30 100644 > --- a/meta-oe/recipes-dbs/rocksdb/rocksdb_6.20.3.bb > +++ b/meta-oe/recipes-dbs/rocksdb/rocksdb_6.20.3.bb > @@ -19,6 +19,7 @@ SRC_URI = "git://github.com/facebook/${BPN}.git;branch=${SRCBRANCH};protocol=htt > file://mips.patch \ > file://arm.patch \ > file://run-ptest \ > + file://static_library_as_option.patch \ > " > > SRC_URI:append:riscv32 = " file://0001-replace-old-sync-with-new-atomic-builtin-equivalents.patch" > @@ -45,6 +46,7 @@ EXTRA_OECMAKE = "\ > -DWITH_BENCHMARK_TOOLS=OFF \ > -DWITH_TOOLS=OFF \ > -DFAIL_ON_WARNINGS=OFF \ > + -DROCKSDB_BUILD_STATIC=OFF \ > " At this point in the Kirkstone lifecycle I'm not sure if defaults should be changed. In general I have no problem with the idea, but could this made a PACKAGECONFIG that's enabled by default (to match the current behavior of the recipe)? > > do_install:append() { > > -=-=-=-=-=-=-=-=-=-=-=- > Links: You receive all messages sent to this group. > View/Reply Online (#124320): https://lists.openembedded.org/g/openembedded-devel/message/124320 > Mute This Topic: https://lists.openembedded.org/mt/117737559/6084445 > Group Owner: openembedded-devel+owner@lists.openembedded.org > Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [skandigraun@gmail.com] > -=-=-=-=-=-=-=-=-=-=-=- >
diff --git a/meta-oe/recipes-dbs/rocksdb/files/static_library_as_option.patch b/meta-oe/recipes-dbs/rocksdb/files/static_library_as_option.patch new file mode 100644 index 0000000000..09b30681f8 --- /dev/null +++ b/meta-oe/recipes-dbs/rocksdb/files/static_library_as_option.patch @@ -0,0 +1,72 @@ +From 285d306494bde3e9c24c8cd6fea1eb380a304d03 Mon Sep 17 00:00:00 2001 +From: Bindu-Bhabu <bindudaniel1996@gmail.com> +Date: Fri, 26 Jul 2024 15:14:45 +0530 +Subject: Add option to CMake for building static libraries + +ROCKSDB creates a STATIC library target reference by default. +Modify the cmake so that the STATIC library is also an option +just like creating a SHARED library and set default to ON. +refersh the patch according to kirkstone version. + +Upstream-Status: Submitted [https://github.com/facebook/rocksdb/pull/12890] + +Signed-off-by: Nisha Parrakat <nisha.m.parrakat@bmw.de> +Signed-off-by: Bindu Bhabu <bhabu.bindu@kpit.com> +Signed-off-by: Zahir Hussain <zahir.basha@kpit.com> +--- + CMakeLists.txt | 25 +++++++++++++++---------- + 1 file changed, 15 insertions(+), 10 deletions(-) + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b68a82b..6f0de6f 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -919,6 +919,7 @@ set(ROCKSDB_STATIC_LIB rocksdb${ARTIFACT_SUFFIX}) + set(ROCKSDB_SHARED_LIB rocksdb-shared${ARTIFACT_SUFFIX}) + + option(ROCKSDB_BUILD_SHARED "Build shared versions of the RocksDB libraries" ON) ++option(ROCKSDB_BUILD_STATIC "Build static versions of the RocksDB libraries" ON) + + option(WITH_LIBRADOS "Build with librados" OFF) + if(WITH_LIBRADOS) +@@ -938,9 +939,11 @@ else() + endif() + endif() + +-add_library(${ROCKSDB_STATIC_LIB} STATIC ${SOURCES} ${BUILD_VERSION_CC}) +-target_link_libraries(${ROCKSDB_STATIC_LIB} PRIVATE +- ${THIRDPARTY_LIBS} ${SYSTEM_LIBS}) ++if(ROCKSDB_BUILD_STATIC) ++ add_library(${ROCKSDB_STATIC_LIB} STATIC ${SOURCES} ${BUILD_VERSION_CC}) ++ target_link_libraries(${ROCKSDB_STATIC_LIB} PRIVATE ++ ${THIRDPARTY_LIBS} ${SYSTEM_LIBS}) ++endif() + + if(ROCKSDB_BUILD_SHARED) + add_library(${ROCKSDB_SHARED_LIB} SHARED ${SOURCES} ${BUILD_VERSION_CC}) +@@ -1021,13 +1024,15 @@ if(NOT WIN32 OR ROCKSDB_INSTALL_ON_WINDOWS) + + install(DIRECTORY "${PROJECT_SOURCE_DIR}/cmake/modules" COMPONENT devel DESTINATION ${package_config_destination}) + +- install( +- TARGETS ${ROCKSDB_STATIC_LIB} +- EXPORT RocksDBTargets +- COMPONENT devel +- ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" +- INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" +- ) ++ if(ROCKSDB_BUILD_STATIC) ++ install( ++ TARGETS ${ROCKSDB_STATIC_LIB} ++ EXPORT RocksDBTargets ++ COMPONENT devel ++ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" ++ INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ++ ) ++ endif() + + if(ROCKSDB_BUILD_SHARED) + install( +-- +2.34.1 + diff --git a/meta-oe/recipes-dbs/rocksdb/rocksdb_6.20.3.bb b/meta-oe/recipes-dbs/rocksdb/rocksdb_6.20.3.bb index 8164f856e2..9cdc2edf30 100644 --- a/meta-oe/recipes-dbs/rocksdb/rocksdb_6.20.3.bb +++ b/meta-oe/recipes-dbs/rocksdb/rocksdb_6.20.3.bb @@ -19,6 +19,7 @@ SRC_URI = "git://github.com/facebook/${BPN}.git;branch=${SRCBRANCH};protocol=htt file://mips.patch \ file://arm.patch \ file://run-ptest \ + file://static_library_as_option.patch \ " SRC_URI:append:riscv32 = " file://0001-replace-old-sync-with-new-atomic-builtin-equivalents.patch" @@ -45,6 +46,7 @@ EXTRA_OECMAKE = "\ -DWITH_BENCHMARK_TOOLS=OFF \ -DWITH_TOOLS=OFF \ -DFAIL_ON_WARNINGS=OFF \ + -DROCKSDB_BUILD_STATIC=OFF \ " do_install:append() {