FindPackages.cmake 2.3 KB

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