xref: /aosp_15_r20/external/libwebm/CMakeLists.txt (revision 103e46e4cd4b6efcf6001f23fa8665fb110abf8d)
1#  Copyright (c) 2015 The WebM project authors. All Rights Reserved.
2#
3#  Use of this source code is governed by a BSD-style license
4#  that can be found in the LICENSE file in the root of the source
5#  tree. An additional intellectual property rights grant can be found
6#  in the file PATENTS.  All contributing project authors may
7#  be found in the AUTHORS file in the root of the source tree.
8cmake_minimum_required(VERSION 3.2)
9project(LIBWEBM CXX)
10
11include(GNUInstallDirs)
12include("${CMAKE_CURRENT_SOURCE_DIR}/build/cxx_flags.cmake")
13
14if(BUILD_SHARED_LIBS)
15  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
16else()
17  include("${CMAKE_CURRENT_SOURCE_DIR}/build/msvc_runtime.cmake")
18endif()
19
20set(LIBWEBM_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
21
22# Build/test configuration flags.
23option(ENABLE_WEBMTS "Enables WebM PES/TS support." ON)
24option(ENABLE_WEBMINFO "Enables building webm_info." ON)
25option(ENABLE_TESTS "Enables tests." OFF)
26option(ENABLE_IWYU "Enables include-what-you-use support." OFF)
27option(ENABLE_WERROR "Enable warnings as errors." OFF)
28option(ENABLE_WEBM_PARSER "Enables new parser API." OFF)
29option(ENABLE_SAMPLE_PROGRAMS "Enables building sample programs." ON)
30
31if(WIN32
32   OR CYGWIN
33   OR MSYS)
34  # Allow use of rand_r() / fdopen() and other POSIX functions.
35  require_cxx_flag_nomsvc("-std=gnu++11")
36else()
37  require_cxx_flag_nomsvc("-std=c++11")
38endif()
39
40add_cxx_preproc_definition("__STDC_CONSTANT_MACROS")
41add_cxx_preproc_definition("__STDC_FORMAT_MACROS")
42add_cxx_preproc_definition("__STDC_LIMIT_MACROS")
43
44# Set up compiler flags and build properties.
45include_directories("${LIBWEBM_SRC_DIR}")
46
47if(MSVC)
48  set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
49  add_cxx_flag_if_supported("/W4")
50  # Disable MSVC warnings that suggest making code non-portable.
51  add_cxx_flag_if_supported("/wd4996")
52  if(ENABLE_WERROR)
53    add_cxx_flag_if_supported("/WX")
54  endif()
55else()
56  add_cxx_flag_if_supported("-Wall")
57  add_cxx_flag_if_supported("-Wc++14-compat")
58  add_cxx_flag_if_supported("-Wc++17-compat")
59  add_cxx_flag_if_supported("-Wc++20-compat")
60  add_cxx_flag_if_supported("-Wextra")
61  add_cxx_flag_if_supported("-Wnarrowing")
62  add_cxx_flag_if_supported("-Wno-deprecated")
63  add_cxx_flag_if_supported("-Wshorten-64-to-32")
64  if(ENABLE_WERROR)
65    add_cxx_flag_if_supported("-Werror")
66  endif()
67endif()
68
69# Source list variables.
70set(dumpvtt_sources "${LIBWEBM_SRC_DIR}/dumpvtt.cc")
71
72set(libwebm_common_public_headers "${LIBWEBM_SRC_DIR}/common/webmids.h")
73
74set(libwebm_common_sources
75    ${libwebm_common_public_headers}
76    "${LIBWEBM_SRC_DIR}/common/file_util.cc"
77    "${LIBWEBM_SRC_DIR}/common/file_util.h"
78    "${LIBWEBM_SRC_DIR}/common/hdr_util.cc"
79    "${LIBWEBM_SRC_DIR}/common/hdr_util.h")
80
81set(mkvmuxer_public_headers
82    "${LIBWEBM_SRC_DIR}/mkvmuxer/mkvmuxer.h"
83    "${LIBWEBM_SRC_DIR}/mkvmuxer/mkvmuxertypes.h"
84    "${LIBWEBM_SRC_DIR}/mkvmuxer/mkvmuxerutil.h"
85    "${LIBWEBM_SRC_DIR}/mkvmuxer/mkvwriter.h")
86
87set(mkvmuxer_sources
88    ${mkvmuxer_public_headers}
89    "${LIBWEBM_SRC_DIR}/mkvmuxer/mkvmuxer.cc"
90    "${LIBWEBM_SRC_DIR}/mkvmuxer/mkvmuxerutil.cc"
91    "${LIBWEBM_SRC_DIR}/mkvmuxer/mkvwriter.cc"
92    "${LIBWEBM_SRC_DIR}/common/webmids.h")
93
94set(mkvmuxer_sample_sources
95    "${LIBWEBM_SRC_DIR}/mkvmuxer_sample.cc"
96    "${LIBWEBM_SRC_DIR}/sample_muxer_metadata.cc"
97    "${LIBWEBM_SRC_DIR}/sample_muxer_metadata.h")
98
99set(mkvmuxer_tests_sources
100    "${LIBWEBM_SRC_DIR}/testing/mkvmuxer_tests.cc"
101    "${LIBWEBM_SRC_DIR}/testing/test_util.cc"
102    "${LIBWEBM_SRC_DIR}/testing/test_util.h")
103
104set(mkvparser_public_headers "${LIBWEBM_SRC_DIR}/mkvparser/mkvparser.h"
105                             "${LIBWEBM_SRC_DIR}/mkvparser/mkvreader.h")
106
107set(mkvparser_sources
108    ${mkvparser_public_headers} "${LIBWEBM_SRC_DIR}/mkvparser/mkvparser.cc"
109    "${LIBWEBM_SRC_DIR}/mkvparser/mkvreader.cc"
110    "${LIBWEBM_SRC_DIR}/common/webmids.h")
111
112set(mkvparser_sample_sources "${LIBWEBM_SRC_DIR}/mkvparser_sample.cc")
113set(mkvparser_tests_sources
114    "${LIBWEBM_SRC_DIR}/testing/mkvparser_tests.cc"
115    "${LIBWEBM_SRC_DIR}/testing/test_util.cc"
116    "${LIBWEBM_SRC_DIR}/testing/test_util.h")
117
118set(vp9_header_parser_tests_sources
119    "${LIBWEBM_SRC_DIR}/common/vp9_header_parser_tests.cc"
120    "${LIBWEBM_SRC_DIR}/common/vp9_header_parser.cc"
121    "${LIBWEBM_SRC_DIR}/common/vp9_header_parser.h"
122    "${LIBWEBM_SRC_DIR}/testing/test_util.cc"
123    "${LIBWEBM_SRC_DIR}/testing/test_util.h")
124
125set(vp9_level_stats_tests_sources
126    "${LIBWEBM_SRC_DIR}/common/vp9_header_parser.cc"
127    "${LIBWEBM_SRC_DIR}/common/vp9_header_parser.h"
128    "${LIBWEBM_SRC_DIR}/common/vp9_level_stats_tests.cc"
129    "${LIBWEBM_SRC_DIR}/common/vp9_level_stats.cc"
130    "${LIBWEBM_SRC_DIR}/common/vp9_level_stats.h"
131    "${LIBWEBM_SRC_DIR}/testing/test_util.cc"
132    "${LIBWEBM_SRC_DIR}/testing/test_util.h")
133
134set(webm_parser_public_headers
135    "${LIBWEBM_SRC_DIR}/webm_parser/include/webm/buffer_reader.h"
136    "${LIBWEBM_SRC_DIR}/webm_parser/include/webm/callback.h"
137    "${LIBWEBM_SRC_DIR}/webm_parser/include/webm/dom_types.h"
138    "${LIBWEBM_SRC_DIR}/webm_parser/include/webm/element.h"
139    "${LIBWEBM_SRC_DIR}/webm_parser/include/webm/file_reader.h"
140    "${LIBWEBM_SRC_DIR}/webm_parser/include/webm/id.h"
141    "${LIBWEBM_SRC_DIR}/webm_parser/include/webm/istream_reader.h"
142    "${LIBWEBM_SRC_DIR}/webm_parser/include/webm/reader.h"
143    "${LIBWEBM_SRC_DIR}/webm_parser/include/webm/status.h"
144    "${LIBWEBM_SRC_DIR}/webm_parser/include/webm/webm_parser.h")
145
146set(webm_parser_sources
147    ${webm_parser_public_headers}
148    "${LIBWEBM_SRC_DIR}/webm_parser/src/ancestory.cc"
149    "${LIBWEBM_SRC_DIR}/webm_parser/src/ancestory.h"
150    "${LIBWEBM_SRC_DIR}/webm_parser/src/audio_parser.h"
151    "${LIBWEBM_SRC_DIR}/webm_parser/src/bit_utils.cc"
152    "${LIBWEBM_SRC_DIR}/webm_parser/src/bit_utils.h"
153    "${LIBWEBM_SRC_DIR}/webm_parser/src/block_additions_parser.h"
154    "${LIBWEBM_SRC_DIR}/webm_parser/src/block_group_parser.h"
155    "${LIBWEBM_SRC_DIR}/webm_parser/src/block_header_parser.cc"
156    "${LIBWEBM_SRC_DIR}/webm_parser/src/block_header_parser.h"
157    "${LIBWEBM_SRC_DIR}/webm_parser/src/block_more_parser.h"
158    "${LIBWEBM_SRC_DIR}/webm_parser/src/block_parser.cc"
159    "${LIBWEBM_SRC_DIR}/webm_parser/src/block_parser.h"
160    "${LIBWEBM_SRC_DIR}/webm_parser/src/bool_parser.h"
161    "${LIBWEBM_SRC_DIR}/webm_parser/src/buffer_reader.cc"
162    "${LIBWEBM_SRC_DIR}/webm_parser/src/byte_parser.h"
163    "${LIBWEBM_SRC_DIR}/webm_parser/src/callback.cc"
164    "${LIBWEBM_SRC_DIR}/webm_parser/src/chapter_atom_parser.h"
165    "${LIBWEBM_SRC_DIR}/webm_parser/src/chapter_display_parser.h"
166    "${LIBWEBM_SRC_DIR}/webm_parser/src/chapters_parser.h"
167    "${LIBWEBM_SRC_DIR}/webm_parser/src/cluster_parser.h"
168    "${LIBWEBM_SRC_DIR}/webm_parser/src/colour_parser.h"
169    "${LIBWEBM_SRC_DIR}/webm_parser/src/content_enc_aes_settings_parser.h"
170    "${LIBWEBM_SRC_DIR}/webm_parser/src/content_encoding_parser.h"
171    "${LIBWEBM_SRC_DIR}/webm_parser/src/content_encodings_parser.h"
172    "${LIBWEBM_SRC_DIR}/webm_parser/src/content_encryption_parser.h"
173    "${LIBWEBM_SRC_DIR}/webm_parser/src/cue_point_parser.h"
174    "${LIBWEBM_SRC_DIR}/webm_parser/src/cue_track_positions_parser.h"
175    "${LIBWEBM_SRC_DIR}/webm_parser/src/cues_parser.h"
176    "${LIBWEBM_SRC_DIR}/webm_parser/src/date_parser.cc"
177    "${LIBWEBM_SRC_DIR}/webm_parser/src/date_parser.h"
178    "${LIBWEBM_SRC_DIR}/webm_parser/src/ebml_parser.h"
179    "${LIBWEBM_SRC_DIR}/webm_parser/src/edition_entry_parser.h"
180    "${LIBWEBM_SRC_DIR}/webm_parser/src/element_parser.h"
181    "${LIBWEBM_SRC_DIR}/webm_parser/src/file_reader.cc"
182    "${LIBWEBM_SRC_DIR}/webm_parser/src/float_parser.cc"
183    "${LIBWEBM_SRC_DIR}/webm_parser/src/float_parser.h"
184    "${LIBWEBM_SRC_DIR}/webm_parser/src/id_element_parser.cc"
185    "${LIBWEBM_SRC_DIR}/webm_parser/src/id_element_parser.h"
186    "${LIBWEBM_SRC_DIR}/webm_parser/src/id_parser.cc"
187    "${LIBWEBM_SRC_DIR}/webm_parser/src/id_parser.h"
188    "${LIBWEBM_SRC_DIR}/webm_parser/src/info_parser.h"
189    "${LIBWEBM_SRC_DIR}/webm_parser/src/int_parser.h"
190    "${LIBWEBM_SRC_DIR}/webm_parser/src/istream_reader.cc"
191    "${LIBWEBM_SRC_DIR}/webm_parser/src/master_parser.cc"
192    "${LIBWEBM_SRC_DIR}/webm_parser/src/master_parser.h"
193    "${LIBWEBM_SRC_DIR}/webm_parser/src/master_value_parser.h"
194    "${LIBWEBM_SRC_DIR}/webm_parser/src/mastering_metadata_parser.h"
195    "${LIBWEBM_SRC_DIR}/webm_parser/src/parser.h"
196    "${LIBWEBM_SRC_DIR}/webm_parser/src/parser_utils.cc"
197    "${LIBWEBM_SRC_DIR}/webm_parser/src/parser_utils.h"
198    "${LIBWEBM_SRC_DIR}/webm_parser/src/projection_parser.h"
199    "${LIBWEBM_SRC_DIR}/webm_parser/src/recursive_parser.h"
200    "${LIBWEBM_SRC_DIR}/webm_parser/src/seek_head_parser.h"
201    "${LIBWEBM_SRC_DIR}/webm_parser/src/seek_parser.h"
202    "${LIBWEBM_SRC_DIR}/webm_parser/src/segment_parser.cc"
203    "${LIBWEBM_SRC_DIR}/webm_parser/src/segment_parser.h"
204    "${LIBWEBM_SRC_DIR}/webm_parser/src/simple_tag_parser.h"
205    "${LIBWEBM_SRC_DIR}/webm_parser/src/size_parser.cc"
206    "${LIBWEBM_SRC_DIR}/webm_parser/src/size_parser.h"
207    "${LIBWEBM_SRC_DIR}/webm_parser/src/skip_callback.h"
208    "${LIBWEBM_SRC_DIR}/webm_parser/src/skip_parser.cc"
209    "${LIBWEBM_SRC_DIR}/webm_parser/src/skip_parser.h"
210    "${LIBWEBM_SRC_DIR}/webm_parser/src/slices_parser.h"
211    "${LIBWEBM_SRC_DIR}/webm_parser/src/tag_parser.h"
212    "${LIBWEBM_SRC_DIR}/webm_parser/src/tags_parser.h"
213    "${LIBWEBM_SRC_DIR}/webm_parser/src/targets_parser.h"
214    "${LIBWEBM_SRC_DIR}/webm_parser/src/time_slice_parser.h"
215    "${LIBWEBM_SRC_DIR}/webm_parser/src/track_entry_parser.h"
216    "${LIBWEBM_SRC_DIR}/webm_parser/src/tracks_parser.h"
217    "${LIBWEBM_SRC_DIR}/webm_parser/src/unknown_parser.cc"
218    "${LIBWEBM_SRC_DIR}/webm_parser/src/unknown_parser.h"
219    "${LIBWEBM_SRC_DIR}/webm_parser/src/var_int_parser.cc"
220    "${LIBWEBM_SRC_DIR}/webm_parser/src/var_int_parser.h"
221    "${LIBWEBM_SRC_DIR}/webm_parser/src/video_parser.h"
222    "${LIBWEBM_SRC_DIR}/webm_parser/src/virtual_block_parser.cc"
223    "${LIBWEBM_SRC_DIR}/webm_parser/src/virtual_block_parser.h"
224    "${LIBWEBM_SRC_DIR}/webm_parser/src/void_parser.cc"
225    "${LIBWEBM_SRC_DIR}/webm_parser/src/void_parser.h"
226    "${LIBWEBM_SRC_DIR}/webm_parser/src/webm_parser.cc")
227
228set(webm_parser_demo_sources "${LIBWEBM_SRC_DIR}/webm_parser/demo/demo.cc")
229set(webm_parser_tests_sources
230    "${LIBWEBM_SRC_DIR}/webm_parser/tests/audio_parser_test.cc"
231    "${LIBWEBM_SRC_DIR}/webm_parser/tests/bit_utils_test.cc"
232    "${LIBWEBM_SRC_DIR}/webm_parser/tests/block_additions_parser_test.cc"
233    "${LIBWEBM_SRC_DIR}/webm_parser/tests/block_group_parser_test.cc"
234    "${LIBWEBM_SRC_DIR}/webm_parser/tests/block_header_parser_test.cc"
235    "${LIBWEBM_SRC_DIR}/webm_parser/tests/block_more_parser_test.cc"
236    "${LIBWEBM_SRC_DIR}/webm_parser/tests/block_parser_test.cc"
237    "${LIBWEBM_SRC_DIR}/webm_parser/tests/bool_parser_test.cc"
238    "${LIBWEBM_SRC_DIR}/webm_parser/tests/buffer_reader_test.cc"
239    "${LIBWEBM_SRC_DIR}/webm_parser/tests/byte_parser_test.cc"
240    "${LIBWEBM_SRC_DIR}/webm_parser/tests/callback_test.cc"
241    "${LIBWEBM_SRC_DIR}/webm_parser/tests/chapter_atom_parser_test.cc"
242    "${LIBWEBM_SRC_DIR}/webm_parser/tests/chapter_display_parser_test.cc"
243    "${LIBWEBM_SRC_DIR}/webm_parser/tests/chapters_parser_test.cc"
244    "${LIBWEBM_SRC_DIR}/webm_parser/tests/cluster_parser_test.cc"
245    "${LIBWEBM_SRC_DIR}/webm_parser/tests/colour_parser_test.cc"
246    "${LIBWEBM_SRC_DIR}/webm_parser/tests/content_enc_aes_settings_parser_test.cc"
247    "${LIBWEBM_SRC_DIR}/webm_parser/tests/content_encoding_parser_test.cc"
248    "${LIBWEBM_SRC_DIR}/webm_parser/tests/content_encodings_parser_test.cc"
249    "${LIBWEBM_SRC_DIR}/webm_parser/tests/content_encryption_parser_test.cc"
250    "${LIBWEBM_SRC_DIR}/webm_parser/tests/cue_point_parser_test.cc"
251    "${LIBWEBM_SRC_DIR}/webm_parser/tests/cue_track_positions_parser_test.cc"
252    "${LIBWEBM_SRC_DIR}/webm_parser/tests/cues_parser_test.cc"
253    "${LIBWEBM_SRC_DIR}/webm_parser/tests/date_parser_test.cc"
254    "${LIBWEBM_SRC_DIR}/webm_parser/tests/ebml_parser_test.cc"
255    "${LIBWEBM_SRC_DIR}/webm_parser/tests/edition_entry_parser_test.cc"
256    "${LIBWEBM_SRC_DIR}/webm_parser/tests/element_test.cc"
257    "${LIBWEBM_SRC_DIR}/webm_parser/tests/float_parser_test.cc"
258    "${LIBWEBM_SRC_DIR}/webm_parser/tests/id_element_parser_test.cc"
259    "${LIBWEBM_SRC_DIR}/webm_parser/tests/id_parser_test.cc"
260    "${LIBWEBM_SRC_DIR}/webm_parser/tests/info_parser_test.cc"
261    "${LIBWEBM_SRC_DIR}/webm_parser/tests/int_parser_test.cc"
262    "${LIBWEBM_SRC_DIR}/webm_parser/tests/istream_reader_test.cc"
263    "${LIBWEBM_SRC_DIR}/webm_parser/tests/limited_reader_test.cc"
264    "${LIBWEBM_SRC_DIR}/webm_parser/tests/master_parser_test.cc"
265    "${LIBWEBM_SRC_DIR}/webm_parser/tests/master_value_parser_test.cc"
266    "${LIBWEBM_SRC_DIR}/webm_parser/tests/mastering_metadata_parser_test.cc"
267    "${LIBWEBM_SRC_DIR}/webm_parser/tests/parser_utils_test.cc"
268    "${LIBWEBM_SRC_DIR}/webm_parser/tests/projection_parser_test.cc"
269    "${LIBWEBM_SRC_DIR}/webm_parser/tests/recursive_parser_test.cc"
270    "${LIBWEBM_SRC_DIR}/webm_parser/tests/seek_head_parser_test.cc"
271    "${LIBWEBM_SRC_DIR}/webm_parser/tests/seek_parser_test.cc"
272    "${LIBWEBM_SRC_DIR}/webm_parser/tests/segment_parser_test.cc"
273    "${LIBWEBM_SRC_DIR}/webm_parser/tests/simple_tag_parser_test.cc"
274    "${LIBWEBM_SRC_DIR}/webm_parser/tests/size_parser_test.cc"
275    "${LIBWEBM_SRC_DIR}/webm_parser/tests/skip_parser_test.cc"
276    "${LIBWEBM_SRC_DIR}/webm_parser/tests/slices_parser_test.cc"
277    "${LIBWEBM_SRC_DIR}/webm_parser/tests/tag_parser_test.cc"
278    "${LIBWEBM_SRC_DIR}/webm_parser/tests/tags_parser_test.cc"
279    "${LIBWEBM_SRC_DIR}/webm_parser/tests/targets_parser_test.cc"
280    "${LIBWEBM_SRC_DIR}/webm_parser/tests/time_slice_parser_test.cc"
281    "${LIBWEBM_SRC_DIR}/webm_parser/tests/track_entry_parser_test.cc"
282    "${LIBWEBM_SRC_DIR}/webm_parser/tests/tracks_parser_test.cc"
283    "${LIBWEBM_SRC_DIR}/webm_parser/tests/unknown_parser_test.cc"
284    "${LIBWEBM_SRC_DIR}/webm_parser/tests/var_int_parser_test.cc"
285    "${LIBWEBM_SRC_DIR}/webm_parser/tests/video_parser_test.cc"
286    "${LIBWEBM_SRC_DIR}/webm_parser/tests/virtual_block_parser_test.cc"
287    "${LIBWEBM_SRC_DIR}/webm_parser/tests/void_parser_test.cc"
288    "${LIBWEBM_SRC_DIR}/webm_parser/tests/webm_parser_test.cc"
289    "${LIBWEBM_SRC_DIR}/webm_parser/test_utils/element_parser_test.h"
290    "${LIBWEBM_SRC_DIR}/webm_parser/test_utils/limited_reader.cc"
291    "${LIBWEBM_SRC_DIR}/webm_parser/test_utils/limited_reader.h"
292    "${LIBWEBM_SRC_DIR}/webm_parser/test_utils/mock_callback.h"
293    "${LIBWEBM_SRC_DIR}/webm_parser/test_utils/parser_test.h"
294    "${LIBWEBM_SRC_DIR}/webm_parser/tests/webm_parser_tests.cc")
295
296set(webm_info_sources
297    "${LIBWEBM_SRC_DIR}/common/indent.cc"
298    "${LIBWEBM_SRC_DIR}/common/indent.h"
299    "${LIBWEBM_SRC_DIR}/common/vp9_header_parser.cc"
300    "${LIBWEBM_SRC_DIR}/common/vp9_header_parser.h"
301    "${LIBWEBM_SRC_DIR}/common/vp9_level_stats.cc"
302    "${LIBWEBM_SRC_DIR}/common/vp9_level_stats.h"
303    "${LIBWEBM_SRC_DIR}/common/webm_constants.h"
304    "${LIBWEBM_SRC_DIR}/common/webm_endian.cc"
305    "${LIBWEBM_SRC_DIR}/common/webm_endian.h"
306    "${LIBWEBM_SRC_DIR}/webm_info.cc")
307
308set(webmts_sources
309    "${LIBWEBM_SRC_DIR}/common/libwebm_util.cc"
310    "${LIBWEBM_SRC_DIR}/common/libwebm_util.h"
311    "${LIBWEBM_SRC_DIR}/common/video_frame.cc"
312    "${LIBWEBM_SRC_DIR}/common/video_frame.h"
313    "${LIBWEBM_SRC_DIR}/m2ts/vpxpes2ts.cc"
314    "${LIBWEBM_SRC_DIR}/m2ts/vpxpes2ts.h"
315    "${LIBWEBM_SRC_DIR}/m2ts/vpxpes_parser.cc"
316    "${LIBWEBM_SRC_DIR}/m2ts/vpxpes_parser.h"
317    "${LIBWEBM_SRC_DIR}/m2ts/webm2pes.cc"
318    "${LIBWEBM_SRC_DIR}/m2ts/webm2pes.h")
319
320set(webm2pes_sources "${LIBWEBM_SRC_DIR}/m2ts/webm2pes_main.cc")
321set(webm2pes_tests_sources
322    "${LIBWEBM_SRC_DIR}/testing/test_util.cc"
323    "${LIBWEBM_SRC_DIR}/testing/test_util.h"
324    "${LIBWEBM_SRC_DIR}/testing/video_frame_tests.cc"
325    "${LIBWEBM_SRC_DIR}/m2ts/tests/webm2pes_tests.cc")
326set(webm2ts_sources "${LIBWEBM_SRC_DIR}/m2ts/vpxpes2ts_main.cc")
327
328set(webvtt_common_headers "${LIBWEBM_SRC_DIR}/webvtt/vttreader.h"
329                          "${LIBWEBM_SRC_DIR}/webvtt/webvttparser.h")
330
331set(webvtt_common_sources
332    ${webvtt_common_headers} "${LIBWEBM_SRC_DIR}/webvtt/vttreader.cc"
333    "${LIBWEBM_SRC_DIR}/webvtt/webvttparser.cc")
334
335set(vttdemux_sources ${webvtt_common_sources} "${LIBWEBM_SRC_DIR}/vttdemux.cc")
336
337# Targets.
338add_library(mkvmuxer OBJECT ${mkvmuxer_sources})
339add_library(mkvparser OBJECT ${mkvparser_sources})
340add_library(webvtt_common OBJECT ${webvtt_common_sources})
341
342add_library(webm ${libwebm_common_sources} $<TARGET_OBJECTS:mkvmuxer>
343                 $<TARGET_OBJECTS:mkvparser>)
344
345if(ENABLE_SAMPLE_PROGRAMS)
346  add_executable(mkvparser_sample ${mkvparser_sample_sources})
347  target_link_libraries(mkvparser_sample LINK_PUBLIC webm)
348
349  add_executable(mkvmuxer_sample ${mkvmuxer_sample_sources}
350                                 $<TARGET_OBJECTS:webvtt_common>)
351  target_link_libraries(mkvmuxer_sample LINK_PUBLIC webm)
352
353  add_executable(dumpvtt ${dumpvtt_sources} $<TARGET_OBJECTS:webvtt_common>)
354  target_link_libraries(dumpvtt LINK_PUBLIC webm)
355
356  add_executable(vttdemux ${vttdemux_sources})
357  target_link_libraries(vttdemux LINK_PUBLIC webm)
358endif()
359
360if(ENABLE_WEBMINFO)
361  add_executable(webm_info ${webm_info_sources})
362  target_link_libraries(webm_info LINK_PUBLIC webm)
363endif()
364
365if(ENABLE_WEBM_PARSER)
366  include_directories(webm_parser webm_parser/include)
367  add_library(webm_parser OBJECT ${webm_parser_sources})
368  target_sources(webm PUBLIC $<TARGET_OBJECTS:webm_parser>)
369
370  add_executable(webm_parser_demo ${webm_parser_demo_sources})
371  target_link_libraries(webm_parser_demo LINK_PUBLIC webm)
372endif()
373
374if(ENABLE_WEBMTS)
375  add_library(webmts OBJECT ${webmts_sources})
376
377  add_executable(webm2pes ${webm2pes_sources} $<TARGET_OBJECTS:webmts>)
378  target_link_libraries(webm2pes LINK_PUBLIC webm)
379
380  add_executable(webm2ts ${webm2ts_sources} $<TARGET_OBJECTS:webmts>)
381  target_link_libraries(webm2ts LINK_PUBLIC webm)
382endif()
383
384if(ENABLE_TESTS)
385  set(GTEST_SRC_DIR
386      "${LIBWEBM_SRC_DIR}/../googletest"
387      CACHE PATH "Path to Googletest git repository.")
388  # This directory is where libwebm will build googletest dependencies.
389  set(GTEST_BUILD_DIR "${CMAKE_BINARY_DIR}/googletest_build")
390
391  if(LIBWEBM_DISABLE_GTEST_CMAKE)
392    add_library(gtest STATIC "${GTEST_SRC_DIR}/googletest/src/gtest-all.cc")
393    include_directories("${GTEST_SRC_DIR}/googletest")
394  else()
395    add_subdirectory("${GTEST_SRC_DIR}" "${GTEST_BUILD_DIR}")
396  endif()
397  include_directories("${GTEST_SRC_DIR}/googletest/include")
398
399  add_executable(mkvmuxer_tests ${mkvmuxer_tests_sources})
400  target_link_libraries(mkvmuxer_tests LINK_PUBLIC gtest webm)
401
402  add_executable(mkvparser_tests ${mkvparser_tests_sources})
403  target_link_libraries(mkvparser_tests LINK_PUBLIC gtest webm)
404
405  add_executable(vp9_header_parser_tests ${vp9_header_parser_tests_sources})
406  target_link_libraries(vp9_header_parser_tests LINK_PUBLIC gtest webm)
407
408  add_executable(vp9_level_stats_tests ${vp9_level_stats_tests_sources})
409  target_link_libraries(vp9_level_stats_tests LINK_PUBLIC gtest webm)
410
411  if(ENABLE_WEBMTS)
412    add_executable(webm2pes_tests ${webm2pes_tests_sources}
413                                  $<TARGET_OBJECTS:webmts>)
414    target_link_libraries(webm2pes_tests LINK_PUBLIC gtest webm)
415  endif()
416
417  if(ENABLE_WEBM_PARSER)
418    include_directories("${GTEST_SRC_DIR}/googlemock/include")
419    add_executable(webm_parser_tests ${webm_parser_tests_sources})
420    target_link_libraries(webm_parser_tests LINK_PUBLIC gmock gtest webm)
421  endif()
422endif()
423
424# Include-what-you-use.
425if(ENABLE_IWYU)
426  # Make sure all the tools necessary for IWYU are present.
427  find_program(iwyu_path NAMES include-what-you-use)
428  find_program(iwyu_tool_path NAMES iwyu_tool.py)
429
430  # Some odd behavior on cmake's part: PYTHON_EXECUTABLE and PYTHON_VERSION_*
431  # are set by cmake when it does its internal python check, but
432  # PYTHONINTERP_FOUND is empty without explicitly looking for it.
433  find_package(PythonInterp)
434
435  if(iwyu_path
436     AND iwyu_tool_path
437     AND PYTHONINTERP_FOUND)
438    # Enable compilation command export (needed for iwyu_tool.py)
439    set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
440
441    # Add a custom target to run iwyu across all targets.
442    add_custom_target(
443      iwyu ALL
444      COMMAND "${PYTHON_EXECUTABLE}" "${iwyu_tool_path}" -p
445              "${CMAKE_BINARY_DIR}"
446      COMMENT "Running include-what-you-use..."
447      VERBATIM)
448  else()
449    message(STATUS "Ignoring ENABLE_IWYU because reasons:")
450    message(STATUS "  iwyu_path=" ${iwyu_path})
451    message(STATUS "  iwyu_tool_path=" ${iwyu_tool_path})
452    message(STATUS "  PYTHONINTERP_FOUND=" ${PYTHONINTERP_FOUND})
453    message(STATUS "  See README.libwebm for more information.")
454  endif()
455endif()
456
457# webm_parser headers are rooted at webm/.
458set_target_properties(webm PROPERTIES PUBLIC_HEADER
459                                      "${webm_parser_public_headers}")
460install(
461  TARGETS webm
462  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
463  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
464  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
465  PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webm)
466
467# Install common headers into a subdirectory to avoid breaking nested includes.
468install(FILES ${libwebm_common_public_headers}
469        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webm/common)
470# mkvmuxer and mkvparser headers are referenced with their prefix.
471install(FILES ${mkvmuxer_public_headers}
472        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webm/mkvmuxer)
473install(FILES ${mkvparser_public_headers}
474        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/webm/mkvparser)
475