endif()
if(WITH_SNAPPY)
+ option(WITH_SNAPPY_STATIC_LIB "build with libsnappy.a" OFF)
+ set(SNAPPY_USE_STATIC_LIB ${WITH_SNAPPY_STATIC_LIB})
find_package(snappy REQUIRED)
add_definitions(-DSNAPPY)
include_directories(${SNAPPY_INCLUDE_DIR})
# 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)
+
+if(SNAPPY_USE_STATIC_LIB)
+ set(_snappy_orig_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
+endif()
find_library(SNAPPY_LIBRARIES
NAMES snappy
- HINTS ${SNAPPY_ROOT_DIR}/lib)
+ HINTS
+ ${PC_snappy_LIBRARY_DIRS}
+ ${SNAPPY_ROOT_DIR}/lib)
+if(SNAPPY_USE_STATIC_LIB)
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ${_snappy_orig_FIND_LIBRARY_SUFFIXES})
+endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(snappy DEFAULT_MSG SNAPPY_LIBRARIES SNAPPY_INCLUDE_DIR)