FindPackages.cmake 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Find system packages
  2. # Required packages
  3. find_package(PkgConfig REQUIRED)
  4. find_package(Threads REQUIRED)
  5. find_package(OpenSSL REQUIRED)
  6. find_package(CURL REQUIRED)
  7. # nlohmann-json
  8. find_package(nlohmann_json 3.11 QUIET)
  9. if(NOT nlohmann_json_FOUND)
  10. pkg_check_modules(nlohmann_json REQUIRED IMPORTED_TARGET nlohmann_json)
  11. add_library(nlohmann_json::nlohmann_json ALIAS PkgConfig::nlohmann_json)
  12. endif()
  13. # spdlog
  14. find_package(spdlog QUIET)
  15. if(NOT spdlog_FOUND)
  16. pkg_check_modules(spdlog REQUIRED IMPORTED_TARGET spdlog)
  17. add_library(spdlog::spdlog ALIAS PkgConfig::spdlog)
  18. endif()
  19. # gRPC and Protobuf
  20. find_package(gRPC CONFIG QUIET)
  21. if(NOT gRPC_FOUND)
  22. pkg_check_modules(grpc++ REQUIRED IMPORTED_TARGET grpc++)
  23. add_library(gRPC::grpc++ ALIAS PkgConfig::grpc++)
  24. endif()
  25. find_package(Protobuf REQUIRED)
  26. # libwebsockets
  27. pkg_check_modules(websockets REQUIRED IMPORTED_TARGET libwebsockets)
  28. add_library(websockets ALIAS PkgConfig::websockets)
  29. # MySQL/MariaDB client
  30. pkg_check_modules(mariadb QUIET IMPORTED_TARGET libmariadb)
  31. if(mariadb_FOUND)
  32. add_library(mysql_client ALIAS PkgConfig::mariadb)
  33. set(MYSQL_CLIENT_FOUND TRUE CACHE BOOL "MySQL client library found")
  34. message(STATUS "Found MariaDB client library")
  35. else()
  36. pkg_check_modules(mysqlclient QUIET IMPORTED_TARGET mysqlclient)
  37. if(mysqlclient_FOUND)
  38. add_library(mysql_client ALIAS PkgConfig::mysqlclient)
  39. set(MYSQL_CLIENT_FOUND TRUE CACHE BOOL "MySQL client library found")
  40. message(STATUS "Found MySQL client library")
  41. else()
  42. set(MYSQL_CLIENT_FOUND FALSE CACHE BOOL "MySQL client library found")
  43. message(STATUS "MySQL/MariaDB client library not found - MySQL node support disabled")
  44. endif()
  45. endif()
  46. # PostgreSQL client (libpq)
  47. pkg_check_modules(libpq QUIET IMPORTED_TARGET libpq)
  48. if(libpq_FOUND)
  49. add_library(postgresql_client ALIAS PkgConfig::libpq)
  50. set(POSTGRESQL_CLIENT_FOUND TRUE CACHE BOOL "PostgreSQL client library found")
  51. message(STATUS "Found PostgreSQL client library (libpq)")
  52. else()
  53. set(POSTGRESQL_CLIENT_FOUND FALSE CACHE BOOL "PostgreSQL client library found")
  54. message(STATUS "PostgreSQL client library not found - PostgreSQL node support disabled")
  55. endif()