Findssh2.cmake 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #国密加解密库
  2. message(STATUS "***** Find ssh2 Library *****")
  3. #寻找头文件
  4. unset(ssh2_INCLUDE_DIR CACHE)
  5. unset(INCLUDE_PATH)
  6. find_path(INCLUDE_PATH
  7. NAMES libssh2.h
  8. PATHS ${CMAKE_CURRENT_LIST_DIR}/include
  9. NO_DEFAULT_PATH
  10. )
  11. list(APPEND ssh2_INCLUDE_DIR ${INCLUDE_PATH})
  12. #查找库文件,需要判断操作系统,位数
  13. if(CMAKE_SYSTEM_NAME MATCHES "Windows")
  14. message(WARNING "Windows is not supported")
  15. # if(CMAKE_SIZEOF_VOID_P EQUAL 8)
  16. # if(CMAKE_BUILD_TYPE MATCHES "Debug")
  17. # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64/with_debug_info/libSM_DLL.lib)
  18. # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64/ucrtbased.dll)
  19. # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64/vcruntime140d.dll)
  20. # else()
  21. # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64/libSM_DLL.lib)
  22. # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64/ucrtbase.dll)
  23. # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x64/vcruntime140.dll)
  24. # endif()
  25. # elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
  26. # if(CMAKE_BUILD_TYPE MATCHES "Debug")
  27. # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x86/with_debug_info/libSM_DLL.lib)
  28. # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x86/ucrtbased.dll)
  29. # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x86/vcruntime140d.dll)
  30. # else()
  31. # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x86/libSM_DLL.lib)
  32. # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x86/ucrtbase.dll)
  33. # list(APPEND SM_LIB_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/libs/win/x86/vcruntime140.dll)
  34. # endif()
  35. # endif()
  36. #添加Linux版本
  37. elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
  38. list(APPEND ssh2_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/lib/linux/libssh2.so)
  39. list(APPEND ssh2_STATIC_LIBRARY ${CMAKE_CURRENT_LIST_DIR}/lib/linux/libssh2.a)
  40. endif()
  41. #设置查找到后的变量
  42. if(ssh2_INCLUDE_DIR AND ssh2_LIBRARY AND ssh2_STATIC_LIBRARY)
  43. set(ssh2_FOUND TRUE)
  44. set(ssh2_VERSION "1.11.1")
  45. else()
  46. set(ssh2_FOUND FALSE)
  47. endif()
  48. message(STATUS "include : ssh2_INCLUDE_DIR")
  49. message(STATUS "Library : ssh2_LIBRARY")
  50. message(STATUS "Static Library : ssh2_STATIC_LIBRARY")
  51. message(STATUS "---------------------------------")