summaryrefslogtreecommitdiff
blob: 5715edaec3f085443e06ad5b84a282e2c63388cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
From 3a07d551949ff488d1d669600a07d9c73ff4cc55 Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <asturm@gentoo.org>
Date: Mon, 29 Apr 2019 21:08:02 +0200
Subject: [PATCH 1/2] Import FindBrotliDec.cmake and FindBrotliEnc.cmake from
 Igalia S.L.

MIT License, which fits well.

Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
---
 cmake/FindBrotliDec.cmake | 35 +++++++++++++++++++++++++++++++++++
 cmake/FindBrotliEnc.cmake | 35 +++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+)
 create mode 100644 cmake/FindBrotliDec.cmake
 create mode 100644 cmake/FindBrotliEnc.cmake

diff --git a/cmake/FindBrotliDec.cmake b/cmake/FindBrotliDec.cmake
new file mode 100644
index 00000000..abb06f44
--- /dev/null
+++ b/cmake/FindBrotliDec.cmake
@@ -0,0 +1,35 @@
+# Copyright 2017 Igalia S.L. All Rights Reserved.
+#
+# Distributed under MIT license.
+# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
+
+# Try to find BrotliDec. Once done, this will define
+#
+#  BROTLIDEC_FOUND - system has BrotliDec.
+#  BROTLIDEC_INCLUDE_DIRS - the BrotliDec include directories
+#  BROTLIDEC_LIBRARIES - link these to use BrotliDec.
+
+find_package(PkgConfig)
+
+pkg_check_modules(PC_BROTLIDEC libbrotlidec)
+
+find_path(BROTLIDEC_INCLUDE_DIRS
+    NAMES brotli/decode.h
+    HINTS ${PC_BROTLIDEC_INCLUDEDIR}
+)
+
+find_library(BROTLIDEC_LIBRARIES
+    NAMES brotlidec
+    HINTS ${PC_BROTLIDEC_LIBDIR}
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(BrotliDec
+    REQUIRED_VARS BROTLIDEC_INCLUDE_DIRS BROTLIDEC_LIBRARIES
+    FOUND_VAR BROTLIDEC_FOUND
+    VERSION_VAR PC_BROTLIDEC_VERSION)
+
+mark_as_advanced(
+    BROTLIDEC_INCLUDE_DIRS
+    BROTLIDEC_LIBRARIES
+)
diff --git a/cmake/FindBrotliEnc.cmake b/cmake/FindBrotliEnc.cmake
new file mode 100644
index 00000000..4be347db
--- /dev/null
+++ b/cmake/FindBrotliEnc.cmake
@@ -0,0 +1,35 @@
+# Copyright 2017 Igalia S.L. All Rights Reserved.
+#
+# Distributed under MIT license.
+# See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
+
+# Try to find BrotliEnc. Once done, this will define
+#
+#  BROTLIENC_FOUND - system has BrotliEnc.
+#  BROTLIENC_INCLUDE_DIRS - the BrotliEnc include directories
+#  BROTLIENC_LIBRARIES - link these to use BrotliEnc.
+
+find_package(PkgConfig)
+
+pkg_check_modules(PC_BROTLIENC libbrotlienc)
+
+find_path(BROTLIENC_INCLUDE_DIRS
+    NAMES brotli/encode.h
+    HINTS ${PC_BROTLIENC_INCLUDEDIR}
+)
+
+find_library(BROTLIENC_LIBRARIES
+    NAMES brotlienc
+    HINTS ${PC_BROTLIENC_LIBDIR}
+)
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(BrotliEnc
+    REQUIRED_VARS BROTLIENC_INCLUDE_DIRS BROTLIENC_LIBRARIES
+    FOUND_VAR BROTLIENC_FOUND
+    VERSION_VAR PC_BROTLIENC_VERSION)
+
+mark_as_advanced(
+    BROTLIENC_INCLUDE_DIRS
+    BROTLIENC_LIBRARIES
+)
-- 
2.24.1

From 08a410f238aaf6488759e023b66d16cbbd7f6d66 Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <asturm@gentoo.org>
Date: Mon, 29 Apr 2019 21:11:57 +0200
Subject: [PATCH 2/2] Find system brotli instead of bundled

Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
---
 CMakeLists.txt           | 5 +++--
 cli/CMakeLists.txt       | 2 +-
 lib/trace/CMakeLists.txt | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c71d24e6..88e6b156 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -491,8 +491,9 @@ if (ENABLE_STATIC_SNAPPY OR NOT SNAPPY_FOUND)
 endif ()
 include_directories (${SNAPPY_INCLUDE_DIRS})
 
-include_directories (${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/brotli/c/include)
-add_subdirectory (thirdparty/brotli)
+find_package(BrotliDec REQUIRED)
+find_package(BrotliEnc REQUIRED)
+include_directories (${BROTLIDEC_INCLUDE_DIRS} ${BROTLIENC_INCLUDE_DIRS})
 
 if (NOT WIN32 AND NOT ENABLE_STATIC_EXE)
     # zlib 1.2.4-1.2.5 made it impossible to read the last block of incomplete
diff --git a/cli/CMakeLists.txt b/cli/CMakeLists.txt
index 3a3c127e..0b33ddb5 100644
--- a/cli/CMakeLists.txt
+++ b/cli/CMakeLists.txt
@@ -39,7 +39,7 @@ add_executable (apitrace
 
 target_link_libraries (apitrace
     common
-    brotli_dec brotli_enc brotli_common
+    ${BROTLIDEC_LIBRARIES} ${BROTLIENC_LIBRARIES}
     ${ZLIB_LIBRARIES}
     ${SNAPPY_LIBRARIES}
     ${GETOPT_LIBRARIES}
diff --git a/lib/trace/CMakeLists.txt b/lib/trace/CMakeLists.txt
index c68bd00f..ce2e469e 100644
--- a/lib/trace/CMakeLists.txt
+++ b/lib/trace/CMakeLists.txt
@@ -31,7 +31,7 @@ target_link_libraries (common
     guids
     highlight
     os
-    brotli_dec brotli_common
+    ${BROTLIDEC_LIBRARIES} ${BROTLIENC_LIBRARIES}
 )
 
 add_gtest (trace_parser_flags_test trace_parser_flags_test.cpp)
-- 
2.24.1