Add sse2/ssse3 intra predictors for 16x4
[aom.git] / CMakeLists.txt
blob1a33bc965e3d8288ff35b5be4e277076eff4c075
1 ##
2 ## Copyright (c) 2016, Alliance for Open Media. All rights reserved
3 ##
4 ## This source code is subject to the terms of the BSD 2 Clause License and
5 ## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6 ## was not distributed with this source code in the LICENSE file, you can
7 ## obtain it at www.aomedia.org/license/software. If the Alliance for Open
8 ## Media Patent License 1.0 was not distributed with this source code in the
9 ## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
11 cmake_minimum_required(VERSION 3.5)
13 if (NOT EMSCRIPTEN)
14   if (NOT CMAKE_BUILD_TYPE)
15     set(CMAKE_BUILD_TYPE "Release" CACHE
16       "Build type: Debug, Release, RelWithDebInfo or MinSizeRel" STRING FORCE)
17   endif ()
18 endif ()
20 option(ENABLE_CCACHE "Enable ccache support." OFF)
21 option(ENABLE_DISTCC "Enable distcc support." OFF)
22 option(ENABLE_DOCS "Enable documentation generation (doxygen required)." ON)
23 option(ENABLE_EXAMPLES "Enables build of example code." ON)
24 option(ENABLE_GOMA "Enable goma support." OFF)
25 option(ENABLE_IDE_TEST_HOSTING
26        "Enables running tests within IDEs like Visual Studio and Xcode." OFF)
27 option(ENABLE_NASM "Use nasm instead of yasm for x86 assembly." OFF)
28 option(ENABLE_TOOLS "Enable applications in tools sub directory." ON)
29 option(ENABLE_WERROR "Converts warnings to errors at compile time." OFF)
31 # ARM assembly/intrinsics flags.
32 option(ENABLE_NEON "Enables NEON optimizations on ARM targets." ON)
33 option(ENABLE_NEON_ASM "Enables NEON ASM optimizations on ARM targets." ON)
35 # MIPS assembly/intrinsics flags.
36 option(ENABLE_DSPR2 "Enables DSPR2 optimizations on MIPS targets." OFF)
37 option(ENABLE_MSA "Enables MSA optimizations on MIPS targets." OFF)
39 # VSX intrinsics flags.
40 option(ENABLE_VSX "Enables VSX optimizations on PowerPC targets." ON)
42 # x86/x86_64 assembly/intrinsics flags.
43 option(ENABLE_MMX "Enables MMX optimizations on x86/x86_64 targets." ON)
44 option(ENABLE_SSE "Enables SSE optimizations on x86/x86_64 targets." ON)
45 option(ENABLE_SSE2 "Enables SSE2 optimizations on x86/x86_64 targets." ON)
46 option(ENABLE_SSE3 "Enables SSE3 optimizations on x86/x86_64 targets." ON)
47 option(ENABLE_SSSE3 "Enables SSSE3 optimizations on x86/x86_64 targets." ON)
48 option(ENABLE_SSE4_1 "Enables SSE4_1 optimizations on x86/x86_64 targets." ON)
49 option(ENABLE_SSE4_2 "Enables SSE4_2 optimizations on x86/x86_64 targets." ON)
50 option(ENABLE_AVX "Enables AVX optimizations on x86/x86_64 targets." ON)
51 option(ENABLE_AVX2 "Enables AVX2 optimizations on x86/x86_64 targets." ON)
53 # $BUILD_SHARED_LIBS is a CMake built-in-- it's listed here for visibility.
54 option(BUILD_SHARED_LIBS "CMake should generate a shared library build." OFF)
56 project(AOM C CXX)
58 set(AOM_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
59 set(AOM_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")
60 set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH
61     "Installation path of includes")
62 set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH
63     "Installation path of libraries")
65 if ("${AOM_ROOT}" STREQUAL "${AOM_CONFIG_DIR}")
66   message(FATAL_ERROR
67           "Building from within the aom source tree is not supported.\n"
68           "Hint: Run these commands\n"
69           "$ rm -rf CMakeCache.txt CMakeFiles\n"
70           "$ mkdir -p ../aom_build\n"
71           "$ cd ../aom_build\n"
72           "And re-run CMake from the aom_build directory.")
73 endif ()
75 include("${AOM_ROOT}/build/cmake/aom_configure.cmake")
76 include("${AOM_ROOT}/aom_dsp/aom_dsp.cmake")
77 include("${AOM_ROOT}/aom_mem/aom_mem.cmake")
78 include("${AOM_ROOT}/aom_ports/aom_ports.cmake")
79 include("${AOM_ROOT}/aom_scale/aom_scale.cmake")
80 include("${AOM_ROOT}/aom_util/aom_util.cmake")
81 include("${AOM_ROOT}/av1/av1.cmake")
82 include("${AOM_ROOT}/test/test.cmake")
83 include("${AOM_ROOT}/build/cmake/sanitizers.cmake")
84 include("${AOM_ROOT}/build/cmake/util.cmake")
86 set(AOM_RTCD_SOURCES
87     "${AOM_CONFIG_DIR}/aom_dsp_rtcd.h"
88     "${AOM_CONFIG_DIR}/aom_scale_rtcd.h"
89     "${AOM_CONFIG_DIR}/av1_rtcd.h"
90     "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd_defs.pl"
91     "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd.c"
92     "${AOM_ROOT}/aom_scale/aom_scale_rtcd.pl"
93     "${AOM_ROOT}/aom_scale/aom_scale_rtcd.c"
94     "${AOM_ROOT}/av1/common/av1_rtcd_defs.pl"
95     "${AOM_ROOT}/av1/common/av1_rtcd.c"
96     "${AOM_ROOT}/build/make/rtcd.pl")
98 # TODO(tomfinegan): Use libwebm's cmake support directly.
99 set(AOM_LIBWEBM_SOURCES
100     "${AOM_ROOT}/third_party/libwebm/common/hdr_util.cc"
101     "${AOM_ROOT}/third_party/libwebm/common/hdr_util.h"
102     "${AOM_ROOT}/third_party/libwebm/common/webmids.h"
103     "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvmuxer.cc"
104     "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvmuxer.h"
105     "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvmuxertypes.h"
106     "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvmuxerutil.cc"
107     "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvmuxerutil.h"
108     "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvwriter.cc"
109     "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvwriter.h"
110     "${AOM_ROOT}/third_party/libwebm/mkvparser/mkvparser.cc"
111     "${AOM_ROOT}/third_party/libwebm/mkvparser/mkvparser.h"
112     "${AOM_ROOT}/third_party/libwebm/mkvparser/mkvreader.cc"
113     "${AOM_ROOT}/third_party/libwebm/mkvparser/mkvreader.h")
115 set(AOM_LIBYUV_SOURCES
116     "${AOM_ROOT}/third_party/libyuv/include/libyuv/basic_types.h"
117     "${AOM_ROOT}/third_party/libyuv/include/libyuv/convert.h"
118     "${AOM_ROOT}/third_party/libyuv/include/libyuv/convert_argb.h"
119     "${AOM_ROOT}/third_party/libyuv/include/libyuv/convert_from.h"
120     "${AOM_ROOT}/third_party/libyuv/include/libyuv/cpu_id.h"
121     "${AOM_ROOT}/third_party/libyuv/include/libyuv/planar_functions.h"
122     "${AOM_ROOT}/third_party/libyuv/include/libyuv/rotate.h"
123     "${AOM_ROOT}/third_party/libyuv/include/libyuv/row.h"
124     "${AOM_ROOT}/third_party/libyuv/include/libyuv/scale.h"
125     "${AOM_ROOT}/third_party/libyuv/include/libyuv/scale_row.h"
126     "${AOM_ROOT}/third_party/libyuv/source/cpu_id.cc"
127     "${AOM_ROOT}/third_party/libyuv/source/planar_functions.cc"
128     "${AOM_ROOT}/third_party/libyuv/source/row_any.cc"
129     "${AOM_ROOT}/third_party/libyuv/source/row_common.cc"
130     "${AOM_ROOT}/third_party/libyuv/source/row_gcc.cc"
131     "${AOM_ROOT}/third_party/libyuv/source/row_mips.cc"
132     "${AOM_ROOT}/third_party/libyuv/source/row_neon.cc"
133     "${AOM_ROOT}/third_party/libyuv/source/row_neon64.cc"
134     "${AOM_ROOT}/third_party/libyuv/source/row_win.cc"
135     "${AOM_ROOT}/third_party/libyuv/source/scale.cc"
136     "${AOM_ROOT}/third_party/libyuv/source/scale_any.cc"
137     "${AOM_ROOT}/third_party/libyuv/source/scale_common.cc"
138     "${AOM_ROOT}/third_party/libyuv/source/scale_gcc.cc"
139     "${AOM_ROOT}/third_party/libyuv/source/scale_mips.cc"
140     "${AOM_ROOT}/third_party/libyuv/source/scale_neon.cc"
141     "${AOM_ROOT}/third_party/libyuv/source/scale_neon64.cc"
142     "${AOM_ROOT}/third_party/libyuv/source/scale_win.cc")
144 set(AOM_SOURCES
145     "${AOM_CONFIG_DIR}/aom_config.c"
146     "${AOM_CONFIG_DIR}/aom_config.h"
147     "${AOM_ROOT}/aom/aom.h"
148     "${AOM_ROOT}/aom/aom_codec.h"
149     "${AOM_ROOT}/aom/aom_decoder.h"
150     "${AOM_ROOT}/aom/aom_encoder.h"
151     "${AOM_ROOT}/aom/aom_frame_buffer.h"
152     "${AOM_ROOT}/aom/aom_image.h"
153     "${AOM_ROOT}/aom/aom_integer.h"
154     "${AOM_ROOT}/aom/aomcx.h"
155     "${AOM_ROOT}/aom/aomdx.h"
156     "${AOM_ROOT}/aom/internal/aom_codec_internal.h"
157     "${AOM_ROOT}/aom/src/aom_codec.c"
158     "${AOM_ROOT}/aom/src/aom_decoder.c"
159     "${AOM_ROOT}/aom/src/aom_encoder.c"
160     "${AOM_ROOT}/aom/src/aom_image.c"
161     "${AOM_ROOT}/aom/src/aom_integer.c")
163 set(AOM_COMMON_APP_UTIL_SOURCES
164     "${AOM_ROOT}/args.c"
165     "${AOM_ROOT}/args.h"
166     "${AOM_ROOT}/md5_utils.c"
167     "${AOM_ROOT}/md5_utils.h"
168     "${AOM_ROOT}/tools_common.c"
169     "${AOM_ROOT}/tools_common.h"
170     "${AOM_ROOT}/video_common.h"
171     "${AOM_ROOT}/y4menc.c"
172     "${AOM_ROOT}/y4menc.h")
174 set(AOM_DECODER_APP_UTIL_SOURCES
175     "${AOM_ROOT}/ivfdec.c"
176     "${AOM_ROOT}/ivfdec.h"
177     "${AOM_ROOT}/obudec.c"
178     "${AOM_ROOT}/obudec.h"
179     "${AOM_ROOT}/video_reader.c"
180     "${AOM_ROOT}/video_reader.h")
182 set(AOM_ENCODER_APP_UTIL_SOURCES
183     "${AOM_ROOT}/ivfenc.c"
184     "${AOM_ROOT}/ivfenc.h"
185     "${AOM_ROOT}/video_writer.c"
186     "${AOM_ROOT}/video_writer.h"
187     "${AOM_ROOT}/warnings.c"
188     "${AOM_ROOT}/warnings.h"
189     "${AOM_ROOT}/y4minput.c"
190     "${AOM_ROOT}/y4minput.h"
191     "${AOM_ROOT}/examples/encoder_util.h"
192     "${AOM_ROOT}/examples/encoder_util.c")
194 set(AOM_ENCODER_STATS_SOURCES
195     "${AOM_ROOT}/aomstats.c"
196     "${AOM_ROOT}/aomstats.h"
197     "${AOM_ROOT}/rate_hist.c"
198     "${AOM_ROOT}/rate_hist.h")
200 set(AOM_PKG_CONFIG_SOURCES "${AOM_CONFIG_DIR}/aom.pc")
202 set(AOM_VERSION_SOURCES "${AOM_CONFIG_DIR}/aom_version.h")
204 set(AOM_WEBM_DECODER_SOURCES
205     "${AOM_ROOT}/webmdec.cc"
206     "${AOM_ROOT}/webmdec.h")
208 set(AOM_WEBM_ENCODER_SOURCES
209     "${AOM_ROOT}/webmenc.cc"
210     "${AOM_ROOT}/webmenc.h")
212 include_directories(${AOM_ROOT} ${AOM_CONFIG_DIR})
214 # Targets
215 add_library(aom_version ${AOM_VERSION_SOURCES})
216 add_dummy_source_file_to_target(aom_version c)
217 add_custom_command(
218   OUTPUT "${AOM_CONFIG_DIR}/aom_version.h"
219   COMMAND ${CMAKE_COMMAND}
220   ARGS -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
221     -DAOM_ROOT=${AOM_ROOT}
222     -DGIT_EXECUTABLE=${GIT_EXECUTABLE}
223     -DPERL_EXECUTABLE=${PERL_EXECUTABLE}
224     -P "${AOM_ROOT}/build/cmake/version.cmake"
225   COMMENT "Writing aom_version.h"
226   VERBATIM)
228 add_custom_target(aom_version_check
229   COMMAND ${CMAKE_COMMAND}
230     -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
231     -DAOM_ROOT=${AOM_ROOT}
232     -DGIT_EXECUTABLE=${GIT_EXECUTABLE}
233     -DPERL_EXECUTABLE=${PERL_EXECUTABLE}
234     -P "${AOM_ROOT}/build/cmake/version.cmake"
235   COMMENT "Updating version info if necessary."
236   VERBATIM)
237 add_dependencies(aom_version aom_version_check)
239 if (NOT MSVC)
240   add_library(aom_pc ${AOM_PKG_CONFIG_SOURCES})
241   add_dummy_source_file_to_target(aom_pc c)
242   add_custom_command(
243     OUTPUT "${AOM_CONFIG_DIR}/aom.pc"
244     COMMAND ${CMAKE_COMMAND}
245     ARGS -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
246       -DAOM_ROOT=${AOM_ROOT}
247       -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
248       -DCMAKE_PROJECT_NAME=${CMAKE_PROJECT_NAME}
249       -DCONFIG_MULTITHREAD=${CONFIG_MULTITHREAD}
250       -DHAVE_PTHREAD_H=${HAVE_PTHREAD_H}
251       -P "${AOM_ROOT}/build/cmake/pkg_config.cmake"
252       COMMENT "Writing aom.pc"
253       VERBATIM)
254   add_dependencies(aom_pc aom_version)
255 endif ()
257 # TODO(tomfinegan): Move rtcd target setup where it belongs for each rtcd
258 # source.
259 add_rtcd_build_step("${AOM_ROOT}/aom_dsp/aom_dsp_rtcd_defs.pl"
260                     "${AOM_CONFIG_DIR}/aom_dsp_rtcd.h"
261                     "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd.c"
262                     "aom_dsp_rtcd")
263 add_rtcd_build_step("${AOM_ROOT}/aom_scale/aom_scale_rtcd.pl"
264                     "${AOM_CONFIG_DIR}/aom_scale_rtcd.h"
265                     "${AOM_ROOT}/aom_scale/aom_scale_rtcd.c"
266                     "aom_scale_rtcd")
267 add_rtcd_build_step("${AOM_ROOT}/av1/common/av1_rtcd_defs.pl"
268                     "${AOM_CONFIG_DIR}/av1_rtcd.h"
269                     "${AOM_ROOT}/av1/common/av1_rtcd.c"
270                     "av1_rtcd")
272 add_library(aom_rtcd OBJECT ${AOM_RTCD_SOURCES})
273 add_dependencies(aom_rtcd aom_version)
275 add_library(aom_encoder_stats OBJECT ${AOM_ENCODER_STATS_SOURCES})
276 add_library(aom ${AOM_SOURCES} $<TARGET_OBJECTS:aom_rtcd>)
278 if (NOT MSVC AND NOT APPLE)
279   target_link_libraries(aom ${AOM_LIB_LINK_TYPE} m)
280 endif ()
282 # List of object and static library targets.
283 set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_rtcd aom_encoder_stats aom_mem
284     aom_scale aom)
286 # Setup dependencies.
287 setup_aom_dsp_targets()
288 setup_aom_mem_targets()
289 setup_aom_ports_targets()
290 setup_aom_util_targets()
291 setup_aom_scale_targets()
292 setup_av1_targets()
294 # Make all library targets depend on aom_rtcd to make sure it builds first.
295 foreach (aom_lib ${AOM_LIB_TARGETS})
296   if (NOT "${aom_lib}" STREQUAL "aom_rtcd")
297     add_dependencies(${aom_lib} aom_rtcd)
298   endif ()
299 endforeach ()
301 # Generate C/C++ stub files containing the function usage_exit(). Users of the
302 # aom_common_app_util library must define this function. This is a convenience
303 # to allow omission of the function from applications that might want to use
304 # other pieces of the util support without defining usage_exit().
305 file(WRITE "${AOM_CONFIG_DIR}/usage_exit.c" "void usage_exit(void) {}")
306 file(WRITE "${AOM_CONFIG_DIR}/usage_exit.cc"
307      "extern \"C\" void usage_exit(void) {}")
310 # Application and application support targets.
312 if (CONFIG_UNIT_TESTS OR ENABLE_EXAMPLES OR ENABLE_TOOLS)
313   add_library(aom_common_app_util OBJECT ${AOM_COMMON_APP_UTIL_SOURCES})
314   if (CONFIG_AV1_DECODER)
315     add_library(aom_decoder_app_util OBJECT ${AOM_DECODER_APP_UTIL_SOURCES})
316     # obudec depends on internal headers that require *rtcd.h
317     add_dependencies(aom_decoder_app_util aom_rtcd)
318   endif ()
319   if (CONFIG_AV1_ENCODER)
320     add_library(aom_encoder_app_util OBJECT ${AOM_ENCODER_APP_UTIL_SOURCES})
321   endif ()
322 endif ()
324 if (CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
325   add_executable(aomdec
326                  "${AOM_ROOT}/aomdec.c"
327                  $<TARGET_OBJECTS:aom_common_app_util>
328                  $<TARGET_OBJECTS:aom_decoder_app_util>)
329   add_executable(decode_to_md5
330                  "${AOM_ROOT}/examples/decode_to_md5.c"
331                  $<TARGET_OBJECTS:aom_common_app_util>
332                  $<TARGET_OBJECTS:aom_decoder_app_util>)
333   add_executable(decode_with_drops
334                  "${AOM_ROOT}/examples/decode_with_drops.c"
335                  $<TARGET_OBJECTS:aom_common_app_util>
336                  $<TARGET_OBJECTS:aom_decoder_app_util>)
337   add_executable(simple_decoder
338                  "${AOM_ROOT}/examples/simple_decoder.c"
339                  $<TARGET_OBJECTS:aom_common_app_util>
340                  $<TARGET_OBJECTS:aom_decoder_app_util>)
341   add_executable(scalable_decoder
342                  "${AOM_ROOT}/examples/scalable_decoder.c"
343                  $<TARGET_OBJECTS:aom_common_app_util>
344                  $<TARGET_OBJECTS:aom_decoder_app_util>)
345   
346   if (CONFIG_ANALYZER)
347     add_executable(analyzer
348                    "${AOM_ROOT}/examples/analyzer.cc"
349                    $<TARGET_OBJECTS:aom_common_app_util>
350                    $<TARGET_OBJECTS:aom_decoder_app_util>)
351     target_link_libraries(analyzer
352                           ${AOM_LIB_LINK_TYPE} ${wxWidgets_LIBRARIES})
353     set(AOM_APP_TARGETS ${AOM_APP_TARGETS} analyzer)
354     set(AOM_DECODER_EXAMPLE_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS} analyzer)
355   endif ()
357   if (CONFIG_INSPECTION)
358     add_executable(inspect
359                    "${AOM_ROOT}/examples/inspect.c"
360                    $<TARGET_OBJECTS:aom_common_app_util>
361                    $<TARGET_OBJECTS:aom_decoder_app_util>)
362     set(AOM_DECODER_EXAMPLE_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS} inspect)
364     if (EMSCRIPTEN)
365       add_preproc_definition(_POSIX_SOURCE)
366       append_link_flag_to_target("inspect" "-s TOTAL_MEMORY=402653184")
367       append_link_flag_to_target("inspect" "-s MODULARIZE=1")
368       append_link_flag_to_target("inspect"
369                                  "-s EXPORT_NAME=\"\'DecoderModule\'\"")
370       append_link_flag_to_target("inspect" "--memory-init-file 0")
372       if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
373         # Default to -O3 when no build type specified.
374         append_compiler_flag("-O3")
375       endif ()
377       em_link_post_js(inspect "${AOM_ROOT}/tools/inspect-post.js")
378     endif ()
379   endif ()
381   # Maintain a list of decoder example targets.
382   set(AOM_DECODER_EXAMPLE_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS}
383       aomdec decode_to_md5 decode_with_drops simple_decoder)
385     set(AOM_DECODER_EXAMPLE_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS}
386         scalable_decoder)
387   
388   # Add decoder examples to the app targets list.
389   set(AOM_APP_TARGETS ${AOM_APP_TARGETS} ${AOM_DECODER_EXAMPLE_TARGETS})
390 endif ()
392 if (CONFIG_AV1_ENCODER)
393   if (ENABLE_EXAMPLES)
394     add_executable(aomenc
395                    "${AOM_ROOT}/aomenc.c"
396                    $<TARGET_OBJECTS:aom_common_app_util>
397                    $<TARGET_OBJECTS:aom_encoder_app_util>
398                    $<TARGET_OBJECTS:aom_encoder_stats>)
399     add_executable(lossless_encoder
400                    "${AOM_ROOT}/examples/lossless_encoder.c"
401                    $<TARGET_OBJECTS:aom_common_app_util>
402                    $<TARGET_OBJECTS:aom_encoder_app_util>)
403     add_executable(set_maps
404                    "${AOM_ROOT}/examples/set_maps.c"
405                    $<TARGET_OBJECTS:aom_common_app_util>
406                    $<TARGET_OBJECTS:aom_encoder_app_util>)
407     add_executable(simple_encoder
408                    "${AOM_ROOT}/examples/simple_encoder.c"
409                    $<TARGET_OBJECTS:aom_common_app_util>
410                    $<TARGET_OBJECTS:aom_encoder_app_util>)
411     add_executable(twopass_encoder
412                    "${AOM_ROOT}/examples/twopass_encoder.c"
413                    $<TARGET_OBJECTS:aom_common_app_util>
414                    $<TARGET_OBJECTS:aom_encoder_app_util>)
415     add_executable(noise_model
416                    "${AOM_ROOT}/examples/noise_model.c"
417                    $<TARGET_OBJECTS:aom_common_app_util>
418                    $<TARGET_OBJECTS:aom_encoder_app_util>)
419     add_executable(scalable_encoder
420                    "${AOM_ROOT}/examples/scalable_encoder.c"
421                    $<TARGET_OBJECTS:aom_common_app_util>
422                    $<TARGET_OBJECTS:aom_encoder_app_util>)
424     # Maintain a list of encoder example targets.
425     set(AOM_ENCODER_EXAMPLE_TARGETS
426         aomenc lossless_encoder noise_model set_maps simple_encoder twopass_encoder)
428       set(AOM_ENCODER_EXAMPLE_TARGETS ${AOM_ENCODER_EXAMPLE_TARGETS}
429           scalable_encoder)
431   endif ()
433   if (ENABLE_TOOLS)
434     if (CONFIG_ENTROPY_STATS AND NOT BUILD_SHARED_LIBS)
435       # TODO(tomfinegan): Sort out why a simple link command with
436       # aom_entropy_optimizer.c won't work on macos, but dragging in all the
437       # helper machinery allows the link to succeed.
438       add_executable(aom_entropy_optimizer
439                      "${AOM_CONFIG_DIR}/usage_exit.c"
440                      "${AOM_ROOT}/tools/aom_entropy_optimizer.c"
441                      $<TARGET_OBJECTS:aom_common_app_util>
442                      $<TARGET_OBJECTS:aom_encoder_app_util>)
444       # Maintain a list of encoder tool targets.
445       set(AOM_ENCODER_TOOL_TARGETS
446           ${AOM_ENCODER_TOOL_TARGETS} aom_entropy_optimizer)
447     endif ()
448   endif ()
450   # Add encoder examples and tools to the targets list.
451   set(AOM_APP_TARGETS ${AOM_APP_TARGETS}
452       ${AOM_ENCODER_EXAMPLE_TARGETS} ${AOM_ENCODER_TOOL_TARGETS})
453 endif ()
455 if (ENABLE_EXAMPLES)
456   # Maintain a separate variable listing only the examples to facilitate
457   # installation of example programs into an examples sub directory of
458   # $AOM_DIST_DIR/bin when building the dist target.
459   set(AOM_EXAMPLE_TARGETS
460       ${AOM_DECODER_EXAMPLE_TARGETS} ${AOM_ENCODER_EXAMPLE_TARGETS})
461 endif ()
463 if (ENABLE_TOOLS)
464   if (CONFIG_AV1_DECODER)
465     require_cxx_flag_nomsvc("-std=c++11" NO)
466     add_executable(dump_obu
467                    "${AOM_CONFIG_DIR}/usage_exit.cc"
468                    "${AOM_ROOT}/tools/dump_obu.cc"
469                    "${AOM_ROOT}/tools/obu_parser.cc"
470                    "${AOM_ROOT}/tools/obu_parser.h"
471                    $<TARGET_OBJECTS:aom_common_app_util>
472                    $<TARGET_OBJECTS:aom_decoder_app_util>)
474     list(APPEND AOM_TOOL_TARGETS dump_obu)
475     list(APPEND AOM_APP_TARGETS dump_obu)
477     if (NOT MSVC)
478       target_compile_options(dump_obu PUBLIC -std=c++11)
479       # TODO(tomfinegan): This can go once the GCC pragma in libwebm is updated
480       # to silence the auto_ptr warnings for GCC >= v4.
481       target_compile_options(dump_obu PUBLIC -Wno-deprecated-declarations)
482     endif ()
484     # Maintain a separate variable listing only the examples to facilitate
485     # installation of example programs into an tools sub directory of
486     # $AOM_DIST_DIR/bin when building the dist target.
487     list(APPEND AOM_TOOL_TARGETS
488          ${AOM_DECODER_TOOL_TARGETS} ${AOM_ENCODER_TOOL_TARGETS})
489   endif ()
490 endif ()
492 if (ENABLE_EXAMPLES AND CONFIG_AV1_DECODER AND CONFIG_AV1_ENCODER)
493   add_executable(aom_cx_set_ref
494                  "${AOM_ROOT}/examples/aom_cx_set_ref.c"
495                  $<TARGET_OBJECTS:aom_common_app_util>
496                  $<TARGET_OBJECTS:aom_encoder_app_util>)
497   set(AOM_EXAMPLE_TARGETS ${AOM_EXAMPLE_TARGETS} aom_cx_set_ref)
498   set(AOM_APP_TARGETS ${AOM_APP_TARGETS} aom_cx_set_ref)
499 endif ()
501 foreach (aom_app ${AOM_APP_TARGETS})
502   target_link_libraries(${aom_app} ${AOM_LIB_LINK_TYPE} aom)
503 endforeach ()
505 if (CONFIG_UNIT_TESTS OR ENABLE_EXAMPLES OR ENABLE_TOOLS)
506   if (CONFIG_LIBYUV)
507     add_library(yuv OBJECT ${AOM_LIBYUV_SOURCES})
508     if (NOT MSVC)
509       target_compile_options(yuv PRIVATE -Wno-unused-parameter)
510     endif ()
511     include_directories("${AOM_ROOT}/third_party/libyuv/include")
513     # Add to existing targets.
514     foreach (aom_app ${AOM_APP_TARGETS})
515       target_sources(${aom_app} PRIVATE $<TARGET_OBJECTS:yuv>)
516       set_property(TARGET ${aom_app} PROPERTY LINKER_LANGUAGE CXX)
517     endforeach ()
518   endif ()
520   if (CONFIG_WEBM_IO)
521     add_library(webm OBJECT ${AOM_LIBWEBM_SOURCES})
522     include_directories("${AOM_ROOT}/third_party/libwebm")
523     target_compile_definitions(webm PRIVATE __STDC_CONSTANT_MACROS)
524     target_compile_definitions(webm PRIVATE __STDC_LIMIT_MACROS)
526     if (NOT MSVC)
527       target_compile_options(webm PRIVATE -Wno-shadow)
528     endif ()
530     # Add to existing targets.
531     if (CONFIG_AV1_DECODER)
532       target_sources(aom_decoder_app_util PRIVATE ${AOM_WEBM_DECODER_SOURCES})
533     endif ()
535     if (CONFIG_AV1_ENCODER)
536       target_sources(aom_encoder_app_util PRIVATE ${AOM_WEBM_ENCODER_SOURCES})
537     endif ()
539     foreach (aom_app ${AOM_APP_TARGETS})
540       target_sources(${aom_app} PRIVATE $<TARGET_OBJECTS:webm>)
541       set_property(TARGET ${aom_app} PROPERTY LINKER_LANGUAGE CXX)
542      endforeach ()
543   endif ()
544 endif ()
546 if (CONFIG_UNIT_TESTS)
547   # Create test_libaom target and the targets it depends on.
548   setup_aom_test_targets()
549 endif ()
551 if (HAVE_PTHREAD_H AND CONFIG_MULTITHREAD)
552   find_package(Threads)
553   foreach (app_target ${AOM_APP_TARGETS})
554     target_link_libraries(${app_target} ${AOM_LIB_LINK_TYPE} Threads::Threads)
555   endforeach ()
556 endif ()
558 if (XCODE)
559   # TODO(tomfinegan): Make sure target has no C++ files before doing this as
560   # it's not necessary in that case.
561   if (CONFIG_LIBYUV OR CONFIG_WEBM_IO)
562     # The Xcode generator does not obey LINKER_LANGUAGE. Because of the issue
563     # what looks like a C++ file needs to be in any target that Xcode will link
564     # when the target contains a C++ dependency.
565     # Without this Xcode will try to link with the C linker, which always ends
566     # badly when a dependency actually includes C++.
567     # Note: LINKER_LANGUAGE is explicitly set to C++ for all targets touched
568     # here, it really is the Xcode generator's fault, or just a deficiency in
569     # Xcode itself.
570     foreach (aom_app ${AOM_APP_TARGETS})
571       add_dummy_source_file_to_target("${aom_app}" "cc")
572     endforeach ()
573   endif ()
574 endif ()
576 if (ENABLE_EXAMPLES AND "${CMAKE_GENERATOR}" MATCHES "Makefiles$")
577   # For historical purposes place the example binaries in the example directory.
578   file(MAKE_DIRECTORY "${AOM_CONFIG_DIR}/examples")
580   foreach (target ${AOM_EXAMPLE_TARGETS})
581     if (NOT "${target}" MATCHES "aomdec\|aomenc")
582       set_target_properties(${target} PROPERTIES
583                             RUNTIME_OUTPUT_DIRECTORY
584                             "${AOM_CONFIG_DIR}/examples")
585     endif ()
586   endforeach ()
588   if (ENABLE_TOOLS AND AOM_TOOL_TARGETS)
589     # The same expectation is true for tool targets.
590     file(MAKE_DIRECTORY "${AOM_CONFIG_DIR}/tools")
591     set_target_properties(${AOM_TOOL_TARGETS} PROPERTIES
592                           RUNTIME_OUTPUT_DIRECTORY "${AOM_CONFIG_DIR}/tools")
593   endif ()
594 endif ()
596 if (BUILD_SHARED_LIBS)
597   include("${AOM_ROOT}/build/cmake/exports.cmake")
598   setup_exports_target()
599   set_target_properties(aom PROPERTIES SOVERSION 0)
600 endif ()
602 # Handle user supplied compile and link flags last to ensure they're obeyed.
603 set_user_flags()
605 # Aomedia documentation rule.
606 if (ENABLE_DOCS)
607   include(FindDoxygen)
608   if (DOXYGEN_FOUND)
609     include("${AOM_ROOT}/docs.cmake")
610     setup_documentation_targets()
611   else ()
612     message("--- Cannot find doxygen, ENABLE_DOCS turned off.")
613     set(ENABLE_DOCS OFF)
614   endif ()
615 endif ()
617 # Aomedia install rule.
618 set(AOM_INSTALL_INCS
619     "${AOM_ROOT}/aom/aom.h"
620     "${AOM_ROOT}/aom/aom_codec.h"
621     "${AOM_ROOT}/aom/aom_frame_buffer.h"
622     "${AOM_ROOT}/aom/aom_image.h"
623     "${AOM_ROOT}/aom/aom_integer.h"
624     "${AOM_ROOT}/aom/aom.h")
626 if (CONFIG_AV1_DECODER)
627   if (ENABLE_EXAMPLES)
628     set(AOM_INSTALL_BINS ${AOM_INSTALL_BINS} aomdec)
629   endif ()
631   set(AOM_INSTALL_INCS
632       ${AOM_INSTALL_INCS}
633       "${AOM_ROOT}/aom/aom_decoder.h"
634       "${AOM_ROOT}/aom/aomdx.h")
635 endif ()
637 if (CONFIG_AV1_ENCODER)
638   if (ENABLE_EXAMPLES)
639     set(AOM_INSTALL_BINS ${AOM_INSTALL_BINS} aomenc)
640   endif ()
642   set(AOM_INSTALL_INCS
643       ${AOM_INSTALL_INCS}
644       "${AOM_ROOT}/aom/aomcx.h"
645       "${AOM_ROOT}/aom/aom_encoder.h")
646 endif ()
648 set(AOM_INSTALL_LIBS aom)
650 install(FILES ${AOM_INSTALL_INCS}
651         DESTINATION "${INCLUDE_INSTALL_DIR}/aom")
652 install(FILES "${AOM_CONFIG_DIR}/aom.pc"
653         DESTINATION "${LIB_INSTALL_DIR}/pkgconfig")
654 install(TARGETS ${AOM_INSTALL_LIBS} DESTINATION "${LIB_INSTALL_DIR}")
656 if (ENABLE_EXAMPLES)
657   install(TARGETS ${AOM_INSTALL_BINS} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
658 endif ()
660 # Aomedia dist rule.
661 if (CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
662   set(AOM_DIST_APPS ${AOM_DIST_APPS} $<TARGET_FILE:aomdec>)
663 endif ()
664 if (CONFIG_AV1_ENCODER AND ENABLE_EXAMPLES)
665   set(AOM_DIST_APPS ${AOM_DIST_APPS} $<TARGET_FILE:aomenc>)
666 endif ()
668 if (ENABLE_EXAMPLES)
669   foreach (example ${AOM_EXAMPLE_TARGETS})
670     list(APPEND AOM_DIST_EXAMPLES $<TARGET_FILE:${example}>)
671   endforeach ()
672 endif ()
674 if (ENABLE_TOOLS)
675   foreach (tool ${AOM_TOOL_TARGETS})
676     list(APPEND AOM_DIST_TOOLS $<TARGET_FILE:${tool}>)
677   endforeach ()
678 endif ()
680 if (NOT AOM_DIST_DIR)
681   set(AOM_DIST_DIR "${AOM_CONFIG_DIR}/dist")
682 endif ()
684 add_custom_target(dist
685                   COMMAND ${CMAKE_COMMAND}
686                   -DAOM_ROOT=${AOM_ROOT}
687                   -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
688                   -DAOM_DIST_DIR=${AOM_DIST_DIR}
689                   -DAOM_DIST_APPS="${AOM_DIST_APPS}"
690                   -DAOM_DIST_EXAMPLES="${AOM_DIST_EXAMPLES}"
691                   -DAOM_DIST_TOOLS="${AOM_DIST_TOOLS}"
692                   -DAOM_DIST_INCLUDES="${AOM_INSTALL_INCS}"
693                   -DAOM_DIST_LIBS=$<TARGET_FILE:aom>
694                   -DENABLE_DOCS=${ENABLE_DOCS}
695                   -P "${AOM_ROOT}/build/cmake/dist.cmake"
696                   DEPENDS ${AOM_INSTALL_BINS} ${AOM_INSTALL_LIBS}
697                   ${AOM_INSTALL_INCS} ${AOM_EXAMPLE_TARGETS}
698                   ${AOM_TOOL_TARGETS})
700 if (ENABLE_DOCS)
701   add_dependencies(dist docs)
702 endif ()
704 # Collect all variables containing libaom source files.
705 get_cmake_property(all_cmake_vars VARIABLES)
706 foreach (var ${all_cmake_vars})
707   if ("${var}" MATCHES "SOURCES$\|_INTRIN_\|_ASM_" AND NOT
708       "${var}" MATCHES "_APP_\|DOXYGEN\|LIBWEBM\|LIBYUV\|_PKG_\|TEST")
709     list(APPEND aom_source_vars ${var})
710   endif ()
711 endforeach ()
713 # Libaom_srcs.txt generation.
714 set(libaom_srcs_txt_file "${AOM_CONFIG_DIR}/libaom_srcs.txt")
715 file(WRITE "${libaom_srcs_txt_file}" "# This file is generated. DO NOT EDIT.\n")
717 # Static source file list first.
718 foreach (aom_source_var ${aom_source_vars})
719   foreach (file ${${aom_source_var}})
720     if (NOT "${file}" MATCHES "${AOM_CONFIG_DIR}")
721       string(REPLACE "${AOM_ROOT}/" "" file "${file}")
722       file(APPEND "${libaom_srcs_txt_file}" "${file}\n")
723     endif ()
724   endforeach ()
725 endforeach ()
727 file(APPEND "${libaom_srcs_txt_file}"
728      "# Files below this line are generated by the libaom build system.\n")
729 foreach (aom_source_var ${aom_source_vars})
730   foreach (file ${${aom_source_var}})
731     if ("${file}" MATCHES "${AOM_CONFIG_DIR}")
732       string(REPLACE "${AOM_CONFIG_DIR}/" "" file "${file}")
733       file(APPEND "${libaom_srcs_txt_file}" "${file}\n")
734     endif ()
735   endforeach ()
736 endforeach ()
738 # Libaom_srcs.gni generation.
739 set(libaom_srcs_gni_file "${AOM_CONFIG_DIR}/libaom_srcs.gni")
740 file(WRITE "${libaom_srcs_gni_file}" "# This file is generated. DO NOT EDIT.\n")
742 foreach (aom_source_var ${aom_source_vars})
743   if ("${${aom_source_var}}" MATCHES "${AOM_ROOT}")
744     string(TOLOWER ${aom_source_var} aom_source_var_lowercase)
745     file(APPEND "${libaom_srcs_gni_file}" "\n${aom_source_var_lowercase} = [\n")
746   endif ()
748   foreach (file ${${aom_source_var}})
749     if (NOT "${file}" MATCHES "${AOM_CONFIG_DIR}")
750       string(REPLACE "${AOM_ROOT}" "//third_party/aom/src" file "${file}")
751       file(APPEND "${libaom_srcs_gni_file}" "  \"${file}\",\n")
752     endif ()
753   endforeach ()
755   if ("${${aom_source_var}}" MATCHES "${AOM_ROOT}")
756     file(APPEND "${libaom_srcs_gni_file}" "]\n")
757   endif ()
758 endforeach ()
760 file(APPEND "${libaom_srcs_gni_file}"
761      "\n# Files below this line are generated by the libaom build system.\n")
763 foreach (aom_source_var ${aom_source_vars})
764   if ("${${aom_source_var}}" MATCHES "${AOM_CONFIG_DIR}")
765     string(TOLOWER ${aom_source_var} aom_source_var_lowercase)
766     file(APPEND "${libaom_srcs_gni_file}"
767          "\n${aom_source_var_lowercase}_gen = [\n")
768   endif ()
769   foreach (file ${${aom_source_var}})
770     if (NOT "${file}" MATCHES "${AOM_ROOT}")
771       string(REPLACE "${AOM_CONFIG_DIR}" "//third_party/aom/src" file "${file}")
772       file(APPEND "${libaom_srcs_gni_file}" "  \"${file}\",\n")
773     endif ()
774   endforeach ()
776   if ("${${aom_source_var}}" MATCHES "${AOM_CONFIG_DIR}")
777     file(APPEND "${libaom_srcs_gni_file}" "]\n")
778   endif ()
779 endforeach ()