blob: c10e33c38a3459871fc17e33686de794c382bd71 [file] [log] [blame]
Tom Fineganfc6f2362016-10-24 10:39:41 -07001##
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.
10##
Tom Finegan03e80212017-03-02 18:32:52 -080011cmake_minimum_required(VERSION 3.5)
Tom Fineganfc1aac52017-05-03 11:24:37 -070012
13if (NOT EMSCRIPTEN)
James Zerna14f2bb2017-07-06 19:51:57 -070014 if (NOT CMAKE_BUILD_TYPE)
James Zerndb0cc5b2017-08-30 19:40:54 -070015 set(CMAKE_BUILD_TYPE "Release" CACHE
James Zerna14f2bb2017-07-06 19:51:57 -070016 "Build type: Debug, Release, RelWithDebInfo or MinSizeRel" STRING FORCE)
Tom Fineganfc1aac52017-05-03 11:24:37 -070017 endif ()
18endif ()
19
Johann4ceee162017-10-02 12:59:57 -070020option(ENABLE_ADOPTED_EXPERIMENTS "Enable adopted experiments." ON)
Tom Finegana0ff4562017-05-23 08:27:47 -070021option(ENABLE_CCACHE "Enable ccache support." OFF)
22option(ENABLE_DISTCC "Enable distcc support." OFF)
Tom Finegan0d066ce2017-05-30 11:07:05 -070023option(ENABLE_DOCS "Enable documentation generation (doxygen required)." ON)
Tom Finegan9befd172017-09-29 15:19:19 -070024option(ENABLE_EXAMPLES "Enables build of example code." ON)
Tom Fineganf67fd8a2017-08-10 14:57:11 -070025option(ENABLE_GOMA "Enable goma support." OFF)
Tom Finegan375ee842017-06-02 10:34:02 -070026option(ENABLE_IDE_TEST_HOSTING
27 "Enables running tests within IDEs like Visual Studio and Xcode." OFF)
Tom Finegan9befd172017-09-29 15:19:19 -070028option(ENABLE_NASM "Use nasm instead of yasm for x86 assembly." OFF)
29option(ENABLE_TOOLS "Enable applications in tools sub directory." ON)
30option(ENABLE_WERROR "Converts warnings to errors at compile time." OFF)
Tom Finegana0ff4562017-05-23 08:27:47 -070031
Tom Finegane3bae4a2017-10-12 09:06:31 -070032# ARM assembly/intrinsics flags.
33option(ENABLE_NEON "Enables NEON optimizations on ARM targets." ON)
34option(ENABLE_NEON_ASM "Enables NEON ASM optimizations on ARM targets." ON)
35
36# MIPS assembly/intrinsics flags.
37option(ENABLE_DSPR2 "Enables DSPR2 optimizations on MIPS targets." OFF)
38option(ENABLE_MSA "Enables MSA optimizations on MIPS targets." OFF)
39
40# x86/x86_64 assembly/intrinsics flags.
41option(ENABLE_MMX "Enables MMX optimizations on x86/x86_64 targets." ON)
42option(ENABLE_SSE "Enables SSE optimizations on x86/x86_64 targets." ON)
43option(ENABLE_SSE2 "Enables SSE2 optimizations on x86/x86_64 targets." ON)
44option(ENABLE_SSE3 "Enables SSE3 optimizations on x86/x86_64 targets." ON)
45option(ENABLE_SSSE3 "Enables SSSE3 optimizations on x86/x86_64 targets." ON)
46option(ENABLE_SSE4_1 "Enables SSE4_1 optimizations on x86/x86_64 targets." ON)
47option(ENABLE_AVX "Enables AVX optimizations on x86/x86_64 targets." ON)
48option(ENABLE_AVX2 "Enables AVX2 optimizations on x86/x86_64 targets." ON)
49
Tom Finegan84f2d792017-06-15 23:06:44 -070050# $BUILD_SHARED_LIBS is a CMake built-in-- it's listed here for visibility.
51option(BUILD_SHARED_LIBS "CMake should generate a shared library build." OFF)
52
Tom Fineganfc6f2362016-10-24 10:39:41 -070053project(AOM C CXX)
54
55set(AOM_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
Tom Finegan973d4d52016-10-26 11:42:42 -070056set(AOM_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")
Tom Finegan6e9d0c12016-10-27 11:57:06 -070057
Tom Fineganf77394f2017-04-26 11:47:59 -070058if ("${AOM_ROOT}" STREQUAL "${AOM_CONFIG_DIR}")
59 message(FATAL_ERROR
60 "Building from within the aom source tree is not supported.\n"
61 "Hint: mkdir -p ../aom_build && cd ../aom_build\n"
62 "Run cmake from there.")
63endif ()
64
Tom Finegan973d4d52016-10-26 11:42:42 -070065include("${AOM_ROOT}/build/cmake/aom_configure.cmake")
Tom Finegan85ac13e2017-02-22 15:09:20 -080066include("${AOM_ROOT}/aom_dsp/aom_dsp.cmake")
Tom Finegandd6d0572017-03-01 19:01:23 -080067include("${AOM_ROOT}/aom_mem/aom_mem.cmake")
Tom Finegan507e2e12017-03-01 19:58:19 -080068include("${AOM_ROOT}/aom_ports/aom_ports.cmake")
Tom Fineganf0d14442017-03-01 20:42:51 -080069include("${AOM_ROOT}/aom_scale/aom_scale.cmake")
Tom Fineganb7d02542017-03-01 21:14:28 -080070include("${AOM_ROOT}/aom_util/aom_util.cmake")
Tom Finegan44916e72017-02-27 14:12:31 -080071include("${AOM_ROOT}/av1/av1.cmake")
Tom Finegan4db04d32017-02-23 14:37:27 -080072include("${AOM_ROOT}/test/test.cmake")
Tom Finegan8cc239b2017-08-07 12:28:12 -070073include("${AOM_ROOT}/build/cmake/sanitizers.cmake")
Tom Finegan84f2d792017-06-15 23:06:44 -070074include("${AOM_ROOT}/build/cmake/util.cmake")
Tom Finegan85ac13e2017-02-22 15:09:20 -080075
Tom Finegana0c21f02017-02-01 11:11:09 -080076set(AOM_RTCD_SOURCES
77 "${AOM_CONFIG_DIR}/aom_dsp_rtcd.h"
78 "${AOM_CONFIG_DIR}/aom_scale_rtcd.h"
79 "${AOM_CONFIG_DIR}/av1_rtcd.h"
80 "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd_defs.pl"
81 "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd.c"
82 "${AOM_ROOT}/aom_scale/aom_scale_rtcd.pl"
83 "${AOM_ROOT}/aom_scale/aom_scale_rtcd.c"
84 "${AOM_ROOT}/av1/common/av1_rtcd_defs.pl"
85 "${AOM_ROOT}/av1/common/av1_rtcd.c"
86 "${AOM_ROOT}/build/make/rtcd.pl")
87
Tom Finegan957fe822016-11-09 10:37:27 -080088# TODO(tomfinegan): Use libwebm's cmake support directly.
Tom Finegan50c5a7e2017-01-31 21:36:56 -080089set(AOM_LIBWEBM_SOURCES
Tom Finegan957fe822016-11-09 10:37:27 -080090 "${AOM_ROOT}/third_party/libwebm/common/hdr_util.cc"
91 "${AOM_ROOT}/third_party/libwebm/common/hdr_util.h"
92 "${AOM_ROOT}/third_party/libwebm/common/webmids.h"
93 "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvmuxer.cc"
94 "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvmuxer.h"
95 "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvmuxertypes.h"
96 "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvmuxerutil.cc"
97 "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvmuxerutil.h"
98 "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvwriter.cc"
99 "${AOM_ROOT}/third_party/libwebm/mkvmuxer/mkvwriter.h"
100 "${AOM_ROOT}/third_party/libwebm/mkvparser/mkvparser.cc"
101 "${AOM_ROOT}/third_party/libwebm/mkvparser/mkvparser.h"
102 "${AOM_ROOT}/third_party/libwebm/mkvparser/mkvreader.cc"
103 "${AOM_ROOT}/third_party/libwebm/mkvparser/mkvreader.h")
104
Tom Finegan50c5a7e2017-01-31 21:36:56 -0800105set(AOM_LIBYUV_SOURCES
Tom Finegan9cd97002016-11-09 10:37:44 -0800106 "${AOM_ROOT}/third_party/libyuv/include/libyuv/basic_types.h"
107 "${AOM_ROOT}/third_party/libyuv/include/libyuv/convert.h"
108 "${AOM_ROOT}/third_party/libyuv/include/libyuv/convert_argb.h"
109 "${AOM_ROOT}/third_party/libyuv/include/libyuv/convert_from.h"
110 "${AOM_ROOT}/third_party/libyuv/include/libyuv/cpu_id.h"
111 "${AOM_ROOT}/third_party/libyuv/include/libyuv/planar_functions.h"
112 "${AOM_ROOT}/third_party/libyuv/include/libyuv/rotate.h"
113 "${AOM_ROOT}/third_party/libyuv/include/libyuv/row.h"
114 "${AOM_ROOT}/third_party/libyuv/include/libyuv/scale.h"
115 "${AOM_ROOT}/third_party/libyuv/include/libyuv/scale_row.h"
116 "${AOM_ROOT}/third_party/libyuv/source/cpu_id.cc"
117 "${AOM_ROOT}/third_party/libyuv/source/planar_functions.cc"
118 "${AOM_ROOT}/third_party/libyuv/source/row_any.cc"
119 "${AOM_ROOT}/third_party/libyuv/source/row_common.cc"
120 "${AOM_ROOT}/third_party/libyuv/source/row_gcc.cc"
121 "${AOM_ROOT}/third_party/libyuv/source/row_mips.cc"
122 "${AOM_ROOT}/third_party/libyuv/source/row_neon.cc"
123 "${AOM_ROOT}/third_party/libyuv/source/row_neon64.cc"
124 "${AOM_ROOT}/third_party/libyuv/source/row_win.cc"
125 "${AOM_ROOT}/third_party/libyuv/source/scale.cc"
126 "${AOM_ROOT}/third_party/libyuv/source/scale_any.cc"
127 "${AOM_ROOT}/third_party/libyuv/source/scale_common.cc"
128 "${AOM_ROOT}/third_party/libyuv/source/scale_gcc.cc"
129 "${AOM_ROOT}/third_party/libyuv/source/scale_mips.cc"
130 "${AOM_ROOT}/third_party/libyuv/source/scale_neon.cc"
131 "${AOM_ROOT}/third_party/libyuv/source/scale_neon64.cc"
132 "${AOM_ROOT}/third_party/libyuv/source/scale_win.cc")
133
Tom Finegan50c5a7e2017-01-31 21:36:56 -0800134set(AOM_SOURCES
Tom Finegan973d4d52016-10-26 11:42:42 -0700135 "${AOM_CONFIG_DIR}/aom_config.c"
136 "${AOM_CONFIG_DIR}/aom_config.h"
Tom Fineganfc6f2362016-10-24 10:39:41 -0700137 "${AOM_ROOT}/aom/aom.h"
138 "${AOM_ROOT}/aom/aom_codec.h"
139 "${AOM_ROOT}/aom/aom_decoder.h"
140 "${AOM_ROOT}/aom/aom_encoder.h"
141 "${AOM_ROOT}/aom/aom_frame_buffer.h"
142 "${AOM_ROOT}/aom/aom_image.h"
143 "${AOM_ROOT}/aom/aom_integer.h"
144 "${AOM_ROOT}/aom/aomcx.h"
145 "${AOM_ROOT}/aom/aomdx.h"
146 "${AOM_ROOT}/aom/internal/aom_codec_internal.h"
147 "${AOM_ROOT}/aom/src/aom_codec.c"
148 "${AOM_ROOT}/aom/src/aom_decoder.c"
149 "${AOM_ROOT}/aom/src/aom_encoder.c"
150 "${AOM_ROOT}/aom/src/aom_image.c")
151
Tom Finegan03f6ca72016-11-10 13:02:48 -0800152set(AOM_COMMON_APP_UTIL_SOURCES
Tom Finegana89fe0e2017-01-19 14:38:28 -0800153 "${AOM_ROOT}/args.c"
154 "${AOM_ROOT}/args.h"
Tom Finegan03f6ca72016-11-10 13:02:48 -0800155 "${AOM_ROOT}/md5_utils.c"
156 "${AOM_ROOT}/md5_utils.h"
157 "${AOM_ROOT}/tools_common.c"
158 "${AOM_ROOT}/tools_common.h"
Tom Fineganba02c242017-05-16 15:01:54 -0700159 "${AOM_ROOT}/video_common.h"
160 "${AOM_ROOT}/y4menc.c"
161 "${AOM_ROOT}/y4menc.h")
Tom Finegan03f6ca72016-11-10 13:02:48 -0800162
163set(AOM_DECODER_APP_UTIL_SOURCES
164 "${AOM_ROOT}/ivfdec.c"
165 "${AOM_ROOT}/ivfdec.h"
166 "${AOM_ROOT}/video_reader.c"
Tom Fineganba02c242017-05-16 15:01:54 -0700167 "${AOM_ROOT}/video_reader.h")
Tom Finegan03f6ca72016-11-10 13:02:48 -0800168
Cyril Concolato6c788832017-10-30 16:30:35 -0700169if (CONFIG_OBU_NO_IVF)
170 list(APPEND AOM_DECODER_APP_UTIL_SOURCES "${AOM_ROOT}/obudec.c" "${AOM_ROOT}/obudec.h")
171endif ()
172
Tom Finegan03f6ca72016-11-10 13:02:48 -0800173set(AOM_ENCODER_APP_UTIL_SOURCES
174 "${AOM_ROOT}/ivfenc.c"
175 "${AOM_ROOT}/ivfenc.h"
176 "${AOM_ROOT}/video_writer.c"
Tom Finegana89fe0e2017-01-19 14:38:28 -0800177 "${AOM_ROOT}/video_writer.h"
178 "${AOM_ROOT}/warnings.c"
179 "${AOM_ROOT}/warnings.h"
180 "${AOM_ROOT}/y4minput.c"
Urvang Joshi09c293e2017-04-20 17:56:27 -0700181 "${AOM_ROOT}/y4minput.h"
182 "${AOM_ROOT}/examples/encoder_util.h"
183 "${AOM_ROOT}/examples/encoder_util.c")
Tom Finegana89fe0e2017-01-19 14:38:28 -0800184
185set(AOM_ENCODER_STATS_SOURCES
186 "${AOM_ROOT}/aomstats.c"
187 "${AOM_ROOT}/aomstats.h"
188 "${AOM_ROOT}/rate_hist.c"
189 "${AOM_ROOT}/rate_hist.h")
190
Tom Finegan872e5852017-08-29 15:15:58 -0700191set(AOM_PKG_CONFIG_SOURCES "${AOM_CONFIG_DIR}/aom.pc")
192
193set(AOM_VERSION_SOURCES "${AOM_CONFIG_DIR}/aom_version.h")
194
Tom Finegana89fe0e2017-01-19 14:38:28 -0800195set(AOM_WEBM_DECODER_SOURCES
196 "${AOM_ROOT}/webmdec.cc"
197 "${AOM_ROOT}/webmdec.h")
198
199set(AOM_WEBM_ENCODER_SOURCES
200 "${AOM_ROOT}/webmenc.cc"
201 "${AOM_ROOT}/webmenc.h")
202
203include_directories(${AOM_ROOT} ${AOM_CONFIG_DIR})
Tom Finegan03f6ca72016-11-10 13:02:48 -0800204
Tom Fineganfc6f2362016-10-24 10:39:41 -0700205# Targets
Tom Finegan872e5852017-08-29 15:15:58 -0700206add_library(aom_version ${AOM_VERSION_SOURCES})
207add_dummy_source_file_to_target(aom_version c)
208add_custom_command(
209 OUTPUT "${AOM_CONFIG_DIR}/aom_version.h"
210 COMMAND ${CMAKE_COMMAND}
211 ARGS -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
212 -DAOM_ROOT=${AOM_ROOT}
213 -DGIT_EXECUTABLE=${GIT_EXECUTABLE}
214 -DPERL_EXECUTABLE=${PERL_EXECUTABLE}
215 -P "${AOM_ROOT}/build/cmake/version.cmake"
216 COMMENT "Writing aom_version.h"
217 VERBATIM)
218
219add_custom_target(aom_version_check
220 COMMAND ${CMAKE_COMMAND}
221 -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
222 -DAOM_ROOT=${AOM_ROOT}
223 -DGIT_EXECUTABLE=${GIT_EXECUTABLE}
224 -DPERL_EXECUTABLE=${PERL_EXECUTABLE}
225 -P "${AOM_ROOT}/build/cmake/version.cmake"
226 COMMENT "Updating version info if necessary."
227 VERBATIM)
228add_dependencies(aom_version aom_version_check)
229
230if (NOT MSVC)
231 add_library(aom_pc ${AOM_PKG_CONFIG_SOURCES})
232 add_dummy_source_file_to_target(aom_pc c)
233 add_custom_command(
234 OUTPUT "${AOM_CONFIG_DIR}/aom.pc"
235 COMMAND ${CMAKE_COMMAND}
236 ARGS -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
237 -DAOM_ROOT=${AOM_ROOT}
Tom Finegan40b2a972017-09-25 09:45:27 -0700238 -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
Tom Finegan872e5852017-08-29 15:15:58 -0700239 -DCMAKE_PROJECT_NAME=${CMAKE_PROJECT_NAME}
240 -DCONFIG_MULTITHREAD=${CONFIG_MULTITHREAD}
241 -DHAVE_PTHREAD_H=${HAVE_PTHREAD_H}
242 -P "${AOM_ROOT}/build/cmake/pkg_config.cmake"
243 COMMENT "Writing aom.pc"
244 VERBATIM)
Tom Finegan00b4df72017-09-01 11:30:34 -0700245 add_dependencies(aom_pc aom_version)
Tom Finegan872e5852017-08-29 15:15:58 -0700246endif ()
Tom Finegan872e5852017-08-29 15:15:58 -0700247
Tom Fineganf0d14442017-03-01 20:42:51 -0800248# TODO(tomfinegan): Move rtcd target setup where it belongs for each rtcd
249# source.
Tom Finegana0c21f02017-02-01 11:11:09 -0800250add_rtcd_build_step("${AOM_ROOT}/aom_dsp/aom_dsp_rtcd_defs.pl"
251 "${AOM_CONFIG_DIR}/aom_dsp_rtcd.h"
252 "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd.c"
253 "aom_dsp_rtcd")
254add_rtcd_build_step("${AOM_ROOT}/aom_scale/aom_scale_rtcd.pl"
255 "${AOM_CONFIG_DIR}/aom_scale_rtcd.h"
256 "${AOM_ROOT}/aom_scale/aom_scale_rtcd.c"
257 "aom_scale_rtcd")
258add_rtcd_build_step("${AOM_ROOT}/av1/common/av1_rtcd_defs.pl"
259 "${AOM_CONFIG_DIR}/av1_rtcd.h"
260 "${AOM_ROOT}/av1/common/av1_rtcd.c"
261 "av1_rtcd")
Tom Finegan85ac13e2017-02-22 15:09:20 -0800262
Tom Finegana0c21f02017-02-01 11:11:09 -0800263add_library(aom_rtcd OBJECT ${AOM_RTCD_SOURCES})
Tom Finegan872e5852017-08-29 15:15:58 -0700264add_dependencies(aom_rtcd aom_version)
265
Tom Finegana7ed1432017-02-08 10:34:40 -0800266add_library(aom_encoder_stats OBJECT ${AOM_ENCODER_STATS_SOURCES})
Tom Fineganb7d02542017-03-01 21:14:28 -0800267add_library(aom ${AOM_SOURCES} $<TARGET_OBJECTS:aom_rtcd>)
Tom Finegan03f6ca72016-11-10 13:02:48 -0800268
Tom Finegan3e8986b2017-09-29 17:08:31 -0700269if (NOT MSVC AND NOT APPLE)
270 target_link_libraries(aom ${AOM_LIB_LINK_TYPE} m)
271endif ()
272
Tom Finegana0c21f02017-02-01 11:11:09 -0800273# List of object and static library targets.
Tom Fineganb7d02542017-03-01 21:14:28 -0800274set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_rtcd aom_encoder_stats aom_mem
275 aom_scale aom)
Tom Finegana0c21f02017-02-01 11:11:09 -0800276
Tom Finegan507e2e12017-03-01 19:58:19 -0800277# Setup dependencies.
Tom Finegan85ac13e2017-02-22 15:09:20 -0800278setup_aom_dsp_targets()
Tom Finegandd6d0572017-03-01 19:01:23 -0800279setup_aom_mem_targets()
Tom Finegan507e2e12017-03-01 19:58:19 -0800280setup_aom_ports_targets()
Tom Fineganb7d02542017-03-01 21:14:28 -0800281setup_aom_util_targets()
Tom Fineganf0d14442017-03-01 20:42:51 -0800282setup_aom_scale_targets()
Tom Finegan44916e72017-02-27 14:12:31 -0800283setup_av1_targets()
Tom Finegan85ac13e2017-02-22 15:09:20 -0800284
Tom Finegana0c21f02017-02-01 11:11:09 -0800285# Make all library targets depend on aom_rtcd to make sure it builds first.
286foreach (aom_lib ${AOM_LIB_TARGETS})
287 if (NOT "${aom_lib}" STREQUAL "aom_rtcd")
288 add_dependencies(${aom_lib} aom_rtcd)
289 endif ()
290endforeach ()
Tom Fineganba02c242017-05-16 15:01:54 -0700291
Tom Fineganff863952017-12-22 11:41:14 -0800292# Generate C/C++ stub files containing the function usage_exit(). Users of the
Tom Finegane91bb452017-09-29 11:40:24 -0700293# aom_common_app_util library must define this function. This is a convenience
294# to allow omission of the function from applications that might want to use
Tom Fineganff863952017-12-22 11:41:14 -0800295# other pieces of the util support without defining usage_exit().
Tom Finegane91bb452017-09-29 11:40:24 -0700296file(WRITE "${AOM_CONFIG_DIR}/usage_exit.c" "void usage_exit(void) {}")
Tom Fineganff863952017-12-22 11:41:14 -0800297file(WRITE "${AOM_CONFIG_DIR}/usage_exit.cc"
298 "extern \"C\" void usage_exit(void) {}")
Tom Finegan03f6ca72016-11-10 13:02:48 -0800299
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700300#
301# Application and application support targets.
302#
303if (CONFIG_UNIT_TESTS OR ENABLE_EXAMPLES OR ENABLE_TOOLS)
304 add_library(aom_common_app_util OBJECT ${AOM_COMMON_APP_UTIL_SOURCES})
305 if (CONFIG_AV1_DECODER)
306 add_library(aom_decoder_app_util OBJECT ${AOM_DECODER_APP_UTIL_SOURCES})
307 endif ()
308 if (CONFIG_AV1_ENCODER)
309 add_library(aom_encoder_app_util OBJECT ${AOM_ENCODER_APP_UTIL_SOURCES})
310 endif ()
311endif ()
312
313if (CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
Tom Fineganba02c242017-05-16 15:01:54 -0700314 add_executable(aomdec
Tom Finegan84f2d792017-06-15 23:06:44 -0700315 "${AOM_ROOT}/aomdec.c"
316 $<TARGET_OBJECTS:aom_common_app_util>
317 $<TARGET_OBJECTS:aom_decoder_app_util>)
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700318 add_executable(decode_to_md5
319 "${AOM_ROOT}/examples/decode_to_md5.c"
320 $<TARGET_OBJECTS:aom_common_app_util>
321 $<TARGET_OBJECTS:aom_decoder_app_util>)
322 add_executable(decode_with_drops
323 "${AOM_ROOT}/examples/decode_with_drops.c"
324 $<TARGET_OBJECTS:aom_common_app_util>
325 $<TARGET_OBJECTS:aom_decoder_app_util>)
326 add_executable(simple_decoder
327 "${AOM_ROOT}/examples/simple_decoder.c"
328 $<TARGET_OBJECTS:aom_common_app_util>
329 $<TARGET_OBJECTS:aom_decoder_app_util>)
Tom Finegana89fe0e2017-01-19 14:38:28 -0800330
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700331 if (CONFIG_ANALYZER)
332 add_executable(analyzer
333 "${AOM_ROOT}/examples/analyzer.cc"
Tom Finegan9befd172017-09-29 15:19:19 -0700334 $<TARGET_OBJECTS:aom_common_app_util>
335 $<TARGET_OBJECTS:aom_decoder_app_util>)
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700336 target_link_libraries(analyzer
337 ${AOM_LIB_LINK_TYPE} ${wxWidgets_LIBRARIES})
338 set(AOM_APP_TARGETS ${AOM_APP_TARGETS} analyzer)
339 set(AOM_DECODER_EXAMPLE_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS} analyzer)
Tom Fineganba02c242017-05-16 15:01:54 -0700340 endif ()
341
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700342 if (CONFIG_INSPECTION)
343 add_executable(inspect
344 "${AOM_ROOT}/examples/inspect.c"
345 $<TARGET_OBJECTS:aom_common_app_util>
346 $<TARGET_OBJECTS:aom_decoder_app_util>)
347 set(AOM_DECODER_EXAMPLE_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS} inspect)
348
349 if (EMSCRIPTEN)
350 add_preproc_definition(_POSIX_SOURCE)
351 append_link_flag_to_target("inspect" "-s TOTAL_MEMORY=134217728")
352 append_link_flag_to_target("inspect" "-s MODULARIZE=1")
353 append_link_flag_to_target("inspect"
354 "-s EXPORT_NAME=\"\'DecoderModule\'\"")
355 append_link_flag_to_target("inspect" "--memory-init-file 0")
356
357 if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
358 # Default to -O3 when no build type specified.
359 append_compiler_flag("-O3")
360 endif ()
361
362 em_link_post_js(inspect "${AOM_ROOT}/tools/inspect-post.js")
363 endif ()
364 endif ()
365
366 # Maintain a list of decoder example targets.
367 set(AOM_DECODER_EXAMPLE_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS}
368 aomdec decode_to_md5 decode_with_drops simple_decoder)
369
Tom Finegan9befd172017-09-29 15:19:19 -0700370 # Add decoder examples to the app targets list.
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700371 set(AOM_APP_TARGETS ${AOM_APP_TARGETS} ${AOM_DECODER_EXAMPLE_TARGETS})
Michael Bebenitaf4f27fe2017-03-02 17:40:44 -0800372endif ()
373
Tom Fineganba02c242017-05-16 15:01:54 -0700374if (CONFIG_AV1_ENCODER)
Tom Finegan9befd172017-09-29 15:19:19 -0700375 if (ENABLE_EXAMPLES)
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700376 add_executable(aomenc
377 "${AOM_ROOT}/aomenc.c"
378 $<TARGET_OBJECTS:aom_common_app_util>
379 $<TARGET_OBJECTS:aom_encoder_app_util>
380 $<TARGET_OBJECTS:aom_encoder_stats>)
Tom Finegan9befd172017-09-29 15:19:19 -0700381 add_executable(lossless_encoder
382 "${AOM_ROOT}/examples/lossless_encoder.c"
Tom Finegane91bb452017-09-29 11:40:24 -0700383 $<TARGET_OBJECTS:aom_common_app_util>
384 $<TARGET_OBJECTS:aom_encoder_app_util>)
Tom Finegan9befd172017-09-29 15:19:19 -0700385 add_executable(set_maps
386 "${AOM_ROOT}/examples/set_maps.c"
387 $<TARGET_OBJECTS:aom_common_app_util>
388 $<TARGET_OBJECTS:aom_encoder_app_util>)
389 add_executable(simple_encoder
390 "${AOM_ROOT}/examples/simple_encoder.c"
391 $<TARGET_OBJECTS:aom_common_app_util>
392 $<TARGET_OBJECTS:aom_encoder_app_util>)
393 add_executable(twopass_encoder
394 "${AOM_ROOT}/examples/twopass_encoder.c"
395 $<TARGET_OBJECTS:aom_common_app_util>
396 $<TARGET_OBJECTS:aom_encoder_app_util>)
397
398 # Maintain a list of encoder example targets.
399 set(AOM_ENCODER_EXAMPLE_TARGETS
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700400 aomenc lossless_encoder set_maps simple_encoder twopass_encoder)
Tom Finegane91bb452017-09-29 11:40:24 -0700401 endif ()
402
Tom Fineganbac99072017-10-11 09:16:54 -0700403 if (ENABLE_TOOLS)
404 if (CONFIG_ENTROPY_STATS AND NOT BUILD_SHARED_LIBS)
405 # TODO(tomfinegan): Sort out why a simple link command with
406 # aom_entropy_optimizer.c won't work on macos, but dragging in all the
407 # helper machinery allows the link to succeed.
408 add_executable(aom_entropy_optimizer
409 "${AOM_CONFIG_DIR}/usage_exit.c"
410 "${AOM_ROOT}/tools/aom_entropy_optimizer.c"
411 $<TARGET_OBJECTS:aom_common_app_util>
412 $<TARGET_OBJECTS:aom_encoder_app_util>)
Tom Finegan9befd172017-09-29 15:19:19 -0700413
Tom Fineganbac99072017-10-11 09:16:54 -0700414 # Maintain a list of encoder tool targets.
415 set(AOM_ENCODER_TOOL_TARGETS
416 ${AOM_ENCODER_TOOL_TARGETS} aom_entropy_optimizer)
417 endif ()
Tom Finegan9befd172017-09-29 15:19:19 -0700418 endif ()
Tom Fineganbac99072017-10-11 09:16:54 -0700419
420 # Add encoder examples and tools to the targets list.
421 set(AOM_APP_TARGETS ${AOM_APP_TARGETS}
422 ${AOM_ENCODER_EXAMPLE_TARGETS} ${AOM_ENCODER_TOOL_TARGETS})
Tom Fineganba02c242017-05-16 15:01:54 -0700423endif ()
424
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700425if (ENABLE_EXAMPLES)
426 # Maintain a separate variable listing only the examples to facilitate
427 # installation of example programs into an examples sub directory of
428 # $AOM_DIST_DIR/bin when building the dist target.
429 set(AOM_EXAMPLE_TARGETS
430 ${AOM_DECODER_EXAMPLE_TARGETS} ${AOM_ENCODER_EXAMPLE_TARGETS})
431endif ()
Tom Finegan78975672017-05-30 08:55:54 -0700432
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700433if (ENABLE_TOOLS)
Tom Fineganff863952017-12-22 11:41:14 -0800434 if (CONFIG_AV1_DECODER AND CONFIG_OBU)
435 require_cxx_flag_nomsvc("-std=c++11" NO)
Tom Fineganc0192332017-12-02 09:31:45 -0800436 add_executable(dump_obu
Tom Fineganff863952017-12-22 11:41:14 -0800437 "${AOM_CONFIG_DIR}/usage_exit.cc"
Tom Fineganc0192332017-12-02 09:31:45 -0800438 "${AOM_ROOT}/tools/dump_obu.cc"
439 "${AOM_ROOT}/tools/obu_parser.cc"
440 "${AOM_ROOT}/tools/obu_parser.h"
441 $<TARGET_OBJECTS:aom_common_app_util>
442 $<TARGET_OBJECTS:aom_decoder_app_util>)
Tom Fineganff863952017-12-22 11:41:14 -0800443
Tom Fineganc0192332017-12-02 09:31:45 -0800444 list(APPEND AOM_TOOL_TARGETS dump_obu)
445 list(APPEND AOM_APP_TARGETS dump_obu)
Tom Fineganc0192332017-12-02 09:31:45 -0800446
Tom Fineganff863952017-12-22 11:41:14 -0800447 if (NOT MSVC)
448 target_compile_options(dump_obu PUBLIC -std=c++11)
449 # TODO(tomfinegan): This can go once the GCC pragma in libwebm is updated
450 # to silence the auto_ptr warnings for GCC >= v4.
451 target_compile_options(dump_obu PUBLIC -Wno-deprecated-declarations)
452 endif ()
453
454 # Maintain a separate variable listing only the examples to facilitate
455 # installation of example programs into an tools sub directory of
456 # $AOM_DIST_DIR/bin when building the dist target.
457 list(APPEND AOM_TOOL_TARGETS
458 ${AOM_DECODER_TOOL_TARGETS} ${AOM_ENCODER_TOOL_TARGETS})
459 endif ()
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700460endif ()
Tom Finegane91bb452017-09-29 11:40:24 -0700461
Tom Finegan9befd172017-09-29 15:19:19 -0700462if (ENABLE_EXAMPLES AND CONFIG_AV1_DECODER AND CONFIG_AV1_ENCODER)
Tom Fineganba02c242017-05-16 15:01:54 -0700463 add_executable(aom_cx_set_ref
464 "${AOM_ROOT}/examples/aom_cx_set_ref.c"
465 $<TARGET_OBJECTS:aom_common_app_util>
466 $<TARGET_OBJECTS:aom_encoder_app_util>)
Tom Finegan78975672017-05-30 08:55:54 -0700467 set(AOM_EXAMPLE_TARGETS ${AOM_EXAMPLE_TARGETS} aom_cx_set_ref)
Tom Fineganba02c242017-05-16 15:01:54 -0700468 set(AOM_APP_TARGETS ${AOM_APP_TARGETS} aom_cx_set_ref)
469endif ()
Tom Finegan81279802017-02-01 11:27:05 -0800470
471foreach (aom_app ${AOM_APP_TARGETS})
Tom Finegand46b4d32017-05-09 09:14:03 -0700472 target_link_libraries(${aom_app} ${AOM_LIB_LINK_TYPE} aom)
Tom Finegan81279802017-02-01 11:27:05 -0800473endforeach ()
Tom Fineganfc6f2362016-10-24 10:39:41 -0700474
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700475if (CONFIG_UNIT_TESTS OR ENABLE_EXAMPLES OR ENABLE_TOOLS)
476 if (CONFIG_LIBYUV)
477 add_library(yuv OBJECT ${AOM_LIBYUV_SOURCES})
478 if (NOT MSVC)
479 target_compile_options(yuv PRIVATE -Wno-unused-parameter)
480 endif ()
481 include_directories("${AOM_ROOT}/third_party/libyuv/include")
Tom Finegan9cd97002016-11-09 10:37:44 -0800482
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700483 # Add to existing targets.
484 foreach (aom_app ${AOM_APP_TARGETS})
485 target_sources(${aom_app} PRIVATE $<TARGET_OBJECTS:yuv>)
486 set_property(TARGET ${aom_app} PROPERTY LINKER_LANGUAGE CXX)
487 endforeach ()
Tom Finegan87fdc282017-02-10 10:30:28 -0800488 endif ()
Tom Finegan957fe822016-11-09 10:37:27 -0800489
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700490 if (CONFIG_WEBM_IO)
491 add_library(webm OBJECT ${AOM_LIBWEBM_SOURCES})
492 include_directories("${AOM_ROOT}/third_party/libwebm")
493 target_compile_definitions(webm PRIVATE __STDC_CONSTANT_MACROS)
494 target_compile_definitions(webm PRIVATE __STDC_LIMIT_MACROS)
Tom Fineganba02c242017-05-16 15:01:54 -0700495
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700496 if (NOT MSVC)
497 target_compile_options(webm PRIVATE -Wno-shadow)
498 endif ()
Tom Finegan81279802017-02-01 11:27:05 -0800499
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700500 # Add to existing targets.
501 if (CONFIG_AV1_DECODER)
502 target_sources(aom_decoder_app_util PRIVATE ${AOM_WEBM_DECODER_SOURCES})
503 endif ()
504
505 if (CONFIG_AV1_ENCODER)
506 target_sources(aom_encoder_app_util PRIVATE ${AOM_WEBM_ENCODER_SOURCES})
507 endif ()
508
509 foreach (aom_app ${AOM_APP_TARGETS})
510 target_sources(${aom_app} PRIVATE $<TARGET_OBJECTS:webm>)
511 set_property(TARGET ${aom_app} PROPERTY LINKER_LANGUAGE CXX)
512 endforeach ()
513 endif ()
Tom Finegan957fe822016-11-09 10:37:27 -0800514endif ()
Tom Finegan7ba9ba82017-01-23 14:04:28 -0800515
516if (CONFIG_UNIT_TESTS)
Tom Finegan4db04d32017-02-23 14:37:27 -0800517 # Create test_libaom target and the targets it depends on.
518 setup_aom_test_targets()
Tom Finegan7ba9ba82017-01-23 14:04:28 -0800519endif ()
Tom Finegan9412ec32017-02-01 11:41:43 -0800520
Tom Finegan606f6462017-03-06 11:18:29 -0800521if (HAVE_PTHREAD_H AND CONFIG_MULTITHREAD)
522 find_package(Threads)
523 foreach (app_target ${AOM_APP_TARGETS})
Tom Finegand46b4d32017-05-09 09:14:03 -0700524 target_link_libraries(${app_target} ${AOM_LIB_LINK_TYPE} Threads::Threads)
Tom Finegan606f6462017-03-06 11:18:29 -0800525 endforeach ()
526endif ()
527
Tom Finegan9412ec32017-02-01 11:41:43 -0800528if (XCODE)
Tom Finegandb37c752017-11-30 17:02:27 -0800529 # TODO(tomfinegan): Make sure target has no C++ files before doing this as
530 # it's not necessary in that case.
Tom Finegan9412ec32017-02-01 11:41:43 -0800531 if (CONFIG_LIBYUV OR CONFIG_WEBM_IO)
532 # The Xcode generator does not obey LINKER_LANGUAGE. Because of the issue
533 # what looks like a C++ file needs to be in any target that Xcode will link
534 # when the target contains a C++ dependency.
535 # Without this Xcode will try to link with the C linker, which always ends
536 # badly when a dependency actually includes C++.
537 # Note: LINKER_LANGUAGE is explicitly set to C++ for all targets touched
538 # here, it really is the Xcode generator's fault, or just a deficiency in
539 # Xcode itself.
Tom Finegan9412ec32017-02-01 11:41:43 -0800540 foreach (aom_app ${AOM_APP_TARGETS})
Tom Finegan84f2d792017-06-15 23:06:44 -0700541 add_dummy_source_file_to_target("${aom_app}" "cc")
Tom Finegan9412ec32017-02-01 11:41:43 -0800542 endforeach ()
543 endif ()
544endif ()
Tom Finegan0a4ef082017-03-31 11:07:34 -0700545
Tom Finegan9befd172017-09-29 15:19:19 -0700546if (ENABLE_EXAMPLES AND "${CMAKE_GENERATOR}" MATCHES "Makefiles$")
Tom Finegan78975672017-05-30 08:55:54 -0700547 # Users of the configure build expect the example targets to be built in the
548 # examples sub directory of the configured build directory after running make.
549 file(MAKE_DIRECTORY "${AOM_CONFIG_DIR}/examples")
Tom Finegan938172c2017-10-07 13:58:34 -0700550
551 foreach (target ${AOM_EXAMPLE_TARGETS})
552 if (NOT "${target}" MATCHES "aomdec\|aomenc")
553 set_target_properties(${target} PROPERTIES
554 RUNTIME_OUTPUT_DIRECTORY
555 "${AOM_CONFIG_DIR}/examples")
556 endif ()
557 endforeach ()
Tom Finegane91bb452017-09-29 11:40:24 -0700558
Tom Finegan9befd172017-09-29 15:19:19 -0700559 if (ENABLE_TOOLS AND AOM_TOOL_TARGETS)
Tom Finegane91bb452017-09-29 11:40:24 -0700560 # The same expectation is true for tool targets.
561 file(MAKE_DIRECTORY "${AOM_CONFIG_DIR}/tools")
562 set_target_properties(${AOM_TOOL_TARGETS} PROPERTIES
563 RUNTIME_OUTPUT_DIRECTORY "${AOM_CONFIG_DIR}/tools")
564 endif ()
Tom Finegan78975672017-05-30 08:55:54 -0700565endif ()
566
Tom Finegan84f2d792017-06-15 23:06:44 -0700567if (BUILD_SHARED_LIBS)
568 include("${AOM_ROOT}/build/cmake/exports.cmake")
569 setup_exports_target()
Tom Finegan4a3a9c02017-07-14 08:34:20 -0700570 set_target_properties(aom PROPERTIES SOVERSION 0)
Tom Finegan84f2d792017-06-15 23:06:44 -0700571endif ()
572
Tom Fineganc8593982017-09-05 11:01:09 -0700573# Handle user supplied compile and link flags last to ensure they're obeyed.
574set_user_flags()
575
Tom Finegan0d066ce2017-05-30 11:07:05 -0700576# Aomedia documentation rule.
577if (ENABLE_DOCS)
578 include(FindDoxygen)
579 if (DOXYGEN_FOUND)
580 include("${AOM_ROOT}/docs.cmake")
581 setup_documentation_targets()
582 else ()
583 message("--- Cannot find doxygen, ENABLE_DOCS turned off.")
584 set(ENABLE_DOCS OFF)
585 endif ()
586endif ()
587
Tom Finegan0a4ef082017-03-31 11:07:34 -0700588# Aomedia install rule.
Tom Finegan0a4ef082017-03-31 11:07:34 -0700589set(AOM_INSTALL_INCS
590 "${AOM_ROOT}/aom/aom.h"
Tom Finegan0a4ef082017-03-31 11:07:34 -0700591 "${AOM_ROOT}/aom/aom_codec.h"
592 "${AOM_ROOT}/aom/aom_frame_buffer.h"
593 "${AOM_ROOT}/aom/aom_image.h"
594 "${AOM_ROOT}/aom/aom_integer.h"
Tom Finegan0a4ef082017-03-31 11:07:34 -0700595 "${AOM_ROOT}/aom/aom.h")
Tom Fineganba02c242017-05-16 15:01:54 -0700596
597if (CONFIG_AV1_DECODER)
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700598 if (ENABLE_EXAMPLES)
599 set(AOM_INSTALL_BINS ${AOM_INSTALL_BINS} aomdec)
600 endif ()
601
Tom Fineganba02c242017-05-16 15:01:54 -0700602 set(AOM_INSTALL_INCS
603 ${AOM_INSTALL_INCS}
604 "${AOM_ROOT}/aom/aom_decoder.h"
605 "${AOM_ROOT}/aom/aomdx.h")
606endif ()
607
608if (CONFIG_AV1_ENCODER)
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700609 if (ENABLE_EXAMPLES)
610 set(AOM_INSTALL_BINS ${AOM_INSTALL_BINS} aomenc)
611 endif ()
612
Tom Fineganba02c242017-05-16 15:01:54 -0700613 set(AOM_INSTALL_INCS
614 ${AOM_INSTALL_INCS}
615 "${AOM_ROOT}/aom/aomcx.h"
616 "${AOM_ROOT}/aom/aom_encoder.h")
Tom Fineganba02c242017-05-16 15:01:54 -0700617endif ()
618
Tom Finegan0a4ef082017-03-31 11:07:34 -0700619set(AOM_INSTALL_LIBS aom)
620
621install(FILES ${AOM_INSTALL_INCS}
622 DESTINATION "${CMAKE_INSTALL_PREFIX}/include/aom")
Tom Finegan782cdc12017-05-12 10:08:53 -0700623install(FILES "${AOM_CONFIG_DIR}/aom.pc"
624 DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig")
Tom Finegan0a4ef082017-03-31 11:07:34 -0700625install(TARGETS ${AOM_INSTALL_LIBS} DESTINATION "${CMAKE_INSTALL_PREFIX}/lib")
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700626
627if (ENABLE_EXAMPLES)
628 install(TARGETS ${AOM_INSTALL_BINS} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
629endif ()
Tom Finegan0d066ce2017-05-30 11:07:05 -0700630
Tom Finegan78975672017-05-30 08:55:54 -0700631# Aomedia dist rule.
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700632if (CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
Tom Finegan78975672017-05-30 08:55:54 -0700633 set(AOM_DIST_APPS ${AOM_DIST_APPS} $<TARGET_FILE:aomdec>)
634endif ()
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700635if (CONFIG_AV1_ENCODER AND ENABLE_EXAMPLES)
Tom Finegan78975672017-05-30 08:55:54 -0700636 set(AOM_DIST_APPS ${AOM_DIST_APPS} $<TARGET_FILE:aomenc>)
637endif ()
638
Tom Finegan9befd172017-09-29 15:19:19 -0700639if (ENABLE_EXAMPLES)
640 foreach (example ${AOM_EXAMPLE_TARGETS})
641 list(APPEND AOM_DIST_EXAMPLES $<TARGET_FILE:${example}>)
642 endforeach ()
643endif ()
Tom Finegan78975672017-05-30 08:55:54 -0700644
Tom Finegan9befd172017-09-29 15:19:19 -0700645if (ENABLE_TOOLS)
646 foreach (tool ${AOM_TOOL_TARGETS})
647 list(APPEND AOM_DIST_TOOLS $<TARGET_FILE:${tool}>)
648 endforeach ()
649endif ()
Tom Finegane91bb452017-09-29 11:40:24 -0700650
Tom Finegan78975672017-05-30 08:55:54 -0700651if (NOT AOM_DIST_DIR)
652 set(AOM_DIST_DIR "${AOM_CONFIG_DIR}/dist")
653endif ()
654
655add_custom_target(dist
656 COMMAND ${CMAKE_COMMAND}
657 -DAOM_ROOT=${AOM_ROOT}
658 -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
659 -DAOM_DIST_DIR=${AOM_DIST_DIR}
660 -DAOM_DIST_APPS="${AOM_DIST_APPS}"
661 -DAOM_DIST_EXAMPLES="${AOM_DIST_EXAMPLES}"
Tom Finegane91bb452017-09-29 11:40:24 -0700662 -DAOM_DIST_TOOLS="${AOM_DIST_TOOLS}"
Tom Finegan78975672017-05-30 08:55:54 -0700663 -DAOM_DIST_INCLUDES="${AOM_INSTALL_INCS}"
664 -DAOM_DIST_LIBS=$<TARGET_FILE:aom>
665 -DENABLE_DOCS=${ENABLE_DOCS}
666 -P "${AOM_ROOT}/build/cmake/dist.cmake"
667 DEPENDS ${AOM_INSTALL_BINS} ${AOM_INSTALL_LIBS}
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700668 ${AOM_INSTALL_INCS} ${AOM_EXAMPLE_TARGETS}
669 ${AOM_TOOL_TARGETS})
Tom Finegan78975672017-05-30 08:55:54 -0700670
Tom Finegan0d066ce2017-05-30 11:07:05 -0700671if (ENABLE_DOCS)
Tom Finegan78975672017-05-30 08:55:54 -0700672 add_dependencies(dist docs)
Tom Finegan0d066ce2017-05-30 11:07:05 -0700673endif ()
Tom Fineganc34abc82017-10-13 12:04:59 -0700674
675# Collect all variables containing libaom source files.
676get_cmake_property(all_cmake_vars VARIABLES)
677foreach (var ${all_cmake_vars})
678 if ("${var}" MATCHES "SOURCES$\|_INTRIN_\|_ASM_" AND NOT
679 "${var}" MATCHES "_APP_\|DOXYGEN\|LIBWEBM\|LIBYUV\|_PKG_\|TEST")
680 list(APPEND aom_source_vars ${var})
681 endif ()
682endforeach ()
683
684# Libaom_srcs.txt generation.
685set(libaom_srcs_txt_file "${AOM_CONFIG_DIR}/libaom_srcs.txt")
686file(WRITE "${libaom_srcs_txt_file}" "# This file is generated. DO NOT EDIT.\n")
687
688# Static source file list first.
689foreach (aom_source_var ${aom_source_vars})
690 foreach (file ${${aom_source_var}})
691 if (NOT "${file}" MATCHES "${AOM_CONFIG_DIR}")
692 string(REPLACE "${AOM_ROOT}/" "" file "${file}")
693 file(APPEND "${libaom_srcs_txt_file}" "${file}\n")
694 endif ()
695 endforeach ()
696endforeach ()
697
698file(APPEND "${libaom_srcs_txt_file}"
699 "# Files below this line are generated by the libaom build system.\n")
700foreach (aom_source_var ${aom_source_vars})
701 foreach (file ${${aom_source_var}})
702 if ("${file}" MATCHES "${AOM_CONFIG_DIR}")
703 string(REPLACE "${AOM_CONFIG_DIR}/" "" file "${file}")
704 file(APPEND "${libaom_srcs_txt_file}" "${file}\n")
705 endif ()
706 endforeach ()
707endforeach ()
708
709# Libaom_srcs.gni generation.
710set(libaom_srcs_gni_file "${AOM_CONFIG_DIR}/libaom_srcs.gni")
711file(WRITE "${libaom_srcs_gni_file}" "# This file is generated. DO NOT EDIT.\n")
712
713foreach (aom_source_var ${aom_source_vars})
714 if ("${${aom_source_var}}" MATCHES "${AOM_ROOT}")
715 string(TOLOWER ${aom_source_var} aom_source_var_lowercase)
716 file(APPEND "${libaom_srcs_gni_file}" "\n${aom_source_var_lowercase} = [\n")
717 endif ()
718
719 foreach (file ${${aom_source_var}})
720 if (NOT "${file}" MATCHES "${AOM_CONFIG_DIR}")
721 string(REPLACE "${AOM_ROOT}" "//third_party/aom/src" file "${file}")
722 file(APPEND "${libaom_srcs_gni_file}" " \"${file}\",\n")
723 endif ()
724 endforeach ()
725
726 if ("${${aom_source_var}}" MATCHES "${AOM_ROOT}")
727 file(APPEND "${libaom_srcs_gni_file}" "]\n")
728 endif ()
729endforeach ()
730
731file(APPEND "${libaom_srcs_gni_file}"
732 "\n# Files below this line are generated by the libaom build system.\n")
733
734foreach (aom_source_var ${aom_source_vars})
735 if ("${${aom_source_var}}" MATCHES "${AOM_CONFIG_DIR}")
736 string(TOLOWER ${aom_source_var} aom_source_var_lowercase)
737 file(APPEND "${libaom_srcs_gni_file}"
738 "\n${aom_source_var_lowercase}_gen = [\n")
739 endif ()
740 foreach (file ${${aom_source_var}})
741 if (NOT "${file}" MATCHES "${AOM_ROOT}")
742 string(REPLACE "${AOM_CONFIG_DIR}" "//third_party/aom/src" file "${file}")
743 file(APPEND "${libaom_srcs_gni_file}" " \"${file}\",\n")
744 endif ()
745 endforeach ()
746
747 if ("${${aom_source_var}}" MATCHES "${AOM_CONFIG_DIR}")
748 file(APPEND "${libaom_srcs_gni_file}" "]\n")
749 endif ()
750endforeach ()