#国密加解密库 message(STATUS "***** Find hiredis Library *****") #寻找头文件 unset(hiredis_INCLUDE_DIR CACHE) unset(INCLUDE_PATH CACHE) find_path(INCLUDE_PATH NAMES hiredis.h PATHS ${CMAKE_CURRENT_LIST_DIR}/include/hiredis NO_DEFAULT_PATH ) list(APPEND hiredis_INCLUDE_DIR ${INCLUDE_PATH}) # message(STATUS "CMAKE_CURRENT_LIST_DIR : ${CMAKE_CURRENT_LIST_DIR}") # message(STATUS "INCLUDE_PATH : ${INCLUDE_PATH}") # message(STATUS "include : ${hiredis_INCLUDE_DIR}") #查找库文件,需要判断操作系统,位数 if(CMAKE_SYSTEM_NAME MATCHES "Windows") message(WARNING "Hiredis on Windows is not supported") # if(CMAKE_SIZEOF_VOID_P EQUAL 8) # if(CMAKE_BUILD_TYPE MATCHES "Debug") # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64/with_debug_info/libSM_DLL.lib) # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64/ucrtbased.dll) # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64/vcruntime140d.dll) # else() # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64/libSM_DLL.lib) # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64/ucrtbase.dll) # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64/vcruntime140.dll) # endif() # elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) # if(CMAKE_BUILD_TYPE MATCHES "Debug") # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x86/with_debug_info/libSM_DLL.lib) # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x86/ucrtbased.dll) # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x86/vcruntime140d.dll) # else() # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x86/libSM_DLL.lib) # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x86/ucrtbase.dll) # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x86/vcruntime140.dll) # endif() # endif() #添加Linux版本 elseif(CMAKE_SYSTEM_NAME MATCHES "Linux") list(APPEND hiredis_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/lib/linux/libhiredis.so) endif() #设置查找到后的变量 if(hiredis_INCLUDE_DIR AND hiredis_LIBRARY) set(hiredis_FOUND TRUE) set(hiredis_VERSION "1.1.0") else() set(hiredis_FOUND FALSE) endif() # message(STATUS "include : hiredis_INCLUDE_DIR") # message(STATUS "Library : hiredis_LIBRARY") # message(STATUS "Static Library : ssh2_STATIC_LIBRARY") message(STATUS "target_link_libraries(External::hiredis)") message(STATUS "hiredis Found : ${hiredis_FOUND}") message(STATUS "hiredis Version : ${hiredis_VERSION}") message(STATUS "--------------------------------------------------") #导入目标 if(hiredis_FOUND) if(NOT TARGET External::hiredis) add_library(External::hiredis UNKNOWN IMPORTED) #添加头文件 set_target_properties(External::hiredis PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${hiredis_INCLUDE_DIR}") #添加库文件 set_target_properties(External::hiredis PROPERTIES IMPORTED_LOCATION "${hiredis_LIBRARY}") #添加spdlog需要的依赖库 # set_target_properties(External::hiredis PROPERTIES # INTERFACE_LINK_LIBRARIES "pthread") #添加源文件 # set_target_properties(External::hiredis PROPERTIES # INTERFACE_SOURCES "${hiredis_SOURCES}") endif() endif() # 标记这些变量为高级变量 mark_as_advanced( hiredis_INCLUDE_DIR hiredis_LIBRARY )