FindBrotli.cmake 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. #
  10. # This software is licensed as described in the file COPYING, which
  11. # you should have received as part of this distribution. The terms
  12. # are also available at https://curl.se/docs/copyright.html.
  13. #
  14. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. # copies of the Software, and permit persons to whom the Software is
  16. # furnished to do so, under the terms of the COPYING file.
  17. #
  18. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. # KIND, either express or implied.
  20. #
  21. # SPDX-License-Identifier: curl
  22. #
  23. ###########################################################################
  24. # Find the brotli library
  25. #
  26. # Input variables:
  27. #
  28. # - `BROTLI_INCLUDE_DIR`: The brotli include directory.
  29. # - `BROTLICOMMON_LIBRARY`: Path to `brotlicommon` library.
  30. # - `BROTLIDEC_LIBRARY`: Path to `brotlidec` library.
  31. #
  32. # Result variables:
  33. #
  34. # - `BROTLI_FOUND`: System has brotli.
  35. # - `BROTLI_INCLUDE_DIRS`: The brotli include directories.
  36. # - `BROTLI_LIBRARIES`: The brotli library names.
  37. # - `BROTLI_VERSION`: Version of brotli.
  38. if(CURL_USE_PKGCONFIG)
  39. find_package(PkgConfig QUIET)
  40. pkg_check_modules(PC_BROTLI "libbrotlidec")
  41. endif()
  42. find_path(BROTLI_INCLUDE_DIR "brotli/decode.h"
  43. HINTS
  44. ${PC_BROTLI_INCLUDEDIR}
  45. ${PC_BROTLI_INCLUDE_DIRS}
  46. )
  47. find_library(BROTLICOMMON_LIBRARY NAMES "brotlicommon"
  48. HINTS
  49. ${PC_BROTLI_LIBDIR}
  50. ${PC_BROTLI_LIBRARY_DIRS}
  51. )
  52. find_library(BROTLIDEC_LIBRARY NAMES "brotlidec"
  53. HINTS
  54. ${PC_BROTLI_LIBDIR}
  55. ${PC_BROTLI_LIBRARY_DIRS}
  56. )
  57. if(PC_BROTLI_VERSION)
  58. set(BROTLI_VERSION ${PC_BROTLI_VERSION})
  59. endif()
  60. include(FindPackageHandleStandardArgs)
  61. find_package_handle_standard_args(Brotli
  62. REQUIRED_VARS
  63. BROTLI_INCLUDE_DIR
  64. BROTLIDEC_LIBRARY
  65. BROTLICOMMON_LIBRARY
  66. VERSION_VAR
  67. BROTLI_VERSION
  68. )
  69. if(BROTLI_FOUND)
  70. set(BROTLI_INCLUDE_DIRS ${BROTLI_INCLUDE_DIR})
  71. set(BROTLI_LIBRARIES ${BROTLIDEC_LIBRARY} ${BROTLICOMMON_LIBRARY})
  72. endif()
  73. mark_as_advanced(BROTLI_INCLUDE_DIR BROTLIDEC_LIBRARY BROTLICOMMON_LIBRARY)