From a61493062c04c2a0891d975187285796480e9131 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Mon, 23 Jul 2018 19:55:05 +0800 Subject: cmake: link against libsnappy.a if WITH_STATIC_LIBSTDCXX Signed-off-by: Kefu Chai --- cmake/modules/BuildRocksDB.cmake | 5 +++++ cmake/modules/Findsnappy.cmake | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'cmake') diff --git a/cmake/modules/BuildRocksDB.cmake b/cmake/modules/BuildRocksDB.cmake index bc0b3d16f62..f3e0c5b2ee1 100644 --- a/cmake/modules/BuildRocksDB.cmake +++ b/cmake/modules/BuildRocksDB.cmake @@ -13,7 +13,12 @@ function(do_build_rocksdb) list(APPEND ROCKSDB_CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}) endif() + # libsnappy is a C++ library, we need to force rocksdb to link against + # libsnappy statically. list(APPEND ROCKSDB_CMAKE_ARGS -DWITH_SNAPPY=${SNAPPY_FOUND}) + if(SNAPPY_FOUND AND WITH_STATIC_LIBSTDCXX) + list(APPEND ROCKSDB_CMAKE_ARGS -DWITH_SNAPPY_STATIC_LIB=ON) + endif() list(APPEND ROCKSDB_CMAKE_ARGS -DWITH_LZ4=${LZ4_FOUND}) list(APPEND ROCKSDB_CMAKE_ARGS -DWITH_ZLIB=${ZLIB_FOUND}) list(APPEND ROCKSDB_CMAKE_ARGS -DPORTABLE=ON) diff --git a/cmake/modules/Findsnappy.cmake b/cmake/modules/Findsnappy.cmake index 6ed5fda3d57..644eef33bc0 100644 --- a/cmake/modules/Findsnappy.cmake +++ b/cmake/modules/Findsnappy.cmake @@ -5,13 +5,21 @@ # SNAPPY_LIBRARIES - List of libraries when using snappy. # SNAPPY_FOUND - True if snappy found. +find_package(PkgConfig) +pkg_search_module(PC_snappy + QUIET snappy) + find_path(SNAPPY_INCLUDE_DIR NAMES snappy.h - HINTS ${SNAPPY_ROOT_DIR}/include) + HINTS + ${PC_snappy_INCLUDE_DIRS} + ${SNAPPY_ROOT_DIR}/include) find_library(SNAPPY_LIBRARIES NAMES snappy - HINTS ${SNAPPY_ROOT_DIR}/lib) + HINTS + ${PC_snappy_LIBRARY_DIRS} + ${SNAPPY_ROOT_DIR}/lib) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(snappy DEFAULT_MSG SNAPPY_LIBRARIES SNAPPY_INCLUDE_DIR) -- cgit v1.2.3