Skip to content

Commit

Permalink
[CMake] Add find module for Snappy
Browse files Browse the repository at this point in the history
Add a find_package module for Snappy
  • Loading branch information
JoeLoser committed Feb 28, 2018
1 parent 974e6be commit c505581
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
17 changes: 17 additions & 0 deletions CMake/FindSnappy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Find the Snappy libraries
#
# This module defines:
# SNAPPY_FOUND
# SNAPPY_INCLUDE_DIR
# SNAPPY_LIBRARY

find_path(SNAPPY_INCLUDE_DIR NAMES snappy.h)
find_library(SNAPPY_LIBRARY NAMES snappy)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
SNAPPY DEFAULT_MSG
SNAPPY_LIBRARY SNAPPY_INCLUDE_DIR
)

mark_as_advanced(SNAPPY_INCLUDE_DIR SNAPPY_LIBRARY)
11 changes: 7 additions & 4 deletions CMake/folly-deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,19 @@ if (LZ4_FOUND)
list(APPEND FOLLY_LINK_LIBRARIES ${LZ4_LIBRARY})
endif()

find_package(Snappy MODULE)
set(FOLLY_HAVE_LIBSNAPPY ${SNAPPY_FOUND})
if (SNAPPY_FOUND)
list(APPEND FOLLY_INCLUDE_DIRECTORIES ${SNAPPY_INCLUDE_DIR})
list(APPEND FOLLY_LINK_LIBRARIES ${SNAPPY_LIBRARY})
endif()

# TODO: We should ideally build FindXXX modules for the following libraries,
# rather than the simple checks we currently have here.
CHECK_INCLUDE_FILE_CXX(zstd.h FOLLY_HAVE_LIBZSTD)
if (FOLLY_HAVE_LIBZSTD)
list(APPEND FOLLY_LINK_LIBRARIES zstd)
endif()
CHECK_INCLUDE_FILE_CXX(snappy.h FOLLY_HAVE_LIBSNAPPY)
if (FOLLY_HAVE_LIBSNAPPY)
list(APPEND FOLLY_LINK_LIBRARIES snappy)
endif()

find_package(LibDwarf)
list(APPEND FOLLY_LINK_LIBRARIES ${LIBDWARF_LIBRARIES})
Expand Down

0 comments on commit c505581

Please sign in to comment.