Skip to content

Commit 60d565e

Browse files
committed
cmake: detect lz4 version, require >= 1.6
1 parent 182bf9b commit 60d565e

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

cmake/FindLZ4.cmake

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
find_path(LZ4_INCLUDE_DIRS NAMES lz4.h)
22
find_library(LZ4_LIBRARIES NAMES lz4)
33

4+
if(LZ4_INCLUDE_DIRS AND EXISTS "${LZ4_INCLUDE_DIRS}/lz4.h")
5+
file(STRINGS "${LZ4_INCLUDE_DIRS}/lz4.h" LZ4_H REGEX "^#define LZ4_VERSION_[MR]")
6+
string(REGEX REPLACE "LZ4_VERSION" "" LZ4_H "${LZ4_H}")
7+
string(REGEX MATCHALL "[0-9]+" LZ4_H "${LZ4_H}")
8+
string(REGEX REPLACE ";" "." LZ4_VERSION_STRING "${LZ4_H}")
9+
endif()
10+
411
include(FindPackageHandleStandardArgs)
512
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
6-
LZ4 DEFAULT_MSG
7-
LZ4_LIBRARIES LZ4_INCLUDE_DIRS)
13+
LZ4
14+
REQUIRED_VARS LZ4_LIBRARIES LZ4_INCLUDE_DIRS
15+
VERSION_VAR LZ4_VERSION_STRING)
816

917
mark_as_advanced(LZ4_INCLUDE_DIRS LZ4_LIBRARIES)

plugin/provider_lz4/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FIND_PACKAGE(LZ4)
1+
FIND_PACKAGE(LZ4 1.6)
22

33
IF (LZ4_FOUND)
44
GET_PROPERTY(dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES)

0 commit comments

Comments
 (0)