--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -370,6 +370,8 @@
 ProcessPackage(GLIB2 LIBRARY glib-2.0 INCLUDE glib.h
 	INCLUDE_SUFFIXES include/glib
 	ROOT ${GLIB_ROOT_DIR} MODULES glib-2.0>=2.28)
+ProcessPackage(LIBHIREDIS LIBRARY hiredis INCLUDE hiredis.h INCLUDE_SUFFIXES include/hiredis
+	LIB_SUFFIXES lib/libhiredis ROOT ${LIBHIREDIS_ROOT_DIR} MODULES libhiredis)
 
 IF(ENABLE_DKIM MATCHES "ON")
 	SET(WITH_DKIM 1)
@@ -388,8 +390,6 @@
 ENDIF()
 
 ################################ SOURCES SECTION ###########################
-ADD_SUBDIRECTORY(hiredis)
-INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/hiredis")
 INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/contrib/lc-btrie")
 INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/")
 ADD_SUBDIRECTORY(contrib/libucl)
@@ -421,7 +421,6 @@
 ADD_EXECUTABLE(rmilter ${RMILTERSRC})
 SET_TARGET_PROPERTIES(rmilter PROPERTIES LINKER_LANGUAGE C)
 TARGET_LINK_LIBRARIES(rmilter ${RMILTER_REQUIRED_LIBRARIES})
-TARGET_LINK_LIBRARIES(rmilter rmilter-hiredis)
 TARGET_LINK_LIBRARIES(rmilter ucl)
 TARGET_LINK_LIBRARIES(rmilter xxhash)
 TARGET_LINK_LIBRARIES(rmilter rmilter-http-parser)
