Say how to build against a rocksdb of one's own
Rocky Linux and RHEL package rocksdb 6, which does not match the library
collocatordb is built against, so it has to be built by hand there. Both
the header of collocatordb and the two libraries are looked up in
CMAKE_PREFIX_PATH now, so one prefix covers everything, and the header of
an older collocatordb below /usr/local cannot shadow it.
The README says that, corrects the path of the static rocksdb, which is
in lib64 on the RHEL family, and explains what to do when the loader does
not find libcollocatordb.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Change-Id: I176a1f51d6c26447578a158107d34d2d87083d88
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4076589..f391940 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,11 +55,25 @@
endif ()
if (NOT ROCKSDB)
message(FATAL_ERROR "No rocksdb found. Install the rocksdb development "
- "package of your distribution, e.g. librocksdb-dev or rocksdb-devel.")
+ "package of your distribution, e.g. librocksdb-dev or "
+ "rocksdb-devel. Where there is none, or where it is older than the "
+ "one collocatordb was built against, build rocksdb and say where "
+ "it is: -DCMAKE_PREFIX_PATH=<prefix it was installed to>. It has "
+ "to be the same rocksdb that collocatordb was built against.")
endif ()
message(STATUS "Using collocatordb ${COLLOCATORDB}")
message(STATUS "Using RocksDB ${ROCKSDB}")
+# collocatordb.h has to belong to that library. Looked up rather than assumed,
+# so that CMAKE_PREFIX_PATH works for a collocatordb in a prefix of its own,
+# and put before the rest, so that an older one below /usr/local cannot shadow
+# it - the compiler looks into /usr/local/include before /usr/include.
+find_path(COLLOCATORDB_INCLUDE_DIR collocatordb.h)
+if (COLLOCATORDB_INCLUDE_DIR)
+ include_directories(BEFORE ${COLLOCATORDB_INCLUDE_DIR})
+ message(STATUS "Using collocatordb header in ${COLLOCATORDB_INCLUDE_DIR}")
+endif ()
+
file(GLOB APP_SOURCES ${CMAKE_SOURCE_DIR}/src/*.c)
foreach (mysourcefile ${APP_SOURCES})
# I used a simple string replace, to cut off .cpp.