0

我的内容Findhiredis.cmake

# Try to find hiredis
# Once done, this will define
#
# HIREDIS_FOUND        - system has hiredis
# HIREDIS_INCLUDE_DIRS - hiredis include directories
# HIREDIS_LIBRARIES    - libraries need to use hiredis

if(HIREDIS_INCLUDE_DIRS AND HIREDIS_LIBRARIES)
  set(HIREDIS_FIND_QUIETLY TRUE)
else()
  find_path(
    HIREDIS_INCLUDE_DIR
    NAMES hiredis/hiredis.h
    HINTS ${HIREDIS_ROOT_DIR}
    PATH_SUFFIXES include)

  find_library(
    HIREDIS_LIBRARY
    NAMES hiredis
    HINTS ${HIREDIS_ROOT_DIR}
    PATH_SUFFIXES ${CMAKE_INSTALL_LIBDIR})

  set(HIREDIS_INCLUDE_DIRS ${HIREDIS_INCLUDE_DIR})
  set(HIREDIS_LIBRARIES ${HIREDIS_LIBRARY})

  include (FindPackageHandleStandardArgs)
  find_package_handle_standard_args(
    hiredis DEFAULT_MSG HIREDIS_LIBRARY HIREDIS_INCLUDE_DIR)

  mark_as_advanced(HIREDIS_LIBRARY HIREDIS_INCLUDE_DIR)
endif()

我正在使用以下代码构建

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
find_library( microhttpd REQUIRED )
find_package(hiredis REQUIRED)
include_directories( ${HIREDIS_INCLUDE_DIRS} )
target_link_libraries( project ${HIREDIS_LIBRARIES} )

并且主文件中的包含是#include <hiredis.h>. 我不断得到的错误是

main.c:5:10: fatal error: hiredis.h: No such file or directory
#include <hiredis.h>

不知道我哪里出错了。查找hiredis包的脚本取自redox github存储库,我已经验证了该包已安装。谢谢你的协助。

4

0 回答 0