Commit d62d5574 authored by Ghislain MARY's avatar Ghislain MARY

Rework search for hiredis library.

parent 934b8d84
......@@ -156,23 +156,9 @@ if(ENABLE_DATEHANDLER)
endif()
if(ENABLE_REDIS)
find_path(HIREDIS_INCLUDE_DIRS NAMES hiredis/hiredis.h)
find_library(HIREDIS_LIBRARIES NAMES hiredis)
if(NOT HIREDIS_INCLUDE_DIRS)
message(FATAL_ERROR "hiredis headers not found")
endif()
if(NOT HIREDIS_LIBRARIES)
message(FATAL_ERROR "hiredis library not found")
endif()
# check that the async mode is supported
cmake_push_check_state(RESET)
list(APPEND CMAKE_REQUIRED_INCLUDES ${HIREDIS_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${HIREDIS_LIBRARIES})
check_symbol_exists("redisAsyncCommand" "hiredis/async.h" HIREDIS_ASYNC_ENABLED)
cmake_pop_check_state()
find_package(Hiredis REQUIRED)
if(NOT HIREDIS_ASYNC_ENABLED)
message(FATAL_ERROR "Hiredis needs support for Async commands.")
message(FATAL_ERROR "Hiredis needs support for async commands")
endif()
endif()
......
############################################################################
# FindHiredis.cmake
# Copyright (C) 2017 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
#
# - Find the libhiredis library
#
# HIREDIS_FOUND - system has libhiredis
# HIREDIS_INCLUDE_DIRS - the libhiredis include directory
# HIREDIS_LIBRARIES - The libraries needed to use libhiredis
# HIREDIS_ASYNC_ENABLED - The found libhiredis library supports async commands
find_path(HIREDIS_INCLUDE_DIRS
NAMES hiredis/hiredis.h
PATH_SUFFIXES include
)
find_library(HIREDIS_LIBRARIES
NAMES hiredis
)
if(HIREDIS_INCLUDE_DIRS AND HIREDIS_LIBRARIES)
# check that the async mode is supported
cmake_push_check_state(RESET)
list(APPEND CMAKE_REQUIRED_INCLUDES ${HIREDIS_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${HIREDIS_LIBRARIES})
check_symbol_exists("redisAsyncCommand" "hiredis/async.h" HIREDIS_ASYNC_ENABLED)
cmake_pop_check_state()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Hiredis
DEFAULT_MSG
HIREDIS_INCLUDE_DIRS HIREDIS_LIBRARIES
)
mark_as_advanced(HIREDIS_INCLUDE_DIRS HIREDIS_LIBRARIES HIREDIS_ASYNC_ENABLED)
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