FindDependencies.cmake 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # FindDependencies.cmake - Find and configure required dependencies
  2. # Find nlohmann/json
  3. find_package(nlohmann_json QUIET)
  4. if(NOT nlohmann_json_FOUND)
  5. message(STATUS "nlohmann_json not found, will use FetchContent")
  6. include(FetchContent)
  7. FetchContent_Declare(
  8. json
  9. GIT_REPOSITORY https://github.com/nlohmann/json.git
  10. GIT_TAG v3.11.2
  11. )
  12. FetchContent_MakeAvailable(json)
  13. set(NLOHMANN_JSON_TARGET nlohmann_json::nlohmann_json)
  14. else()
  15. set(NLOHMANN_JSON_TARGET nlohmann_json::nlohmann_json)
  16. message(STATUS "Found nlohmann_json: ${nlohmann_json_VERSION}")
  17. endif()
  18. # Find httplib
  19. find_package(httplib QUIET)
  20. if(NOT httplib_FOUND)
  21. message(STATUS "httplib not found, will use FetchContent")
  22. include(FetchContent)
  23. FetchContent_Declare(
  24. httplib
  25. GIT_REPOSITORY https://github.com/yhirose/cpp-httplib.git
  26. GIT_TAG v0.27.0
  27. )
  28. FetchContent_MakeAvailable(httplib)
  29. set(HTTPLIB_TARGET httplib)
  30. else()
  31. set(HTTPLIB_TARGET httplib::httplib)
  32. message(STATUS "Found httplib: ${httplib_VERSION}")
  33. endif()
  34. # Find threads
  35. find_package(Threads REQUIRED)
  36. # Check for CUDA
  37. if(SD_CUDA_SUPPORT)
  38. find_package(CUDA QUIET)
  39. if(CUDA_FOUND)
  40. message(STATUS "Found CUDA: ${CUDA_VERSION}")
  41. enable_language(CUDA)
  42. else()
  43. message(WARNING "CUDA not found, disabling CUDA support")
  44. set(SD_CUDA_SUPPORT OFF)
  45. endif()
  46. endif()
  47. # Find OpenMP
  48. find_package(OpenMP)
  49. if(OpenMP_CXX_FOUND)
  50. message(STATUS "Found OpenMP: ${OpenMP_CXX_VERSION}")
  51. else()
  52. message(WARNING "OpenMP not found")
  53. endif()
  54. # Find OpenSSL for SHA256 hashing
  55. find_package(OpenSSL REQUIRED)
  56. if(OpenSSL_FOUND)
  57. message(STATUS "Found OpenSSL: ${OPENSSL_VERSION}")
  58. else()
  59. message(FATAL_ERROR "OpenSSL not found - required for model hashing")
  60. endif()
  61. # Find PAM if enabled
  62. if(ENABLE_PAM_AUTH)
  63. find_package(PAM)
  64. if(PAM_FOUND)
  65. message(STATUS "Found PAM: ${PAM_VERSION}")
  66. list(APPEND DEPENDENCY_LIBRARIES PAM::PAM)
  67. else()
  68. message(WARNING "PAM not found, PAM authentication will be disabled")
  69. set(ENABLE_PAM_AUTH OFF)
  70. endif()
  71. endif()
  72. # Set up variables for targets
  73. set(DEPENDENCY_LIBRARIES
  74. ${NLOHMANN_JSON_TARGET}
  75. ${HTTPLIB_TARGET}
  76. Threads::Threads
  77. OpenSSL::Crypto
  78. )
  79. if(OpenMP_CXX_FOUND)
  80. list(APPEND DEPENDENCY_LIBRARIES OpenMP::OpenMP_CXX)
  81. endif()
  82. message(STATUS "Dependencies configured successfully")