Rapid spam filtering system https://rspamd.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.9 KiB

  1. include(CheckIncludeFiles)
  2. include(CheckLibraryExists)
  3. # Function to check for URL include support (libcurl or libfetch)
  4. function(CheckURLIncludeSupport)
  5. # First try to find libfetch
  6. find_library(LIBFETCH_LIBRARY HINTS "${RSPAMD_SEARCH_PATH}"
  7. NAMES fetch PATHS PATH_SUFFIXES lib64 lib
  8. PATHS ${RSPAMD_DEFAULT_LIBRARY_PATHS}
  9. DOC "Path where the libfetch library can be found")
  10. if (LIBFETCH_LIBRARY)
  11. # Found libfetch library, now check for header
  12. find_file(HAVE_FETCH_H HINTS "${RSPAMD_SEARCH_PATH}"
  13. NAMES fetch.h
  14. PATH_SUFFIXES include
  15. PATHS ${RSPAMD_DEFAULT_INCLUDE_PATHS}
  16. DOC "Path to libfetch header")
  17. if (HAVE_FETCH_H)
  18. message(STATUS "Found libfetch: ${LIBFETCH_LIBRARY}")
  19. list(APPEND RSPAMD_REQUIRED_LIBRARIES "fetch")
  20. set(WITH_FETCH 1)
  21. set(WITH_FETCH ${WITH_FETCH} PARENT_SCOPE)
  22. else ()
  23. message(STATUS "Found libfetch library but missing fetch.h header")
  24. endif ()
  25. else ()
  26. # Try to find libcurl as an alternative
  27. ProcessPackage(CURL LIBRARY curl INCLUDE curl.h INCLUDE_SUFFIXES include/curl
  28. ROOT ${CURL_ROOT})
  29. if (WITH_CURL)
  30. message(STATUS "Found libcurl for URL includes")
  31. set(WITH_CURL ${WITH_CURL} PARENT_SCOPE)
  32. else ()
  33. message(WARNING "Neither libcurl nor libfetch were found, no support of URL includes in configuration")
  34. endif ()
  35. endif ()
  36. # Propagate variables to parent scope
  37. if (HAVE_FETCH_H)
  38. set(HAVE_FETCH_H ${HAVE_FETCH_H} PARENT_SCOPE)
  39. set(LIBFETCH_LIBRARY ${LIBFETCH_LIBRARY} PARENT_SCOPE)
  40. endif ()
  41. # Update the global RSPAMD_REQUIRED_LIBRARIES list
  42. if (HAVE_FETCH_H)
  43. set(RSPAMD_REQUIRED_LIBRARIES ${RSPAMD_REQUIRED_LIBRARIES} PARENT_SCOPE)
  44. endif ()
  45. endfunction()