From 3ded44dc2daf6bd3718fd80b8a07eef8c60d87e7 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Wed, 6 Jan 2016 19:37:49 +0800 Subject: [PATCH] cmake: detect bzip2 and lz4 for rocksdb * this change is the cmake port of 911e7a0. the rocksdb's Makefile will detect the installed libbz2 and libz4 by its own. if the building env happens to have these libraries installed, a link time dependency is introduced. so we are forced to link against them. * do not REQUIRE BZip2 in cmake anymore * only link against bzip2 if it is detected Signed-off-by: Kefu Chai --- CMakeLists.txt | 3 +-- src/kv/CMakeLists.txt | 12 +++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fac554032412..7b267745c666 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -243,9 +243,8 @@ endif(WITH_REENTRANT_STRSIGNAL) set(HAVE_LIBROCKSDB 1) -# -lbz2 and -lz link into kv +# -lz link into kv find_package(ZLIB REQUIRED) -find_package(BZip2 REQUIRED) #option for LTTng option(WITH_LTTNG "LTTng tracing is enabled" ON) diff --git a/src/kv/CMakeLists.txt b/src/kv/CMakeLists.txt index 3c088991a083..27773629add8 100644 --- a/src/kv/CMakeLists.txt +++ b/src/kv/CMakeLists.txt @@ -6,4 +6,14 @@ add_library(kv_objs OBJECT ${kv_srcs}) add_library(kv STATIC $) target_include_directories(kv_objs PUBLIC ${ROCKSDB_INCLUDE_DIR}) target_include_directories(kv PUBLIC ${ROCKSDB_INCLUDE_DIR}) -target_link_libraries(kv bz2 z leveldb snappy rocksdb) +target_link_libraries(kv z leveldb snappy rocksdb) + +# rocksdb detects bzlib and lz4 in its Makefile, which forces us to do the same. +find_package(BZip2 QUIET) +if (BZIP2_FOUND) + target_link_libraries(kv ${BZIP2_LIBRARIES}) +endif (BZIP2_FOUND) +find_package(LZ4 QUIET) +if (LZ4_FOUND) + target_link_libraries(kv ${LZ4_LIBRARY}) +endif (LZ4_FOUND) -- 2.47.3