Debian Codegraph @

extra/curl/curl-8.14.1/CMake/FindBrotli.cmake

raw
1 #***************************************************************************
2 # _ _ ____ _
3 # Project ___| | | | _ \| |
4 # / __| | | | |_) | |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
7 #
8 # Copyright (C) Daniel Stenberg, <[email protected]>, 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_LIBRARY_DIRS`: The brotli library directories.
38 # - `BROTLI_PC_REQUIRES`: The brotli pkg-config packages.
39 # - `BROTLI_CFLAGS`: Required compiler flags.
40 # - `BROTLI_VERSION`: Version of brotli.
41
42 set(BROTLI_PC_REQUIRES "libbrotlidec" "libbrotlicommon") # order is significant: brotlidec then brotlicommon
43
44 if(CURL_USE_PKGCONFIG AND
45 NOT DEFINED BROTLI_INCLUDE_DIR AND
46 NOT DEFINED BROTLICOMMON_LIBRARY AND
47 NOT DEFINED BROTLIDEC_LIBRARY)
48 find_package(PkgConfig QUIET)
49 pkg_check_modules(BROTLI ${BROTLI_PC_REQUIRES})
50 endif()
51
52 if(BROTLI_FOUND)
53 set(Brotli_FOUND TRUE)
54 set(BROTLI_VERSION "${BROTLI_libbrotlicommon_VERSION}")
55 string(REPLACE ";" " " BROTLI_CFLAGS "${BROTLI_CFLAGS}")
56 message(STATUS "Found Brotli (via pkg-config): ${BROTLI_INCLUDE_DIRS} (found version \"${BROTLI_VERSION}\")")
57 else()
58 find_path(BROTLI_INCLUDE_DIR "brotli/decode.h")
59 find_library(BROTLICOMMON_LIBRARY NAMES "brotlicommon")
60 find_library(BROTLIDEC_LIBRARY NAMES "brotlidec")
61
62 include(FindPackageHandleStandardArgs)
63 find_package_handle_standard_args(Brotli
64 REQUIRED_VARS
65 BROTLI_INCLUDE_DIR
66 BROTLIDEC_LIBRARY
67 BROTLICOMMON_LIBRARY
68 )
69
70 if(BROTLI_FOUND)
71 set(BROTLI_INCLUDE_DIRS ${BROTLI_INCLUDE_DIR})
72 set(BROTLI_LIBRARIES ${BROTLIDEC_LIBRARY} ${BROTLICOMMON_LIBRARY})
73 endif()
74
75 mark_as_advanced(BROTLI_INCLUDE_DIR BROTLIDEC_LIBRARY BROTLICOMMON_LIBRARY)
76 endif()