CMake package-config doesn't work.

Description:

The CMake package-config refers to static-library files, and causes an error. Try importing this in in a cmake-project with find_package(RocksDB REQUIRED). I would suggest to build this package with cmake, and patch the cml to not install the static library, so that we avoid that it end up in the cmake-package-config:

From 56c7bc52a9e070f7c6dd7747b4f3957aa5a1d845 Mon Sep 17 00:00:00 2001
From: John Eivind Helset <private@jehelset.no>
Date: Thu, 7 Mar 2024 21:19:41 +0100
Subject: [PATCH] Use cmake to build rocksdb.

This ensures that a cmake-package-config will also be installed.

Configure cmake to match the old makefile based build.

Adds a patch to remove the installation of the static lib, as this
will break the cmake-config.
---
 PKGBUILD                      | 14 ++++++++++----
 dont-install-static-lib.patch | 30 ++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+), 4 deletions(-)
 create mode 100644 dont-install-static-lib.patch

diff --git a/PKGBUILD b/PKGBUILD
index 6f87252..2d747a0 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -9,21 +9,27 @@ arch=(x86_64)
 url="https://rocksdb.org/"
 license=(GPL2 Apache)
 depends=(bzip2 lz4 snappy zlib zstd tbb liburing)
-makedepends=(python)
+makedepends=(cmake python)
 source=(rocksdb-$pkgver.tar.gz::https://github.com/facebook/rocksdb/archive/v$pkgver.tar.gz)
 sha256sums=('3b51d1d907ea13fab430bf052618610994f08cd8ed0b1341c3e89fe02e199f8e')
 
+prepare() {
+  cd rocksdb-$pkgver
+  patch --forward --strip=1 --input=../../dont-install-static-lib.patch
+}
+
 build() {
   cd rocksdb-$pkgver
-  DISABLE_JEMALLOC=1 PORTABLE=1 USE_RTTI=1 make shared_lib
+  cmake -B build -DCMAKE_INSTALL_PREFIX=/usr -DPORTABLE=ON -DUSE_RTTI=ON -DROCKSDB_BUILD_SHARED=ON -DWITH_LIBURING=ON -DWITH_ZLIB=ON -DWITH_ZSDT=ON -DWITH_LZ4=ON -DWITH_BZ2=ON -DROCKSDB_WITH_COVERAGE=OFF -DCMAKE_CXX_VERSION=20 -DPORTABLE="x86-64" -DWITH_TBB=ON -DFAIL_ON_WARNINGS=OFF
+  cmake --build build
 }
 
 check() {
   cd rocksdb-$pkgver
-  # make check # fails due to https://github.com/facebook/rocksdb/issues/8974
+  ctest --test-dir build
 }
 
 package() {
   cd rocksdb-$pkgver
-  make install-shared DESTDIR="$pkgdir" PREFIX=/usr
+  cmake --install build --prefix $pkgdir/usr
 }
diff --git a/dont-install-static-lib.patch b/dont-install-static-lib.patch
new file mode 100644
index 0000000..e3a759f
--- /dev/null
+++ b/dont-install-static-lib.patch
@@ -0,0 +1,30 @@
+From faf5f23ecc0db32470f27b2f3b27af73e8f8fdbe Mon Sep 17 00:00:00 2001
+From: John Eivind Helset <private@jehelset.no>
+Date: Thu, 7 Mar 2024 21:28:50 +0100
+Subject: [PATCH] Dont install static lib.
+
+---
+ CMakeLists.txt | 8 --------
+ 1 file changed, 8 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index d04356f0a..026c4ee0c 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -1199,14 +1199,6 @@ 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_SHARED)
+     install(
+       TARGETS ${ROCKSDB_SHARED_LIB}
+-- 
+2.44.0
-- 
2.44.0

Created issue upstream here: https://github.com/facebook/rocksdb/issues/12450