Commit b62224e2 authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru

Mroonga cmake failure - LZ4_LIBS = NOTFOUND

The following variables are used in this project, but they are set to NOTFOUND.
LZ4_LIBS

The reason for the failure is that pkg_check_modules will not guarantee
<prefix>_LIBRARY_DIRS variable to be set, according to documentation.
When it's not set, we would force find_library to look in an empty path
and thus fail to correctly find LZ4_LIBS, although pck_check_modules
did previously discover that the library is installed.

To fix the problem and still keep the logic of first following
LIBLZ4_LIBRARY_DIRS and *then* look at other paths, we call find_library
twice. This is the recommended approach, according to CMake 3.11
documentation.
parent 1bc3899a
......@@ -361,10 +361,18 @@ if(NOT ${GRN_WITH_LZ4} STREQUAL "no")
pkg_check_modules(LIBLZ4 liblz4)
endif()
if(LIBLZ4_FOUND)
# According to CMake documentation, this is the recommended way to force
# looking in LIBRARY_DIRS first and in regular system paths otherwise.
#
# pkg_check_modules does not guarantee that LIBLZ4_LIBRARY_DIRS will be
# set. If it's not set we won't find the library without looking through
# the regular system paths.
find_library(LZ4_LIBS
NAMES ${LIBLZ4_LIBRARIES}
PATHS ${LIBLZ4_LIBRARY_DIRS}
NO_DEFAULT_PATH)
NAMES ${LIBLZ4_LIBRARIES}
PATHS ${LIBLZ4_LIBRARY_DIRS}
NO_DEFAULT_PATH)
find_library(LZ4_LIBS
NAMES ${LIBLZ4_LIBRARIES})
set(GRN_WITH_LZ4 TRUE)
else()
if(${GRN_WITH_LZ4} STREQUAL "yes")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment