]> git.proxmox.com Git - ceph.git/blob - ceph/src/zstd/build/cmake/CMakeModules/FindLibLZ4.cmake
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / zstd / build / cmake / CMakeModules / FindLibLZ4.cmake
1 # Find LibLZ4
2 #
3 # Find LibLZ4 headers and library
4 #
5 # Result Variables
6 #
7 # LIBLZ4_FOUND - True if lz4 is found
8 # LIBLZ4_INCLUDE_DIRS - lz4 headers directories
9 # LIBLZ4_LIBRARIES - lz4 libraries
10 # LIBLZ4_VERSION_MAJOR - The major version of lz4
11 # LIBLZ4_VERSION_MINOR - The minor version of lz4
12 # LIBLZ4_VERSION_RELEASE - The release version of lz4
13 # LIBLZ4_VERSION_STRING - version number string (e.g. 1.8.3)
14 #
15 # Hints
16 #
17 # Set ``LZ4_ROOT_DIR`` to the directory of lz4.h and lz4 library
18
19 set(_LIBLZ4_ROOT_HINTS
20 ENV LZ4_ROOT_DIR)
21
22 find_path( LIBLZ4_INCLUDE_DIR lz4.h
23 HINTS ${_LIBLZ4_ROOT_HINTS})
24 find_library( LIBLZ4_LIBRARY NAMES lz4 liblz4 liblz4_static
25 HINTS ${_LIBLZ4_ROOT_HINTS})
26
27 if(LIBLZ4_INCLUDE_DIR)
28 file(STRINGS "${LIBLZ4_INCLUDE_DIR}/lz4.h" LIBLZ4_HEADER_CONTENT REGEX "#define LZ4_VERSION_[A-Z]+ +[0-9]+")
29
30 string(REGEX REPLACE ".*#define LZ4_VERSION_MAJOR +([0-9]+).*" "\\1" LIBLZ4_VERSION_MAJOR "${LIBLZ4_HEADER_CONTENT}")
31 string(REGEX REPLACE ".*#define LZ4_VERSION_MINOR +([0-9]+).*" "\\1" LIBLZ4_VERSION_MINOR "${LIBLZ4_HEADER_CONTENT}")
32 string(REGEX REPLACE ".*#define LZ4_VERSION_RELEASE +([0-9]+).*" "\\1" LIBLZ4_VERSION_RELEASE "${LIBLZ4_HEADER_CONTENT}")
33
34 set(LIBLZ4_VERSION_STRING "${LIBLZ4_VERSION_MAJOR}.${LIBLZ4_VERSION_MINOR}.${LIBLZ4_VERSION_RELEASE}")
35 unset(LIBLZ4_HEADER_CONTENT)
36 endif()
37
38 include(FindPackageHandleStandardArgs)
39 FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibLZ4 REQUIRED_VARS LIBLZ4_INCLUDE_DIR
40 LIBLZ4_LIBRARY
41 VERSION_VAR LIBLZ4_VERSION_STRING
42 FAIL_MESSAGE "Could NOT find LZ4, try to set the paths to lz4.h and lz4 library in environment variable LZ4_ROOT_DIR")
43
44 if (LIBLZ4_FOUND)
45 set(LIBLZ4_LIBRARIES ${LIBLZ4_LIBRARY})
46 set(LIBLZ4_INCLUDE_DIRS ${LIBLZ4_INCLUDE_DIR})
47 endif ()
48
49 mark_as_advanced( LIBLZ4_INCLUDE_DIR LIBLZ4_LIBRARY )