Skip to content

Commit

Permalink
Add FindLZ4 module
Browse files Browse the repository at this point in the history
Summary:
Add a CMake find_package script for LZ4

simpkins
Closes #778

Reviewed By: simpkins

Differential Revision: D7064988

Pulled By: yfeldblum

fbshipit-source-id: 60596ead4b4fd38474dab4c33d4c3fbb0f37549c
  • Loading branch information
JoeLoser authored and facebook-github-bot committed Feb 23, 2018
1 parent 8aa1a41 commit 7dc5a4e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
22 changes: 22 additions & 0 deletions CMake/FindLZ4.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Finds liblz4.
#
# This module defines:
# LZ4_FOUND
# LZ4_INCLUDE_DIR
# LZ4_LIBRARY
#

find_path(LZ4_INCLUDE_DIR NAMES lz4.h)
find_library(LZ4_LIBRARY NAMES lz4)

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
LZ4 DEFAULT_MSG
LZ4_LIBRARY LZ4_INCLUDE_DIR
)

if (LZ4_FOUND)
message(STATUS "Found LZ4: ${LZ4_LIBRARY}")
endif()

mark_as_advanced(LZ4_INCLUDE_DIR LZ4_LIBRARY)
11 changes: 7 additions & 4 deletions CMake/folly-deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ if (LIBLZMA_FOUND)
list(APPEND FOLLY_LINK_LIBRARIES ${LIBLZMA_LIBRARIES})
endif()

find_package(lz4 MODULE)
set(FOLLY_HAVE_LIBLZ4 ${LZ4_FOUND})
if (LZ4_FOUND)
list(APPEND FOLLY_INCLUDE_DIRECTORIES ${LZ4_INCLUDE_DIR})
list(APPEND FOLLY_LINK_LIBRARIES ${LZ4_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)
Expand All @@ -108,10 +115,6 @@ CHECK_INCLUDE_FILE_CXX(snappy.h FOLLY_HAVE_LIBSNAPPY)
if (FOLLY_HAVE_LIBSNAPPY)
list(APPEND FOLLY_LINK_LIBRARIES snappy)
endif()
CHECK_INCLUDE_FILE_CXX(lz4.h FOLLY_HAVE_LIBLZ4)
if (FOLLY_HAVE_LIBLZ4)
list(APPEND FOLLY_LINK_LIBRARIES lz4)
endif()

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

0 comments on commit 7dc5a4e

Please sign in to comment.