blob: 00d4cb19004fc6030257a8cf6daaa6648ec4341a [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
Tom Finegana0ff4562017-05-23 08:27:47 -070020option(ENABLE_CCACHE "Enable ccache support." OFF)
21option(ENABLE_DISTCC "Enable distcc support." OFF)
Tom Finegan0d066ce2017-05-30 11:07:05 -070022option(ENABLE_DOCS "Enable documentation generation (doxygen required)." ON)
Tom Finegan9befd172017-09-29 15:19:19 -070023option(ENABLE_EXAMPLES "Enables build of example code." ON)
Tom Fineganf67fd8a2017-08-10 14:57:11 -070024option(ENABLE_GOMA "Enable goma support." OFF)
Tom Finegan375ee842017-06-02 10:34:02 -070025option(ENABLE_IDE_TEST_HOSTING
26 "Enables running tests within IDEs like Visual Studio and Xcode." OFF)
Tom Finegan9befd172017-09-29 15:19:19 -070027option(ENABLE_NASM "Use nasm instead of yasm for x86 assembly." OFF)
28option(ENABLE_TOOLS "Enable applications in tools sub directory." ON)
29option(ENABLE_WERROR "Converts warnings to errors at compile time." OFF)
Tom Finegana0ff4562017-05-23 08:27:47 -070030
Tom Finegane3bae4a2017-10-12 09:06:31 -070031# ARM assembly/intrinsics flags.
32option(ENABLE_NEON "Enables NEON optimizations on ARM targets." ON)
33option(ENABLE_NEON_ASM "Enables NEON ASM optimizations on ARM targets." ON)
34
35# MIPS assembly/intrinsics flags.
36option(ENABLE_DSPR2 "Enables DSPR2 optimizations on MIPS targets." OFF)
37option(ENABLE_MSA "Enables MSA optimizations on MIPS targets." OFF)
38
Luca Barbatoba908f12018-03-22 15:41:50 +010039# VSX intrinsics flags.
40option(ENABLE_VSX "Enables VSX optimizations on PowerPC targets." ON)
41
Tom Finegane3bae4a2017-10-12 09:06:31 -070042# x86/x86_64 assembly/intrinsics flags.
43option(ENABLE_MMX "Enables MMX optimizations on x86/x86_64 targets." ON)
44option(ENABLE_SSE "Enables SSE optimizations on x86/x86_64 targets." ON)
45option(ENABLE_SSE2 "Enables SSE2 optimizations on x86/x86_64 targets." ON)
46option(ENABLE_SSE3 "Enables SSE3 optimizations on x86/x86_64 targets." ON)
47option(ENABLE_SSSE3 "Enables SSSE3 optimizations on x86/x86_64 targets." ON)
48option(ENABLE_SSE4_1 "Enables SSE4_1 optimizations on x86/x86_64 targets." ON)
PENGBINffda3772018-02-26 17:36:37 +080049option(ENABLE_SSE4_2 "Enables SSE4_2 optimizations on x86/x86_64 targets." ON)
Tom Finegane3bae4a2017-10-12 09:06:31 -070050option(ENABLE_AVX "Enables AVX optimizations on x86/x86_64 targets." ON)
51option(ENABLE_AVX2 "Enables AVX2 optimizations on x86/x86_64 targets." ON)
52
Tom Finegan84f2d792017-06-15 23:06:44 -070053# $BUILD_SHARED_LIBS is a CMake built-in-- it's listed here for visibility.
54option(BUILD_SHARED_LIBS "CMake should generate a shared library build." OFF)
55
Tom Fineganfc6f2362016-10-24 10:39:41 -070056project(AOM C CXX)
57
58set(AOM_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
Tom Finegan973d4d52016-10-26 11:42:42 -070059set(AOM_CONFIG_DIR "${CMAKE_CURRENT_BINARY_DIR}")
Robert-André Mauchinede351b2018-03-07 18:09:18 +010060set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH
61 "Installation path of includes")
62set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH
63 "Installation path of libraries")
Tom Finegan6e9d0c12016-10-27 11:57:06 -070064
Tom Fineganf77394f2017-04-26 11:47:59 -070065if ("${AOM_ROOT}" STREQUAL "${AOM_CONFIG_DIR}")
66 message(FATAL_ERROR
67 "Building from within the aom source tree is not supported.\n"
Tom Fineganbf7cd0d2018-01-19 12:05:19 -080068 "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.")
Tom Fineganf77394f2017-04-26 11:47:59 -070073endif ()
74
Tom Finegan973d4d52016-10-26 11:42:42 -070075include("${AOM_ROOT}/build/cmake/aom_configure.cmake")
Tom Finegan85ac13e2017-02-22 15:09:20 -080076include("${AOM_ROOT}/aom_dsp/aom_dsp.cmake")
Tom Finegandd6d0572017-03-01 19:01:23 -080077include("${AOM_ROOT}/aom_mem/aom_mem.cmake")
Tom Finegan507e2e12017-03-01 19:58:19 -080078include("${AOM_ROOT}/aom_ports/aom_ports.cmake")
Tom Fineganf0d14442017-03-01 20:42:51 -080079include("${AOM_ROOT}/aom_scale/aom_scale.cmake")
Tom Fineganb7d02542017-03-01 21:14:28 -080080include("${AOM_ROOT}/aom_util/aom_util.cmake")
Tom Finegan44916e72017-02-27 14:12:31 -080081include("${AOM_ROOT}/av1/av1.cmake")
Tom Finegan4db04d32017-02-23 14:37:27 -080082include("${AOM_ROOT}/test/test.cmake")
Tom Finegan8cc239b2017-08-07 12:28:12 -070083include("${AOM_ROOT}/build/cmake/sanitizers.cmake")
Tom Finegan84f2d792017-06-15 23:06:44 -070084include("${AOM_ROOT}/build/cmake/util.cmake")
Tom Finegan85ac13e2017-02-22 15:09:20 -080085
Tom Finegan393b79b2018-05-02 10:49:56 -070086list(APPEND AOM_RTCD_SOURCES
Tom Finegana0c21f02017-02-01 11:11:09 -080087 "${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")
97
Tom Finegan957fe822016-11-09 10:37:27 -080098# TODO(tomfinegan): Use libwebm's cmake support directly.
Tom Finegan393b79b2018-05-02 10:49:56 -070099list(APPEND AOM_LIBWEBM_SOURCES
Tom Finegan957fe822016-11-09 10:37:27 -0800100 "${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")
114
Tom Finegan393b79b2018-05-02 10:49:56 -0700115list(APPEND AOM_LIBYUV_SOURCES
Tom Finegan9cd97002016-11-09 10:37:44 -0800116 "${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")
143
Tom Finegan393b79b2018-05-02 10:49:56 -0700144list(APPEND AOM_SOURCES
Tom Finegan973d4d52016-10-26 11:42:42 -0700145 "${AOM_CONFIG_DIR}/aom_config.c"
146 "${AOM_CONFIG_DIR}/aom_config.h"
Tom Fineganfc6f2362016-10-24 10:39:41 -0700147 "${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"
Tom Finegan10fea492018-01-08 18:07:46 -0800160 "${AOM_ROOT}/aom/src/aom_image.c"
161 "${AOM_ROOT}/aom/src/aom_integer.c")
Tom Fineganfc6f2362016-10-24 10:39:41 -0700162
Tom Finegan393b79b2018-05-02 10:49:56 -0700163list(APPEND AOM_COMMON_APP_UTIL_SOURCES
Tom Finegana89fe0e2017-01-19 14:38:28 -0800164 "${AOM_ROOT}/args.c"
165 "${AOM_ROOT}/args.h"
Tom Finegan03f6ca72016-11-10 13:02:48 -0800166 "${AOM_ROOT}/md5_utils.c"
167 "${AOM_ROOT}/md5_utils.h"
168 "${AOM_ROOT}/tools_common.c"
169 "${AOM_ROOT}/tools_common.h"
Tom Fineganba02c242017-05-16 15:01:54 -0700170 "${AOM_ROOT}/video_common.h"
171 "${AOM_ROOT}/y4menc.c"
172 "${AOM_ROOT}/y4menc.h")
Tom Finegan03f6ca72016-11-10 13:02:48 -0800173
Tom Finegan393b79b2018-05-02 10:49:56 -0700174list(APPEND AOM_DECODER_APP_UTIL_SOURCES
Tom Finegan03f6ca72016-11-10 13:02:48 -0800175 "${AOM_ROOT}/ivfdec.c"
176 "${AOM_ROOT}/ivfdec.h"
Tom Finegan61b71ab2018-03-22 15:58:38 -0700177 "${AOM_ROOT}/obudec.c"
178 "${AOM_ROOT}/obudec.h"
Tom Finegan03f6ca72016-11-10 13:02:48 -0800179 "${AOM_ROOT}/video_reader.c"
Tom Fineganba02c242017-05-16 15:01:54 -0700180 "${AOM_ROOT}/video_reader.h")
Tom Finegan03f6ca72016-11-10 13:02:48 -0800181
Tom Finegan393b79b2018-05-02 10:49:56 -0700182list(APPEND AOM_ENCODER_APP_UTIL_SOURCES
Tom Finegan03f6ca72016-11-10 13:02:48 -0800183 "${AOM_ROOT}/ivfenc.c"
184 "${AOM_ROOT}/ivfenc.h"
185 "${AOM_ROOT}/video_writer.c"
Tom Finegana89fe0e2017-01-19 14:38:28 -0800186 "${AOM_ROOT}/video_writer.h"
187 "${AOM_ROOT}/warnings.c"
188 "${AOM_ROOT}/warnings.h"
189 "${AOM_ROOT}/y4minput.c"
Urvang Joshi09c293e2017-04-20 17:56:27 -0700190 "${AOM_ROOT}/y4minput.h"
191 "${AOM_ROOT}/examples/encoder_util.h"
192 "${AOM_ROOT}/examples/encoder_util.c")
Tom Finegana89fe0e2017-01-19 14:38:28 -0800193
Tom Finegan393b79b2018-05-02 10:49:56 -0700194list(APPEND AOM_ENCODER_STATS_SOURCES
Tom Finegana89fe0e2017-01-19 14:38:28 -0800195 "${AOM_ROOT}/aomstats.c"
196 "${AOM_ROOT}/aomstats.h"
197 "${AOM_ROOT}/rate_hist.c"
198 "${AOM_ROOT}/rate_hist.h")
199
Tom Finegan393b79b2018-05-02 10:49:56 -0700200list(APPEND AOM_PKG_CONFIG_SOURCES "${AOM_CONFIG_DIR}/aom.pc")
Tom Finegan872e5852017-08-29 15:15:58 -0700201
Tom Finegan393b79b2018-05-02 10:49:56 -0700202list(APPEND AOM_VERSION_SOURCES "${AOM_CONFIG_DIR}/aom_version.h")
Tom Finegan872e5852017-08-29 15:15:58 -0700203
Tom Finegan393b79b2018-05-02 10:49:56 -0700204list(APPEND AOM_WEBM_DECODER_SOURCES
Tom Finegana89fe0e2017-01-19 14:38:28 -0800205 "${AOM_ROOT}/webmdec.cc"
206 "${AOM_ROOT}/webmdec.h")
207
Tom Finegan393b79b2018-05-02 10:49:56 -0700208list(APPEND AOM_WEBM_ENCODER_SOURCES
Tom Finegana89fe0e2017-01-19 14:38:28 -0800209 "${AOM_ROOT}/webmenc.cc"
210 "${AOM_ROOT}/webmenc.h")
211
212include_directories(${AOM_ROOT} ${AOM_CONFIG_DIR})
Tom Finegan03f6ca72016-11-10 13:02:48 -0800213
Tom Fineganfc6f2362016-10-24 10:39:41 -0700214# Targets
Tom Finegan872e5852017-08-29 15:15:58 -0700215add_library(aom_version ${AOM_VERSION_SOURCES})
216add_dummy_source_file_to_target(aom_version c)
217add_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)
227
228add_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)
237add_dependencies(aom_version aom_version_check)
238
239if (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}
Tom Finegan40b2a972017-09-25 09:45:27 -0700247 -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
Tom Finegan872e5852017-08-29 15:15:58 -0700248 -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)
Tom Finegan00b4df72017-09-01 11:30:34 -0700254 add_dependencies(aom_pc aom_version)
Tom Finegan872e5852017-08-29 15:15:58 -0700255endif ()
Tom Finegan872e5852017-08-29 15:15:58 -0700256
Tom Fineganf0d14442017-03-01 20:42:51 -0800257# TODO(tomfinegan): Move rtcd target setup where it belongs for each rtcd
258# source.
Tom Finegana0c21f02017-02-01 11:11:09 -0800259add_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")
263add_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")
267add_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")
Tom Finegan85ac13e2017-02-22 15:09:20 -0800271
Tom Finegana0c21f02017-02-01 11:11:09 -0800272add_library(aom_rtcd OBJECT ${AOM_RTCD_SOURCES})
Tom Finegan872e5852017-08-29 15:15:58 -0700273add_dependencies(aom_rtcd aom_version)
274
Tom Finegana7ed1432017-02-08 10:34:40 -0800275add_library(aom_encoder_stats OBJECT ${AOM_ENCODER_STATS_SOURCES})
Tom Fineganb7d02542017-03-01 21:14:28 -0800276add_library(aom ${AOM_SOURCES} $<TARGET_OBJECTS:aom_rtcd>)
Tom Finegan03f6ca72016-11-10 13:02:48 -0800277
Tom Finegan3e8986b2017-09-29 17:08:31 -0700278if (NOT MSVC AND NOT APPLE)
279 target_link_libraries(aom ${AOM_LIB_LINK_TYPE} m)
280endif ()
281
Tom Finegana0c21f02017-02-01 11:11:09 -0800282# List of object and static library targets.
Tom Fineganb7d02542017-03-01 21:14:28 -0800283set(AOM_LIB_TARGETS ${AOM_LIB_TARGETS} aom_rtcd aom_encoder_stats aom_mem
284 aom_scale aom)
Tom Finegana0c21f02017-02-01 11:11:09 -0800285
Tom Finegan507e2e12017-03-01 19:58:19 -0800286# Setup dependencies.
Tom Finegan85ac13e2017-02-22 15:09:20 -0800287setup_aom_dsp_targets()
Tom Finegandd6d0572017-03-01 19:01:23 -0800288setup_aom_mem_targets()
Tom Finegan507e2e12017-03-01 19:58:19 -0800289setup_aom_ports_targets()
Tom Fineganb7d02542017-03-01 21:14:28 -0800290setup_aom_util_targets()
Tom Fineganf0d14442017-03-01 20:42:51 -0800291setup_aom_scale_targets()
Tom Finegan44916e72017-02-27 14:12:31 -0800292setup_av1_targets()
Tom Finegan85ac13e2017-02-22 15:09:20 -0800293
Tom Finegana0c21f02017-02-01 11:11:09 -0800294# Make all library targets depend on aom_rtcd to make sure it builds first.
295foreach (aom_lib ${AOM_LIB_TARGETS})
296 if (NOT "${aom_lib}" STREQUAL "aom_rtcd")
297 add_dependencies(${aom_lib} aom_rtcd)
298 endif ()
299endforeach ()
Tom Fineganba02c242017-05-16 15:01:54 -0700300
Tom Fineganff863952017-12-22 11:41:14 -0800301# Generate C/C++ stub files containing the function usage_exit(). Users of the
Tom Finegane91bb452017-09-29 11:40:24 -0700302# 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
Tom Fineganff863952017-12-22 11:41:14 -0800304# other pieces of the util support without defining usage_exit().
Tom Finegane91bb452017-09-29 11:40:24 -0700305file(WRITE "${AOM_CONFIG_DIR}/usage_exit.c" "void usage_exit(void) {}")
Tom Fineganff863952017-12-22 11:41:14 -0800306file(WRITE "${AOM_CONFIG_DIR}/usage_exit.cc"
307 "extern \"C\" void usage_exit(void) {}")
Tom Finegan03f6ca72016-11-10 13:02:48 -0800308
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700309#
310# Application and application support targets.
311#
312if (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})
James Zern41387402018-03-03 13:53:17 -0800316 # obudec depends on internal headers that require *rtcd.h
Tom Finegan61b71ab2018-03-22 15:58:38 -0700317 add_dependencies(aom_decoder_app_util aom_rtcd)
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700318 endif ()
319 if (CONFIG_AV1_ENCODER)
320 add_library(aom_encoder_app_util OBJECT ${AOM_ENCODER_APP_UTIL_SOURCES})
321 endif ()
322endif ()
323
324if (CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
Tom Fineganba02c242017-05-16 15:01:54 -0700325 add_executable(aomdec
Tom Finegan84f2d792017-06-15 23:06:44 -0700326 "${AOM_ROOT}/aomdec.c"
327 $<TARGET_OBJECTS:aom_common_app_util>
328 $<TARGET_OBJECTS:aom_decoder_app_util>)
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700329 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>)
Yaowu Xu7f313c02018-03-28 12:50:16 -0700341 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>)
Tom Finegan393b79b2018-05-02 10:49:56 -0700345
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700346 if (CONFIG_ANALYZER)
347 add_executable(analyzer
348 "${AOM_ROOT}/examples/analyzer.cc"
Tom Finegan9befd172017-09-29 15:19:19 -0700349 $<TARGET_OBJECTS:aom_common_app_util>
350 $<TARGET_OBJECTS:aom_decoder_app_util>)
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700351 target_link_libraries(analyzer
352 ${AOM_LIB_LINK_TYPE} ${wxWidgets_LIBRARIES})
Tom Finegan393b79b2018-05-02 10:49:56 -0700353 list(APPEND AOM_APP_TARGETS analyzer)
354 list(APPEND AOM_DECODER_EXAMPLE_TARGETS analyzer)
Tom Fineganba02c242017-05-16 15:01:54 -0700355 endif ()
356
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700357 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>)
Tom Finegan393b79b2018-05-02 10:49:56 -0700362 list(APPEND AOM_DECODER_EXAMPLE_TARGETS inspect)
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700363
364 if (EMSCRIPTEN)
365 add_preproc_definition(_POSIX_SOURCE)
Thomas Daede32fc4072018-01-12 04:04:24 -0800366 append_link_flag_to_target("inspect" "-s TOTAL_MEMORY=402653184")
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700367 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")
371
372 if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
373 # Default to -O3 when no build type specified.
374 append_compiler_flag("-O3")
375 endif ()
376
377 em_link_post_js(inspect "${AOM_ROOT}/tools/inspect-post.js")
378 endif ()
379 endif ()
380
381 # Maintain a list of decoder example targets.
Tom Finegan393b79b2018-05-02 10:49:56 -0700382 list(APPEND AOM_DECODER_EXAMPLE_TARGETS
383 aomdec decode_to_md5 decode_with_drops scalable_decoder simple_decoder)
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700384
Tom Finegan9befd172017-09-29 15:19:19 -0700385 # Add decoder examples to the app targets list.
Tom Finegan393b79b2018-05-02 10:49:56 -0700386 list(APPEND AOM_APP_TARGETS ${AOM_DECODER_EXAMPLE_TARGETS})
Michael Bebenitaf4f27fe2017-03-02 17:40:44 -0800387endif ()
388
Tom Fineganba02c242017-05-16 15:01:54 -0700389if (CONFIG_AV1_ENCODER)
Tom Finegan9befd172017-09-29 15:19:19 -0700390 if (ENABLE_EXAMPLES)
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700391 add_executable(aomenc
392 "${AOM_ROOT}/aomenc.c"
393 $<TARGET_OBJECTS:aom_common_app_util>
394 $<TARGET_OBJECTS:aom_encoder_app_util>
395 $<TARGET_OBJECTS:aom_encoder_stats>)
Tom Finegan9befd172017-09-29 15:19:19 -0700396 add_executable(lossless_encoder
397 "${AOM_ROOT}/examples/lossless_encoder.c"
Tom Finegane91bb452017-09-29 11:40:24 -0700398 $<TARGET_OBJECTS:aom_common_app_util>
399 $<TARGET_OBJECTS:aom_encoder_app_util>)
Tom Finegan9befd172017-09-29 15:19:19 -0700400 add_executable(set_maps
401 "${AOM_ROOT}/examples/set_maps.c"
402 $<TARGET_OBJECTS:aom_common_app_util>
403 $<TARGET_OBJECTS:aom_encoder_app_util>)
404 add_executable(simple_encoder
405 "${AOM_ROOT}/examples/simple_encoder.c"
406 $<TARGET_OBJECTS:aom_common_app_util>
407 $<TARGET_OBJECTS:aom_encoder_app_util>)
408 add_executable(twopass_encoder
409 "${AOM_ROOT}/examples/twopass_encoder.c"
410 $<TARGET_OBJECTS:aom_common_app_util>
411 $<TARGET_OBJECTS:aom_encoder_app_util>)
Yaowu Xuc7119a72018-03-29 09:59:37 -0700412 add_executable(noise_model
413 "${AOM_ROOT}/examples/noise_model.c"
414 $<TARGET_OBJECTS:aom_common_app_util>
415 $<TARGET_OBJECTS:aom_encoder_app_util>)
416 add_executable(scalable_encoder
417 "${AOM_ROOT}/examples/scalable_encoder.c"
418 $<TARGET_OBJECTS:aom_common_app_util>
419 $<TARGET_OBJECTS:aom_encoder_app_util>)
Tom Finegan9befd172017-09-29 15:19:19 -0700420
421 # Maintain a list of encoder example targets.
Tom Finegan393b79b2018-05-02 10:49:56 -0700422 list(APPEND AOM_ENCODER_EXAMPLE_TARGETS
423 aomenc lossless_encoder noise_model set_maps simple_encoder
424 scalable_encoder twopass_encoder)
Tom Finegane91bb452017-09-29 11:40:24 -0700425 endif ()
426
Tom Fineganbac99072017-10-11 09:16:54 -0700427 if (ENABLE_TOOLS)
428 if (CONFIG_ENTROPY_STATS AND NOT BUILD_SHARED_LIBS)
429 # TODO(tomfinegan): Sort out why a simple link command with
430 # aom_entropy_optimizer.c won't work on macos, but dragging in all the
431 # helper machinery allows the link to succeed.
432 add_executable(aom_entropy_optimizer
433 "${AOM_CONFIG_DIR}/usage_exit.c"
434 "${AOM_ROOT}/tools/aom_entropy_optimizer.c"
435 $<TARGET_OBJECTS:aom_common_app_util>
436 $<TARGET_OBJECTS:aom_encoder_app_util>)
Tom Finegan9befd172017-09-29 15:19:19 -0700437
Tom Fineganbac99072017-10-11 09:16:54 -0700438 # Maintain a list of encoder tool targets.
Tom Finegan393b79b2018-05-02 10:49:56 -0700439 list(APPEND AOM_ENCODER_TOOL_TARGETS aom_entropy_optimizer)
Tom Fineganbac99072017-10-11 09:16:54 -0700440 endif ()
Tom Finegan9befd172017-09-29 15:19:19 -0700441 endif ()
Tom Fineganbac99072017-10-11 09:16:54 -0700442
443 # Add encoder examples and tools to the targets list.
Tom Finegan393b79b2018-05-02 10:49:56 -0700444 list(APPEND AOM_APP_TARGETS
445 ${AOM_ENCODER_EXAMPLE_TARGETS} ${AOM_ENCODER_TOOL_TARGETS})
Tom Fineganba02c242017-05-16 15:01:54 -0700446endif ()
447
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700448if (ENABLE_EXAMPLES)
449 # Maintain a separate variable listing only the examples to facilitate
450 # installation of example programs into an examples sub directory of
451 # $AOM_DIST_DIR/bin when building the dist target.
Tom Finegan393b79b2018-05-02 10:49:56 -0700452 list(APPEND AOM_EXAMPLE_TARGETS
453 ${AOM_DECODER_EXAMPLE_TARGETS} ${AOM_ENCODER_EXAMPLE_TARGETS})
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700454endif ()
Tom Finegan78975672017-05-30 08:55:54 -0700455
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700456if (ENABLE_TOOLS)
Yaowu Xud29ea972018-02-22 09:50:58 -0800457 if (CONFIG_AV1_DECODER)
Tom Fineganff863952017-12-22 11:41:14 -0800458 require_cxx_flag_nomsvc("-std=c++11" NO)
Tom Fineganc0192332017-12-02 09:31:45 -0800459 add_executable(dump_obu
Tom Fineganff863952017-12-22 11:41:14 -0800460 "${AOM_CONFIG_DIR}/usage_exit.cc"
Tom Fineganc0192332017-12-02 09:31:45 -0800461 "${AOM_ROOT}/tools/dump_obu.cc"
462 "${AOM_ROOT}/tools/obu_parser.cc"
463 "${AOM_ROOT}/tools/obu_parser.h"
464 $<TARGET_OBJECTS:aom_common_app_util>
465 $<TARGET_OBJECTS:aom_decoder_app_util>)
Tom Fineganff863952017-12-22 11:41:14 -0800466
Tom Fineganc0192332017-12-02 09:31:45 -0800467 list(APPEND AOM_TOOL_TARGETS dump_obu)
468 list(APPEND AOM_APP_TARGETS dump_obu)
Tom Fineganc0192332017-12-02 09:31:45 -0800469
Tom Fineganff863952017-12-22 11:41:14 -0800470 if (NOT MSVC)
471 target_compile_options(dump_obu PUBLIC -std=c++11)
472 # TODO(tomfinegan): This can go once the GCC pragma in libwebm is updated
473 # to silence the auto_ptr warnings for GCC >= v4.
474 target_compile_options(dump_obu PUBLIC -Wno-deprecated-declarations)
475 endif ()
476
477 # Maintain a separate variable listing only the examples to facilitate
478 # installation of example programs into an tools sub directory of
479 # $AOM_DIST_DIR/bin when building the dist target.
480 list(APPEND AOM_TOOL_TARGETS
481 ${AOM_DECODER_TOOL_TARGETS} ${AOM_ENCODER_TOOL_TARGETS})
482 endif ()
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700483endif ()
Tom Finegane91bb452017-09-29 11:40:24 -0700484
Tom Finegan9befd172017-09-29 15:19:19 -0700485if (ENABLE_EXAMPLES AND CONFIG_AV1_DECODER AND CONFIG_AV1_ENCODER)
Tom Fineganba02c242017-05-16 15:01:54 -0700486 add_executable(aom_cx_set_ref
487 "${AOM_ROOT}/examples/aom_cx_set_ref.c"
488 $<TARGET_OBJECTS:aom_common_app_util>
489 $<TARGET_OBJECTS:aom_encoder_app_util>)
Tom Finegan393b79b2018-05-02 10:49:56 -0700490 list(APPEND AOM_EXAMPLE_TARGETS aom_cx_set_ref)
491 list(APPEND AOM_APP_TARGETS aom_cx_set_ref)
Tom Fineganba02c242017-05-16 15:01:54 -0700492endif ()
Tom Finegan81279802017-02-01 11:27:05 -0800493
494foreach (aom_app ${AOM_APP_TARGETS})
Tom Finegand46b4d32017-05-09 09:14:03 -0700495 target_link_libraries(${aom_app} ${AOM_LIB_LINK_TYPE} aom)
Tom Finegan81279802017-02-01 11:27:05 -0800496endforeach ()
Tom Fineganfc6f2362016-10-24 10:39:41 -0700497
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700498if (CONFIG_UNIT_TESTS OR ENABLE_EXAMPLES OR ENABLE_TOOLS)
499 if (CONFIG_LIBYUV)
500 add_library(yuv OBJECT ${AOM_LIBYUV_SOURCES})
501 if (NOT MSVC)
502 target_compile_options(yuv PRIVATE -Wno-unused-parameter)
503 endif ()
504 include_directories("${AOM_ROOT}/third_party/libyuv/include")
Tom Finegan9cd97002016-11-09 10:37:44 -0800505
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700506 # Add to existing targets.
507 foreach (aom_app ${AOM_APP_TARGETS})
508 target_sources(${aom_app} PRIVATE $<TARGET_OBJECTS:yuv>)
509 set_property(TARGET ${aom_app} PROPERTY LINKER_LANGUAGE CXX)
510 endforeach ()
Tom Finegan87fdc282017-02-10 10:30:28 -0800511 endif ()
Tom Finegan957fe822016-11-09 10:37:27 -0800512
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700513 if (CONFIG_WEBM_IO)
514 add_library(webm OBJECT ${AOM_LIBWEBM_SOURCES})
515 include_directories("${AOM_ROOT}/third_party/libwebm")
516 target_compile_definitions(webm PRIVATE __STDC_CONSTANT_MACROS)
517 target_compile_definitions(webm PRIVATE __STDC_LIMIT_MACROS)
Tom Fineganba02c242017-05-16 15:01:54 -0700518
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700519 if (NOT MSVC)
520 target_compile_options(webm PRIVATE -Wno-shadow)
521 endif ()
Tom Finegan81279802017-02-01 11:27:05 -0800522
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700523 # Add to existing targets.
524 if (CONFIG_AV1_DECODER)
525 target_sources(aom_decoder_app_util PRIVATE ${AOM_WEBM_DECODER_SOURCES})
526 endif ()
527
528 if (CONFIG_AV1_ENCODER)
529 target_sources(aom_encoder_app_util PRIVATE ${AOM_WEBM_ENCODER_SOURCES})
530 endif ()
531
532 foreach (aom_app ${AOM_APP_TARGETS})
533 target_sources(${aom_app} PRIVATE $<TARGET_OBJECTS:webm>)
534 set_property(TARGET ${aom_app} PROPERTY LINKER_LANGUAGE CXX)
535 endforeach ()
536 endif ()
Tom Finegan957fe822016-11-09 10:37:27 -0800537endif ()
Tom Finegan7ba9ba82017-01-23 14:04:28 -0800538
539if (CONFIG_UNIT_TESTS)
Tom Finegan4db04d32017-02-23 14:37:27 -0800540 # Create test_libaom target and the targets it depends on.
541 setup_aom_test_targets()
Tom Finegan7ba9ba82017-01-23 14:04:28 -0800542endif ()
Tom Finegan9412ec32017-02-01 11:41:43 -0800543
Tom Finegan606f6462017-03-06 11:18:29 -0800544if (HAVE_PTHREAD_H AND CONFIG_MULTITHREAD)
545 find_package(Threads)
546 foreach (app_target ${AOM_APP_TARGETS})
Tom Finegand46b4d32017-05-09 09:14:03 -0700547 target_link_libraries(${app_target} ${AOM_LIB_LINK_TYPE} Threads::Threads)
Tom Finegan606f6462017-03-06 11:18:29 -0800548 endforeach ()
549endif ()
550
Tom Finegan9412ec32017-02-01 11:41:43 -0800551if (XCODE)
Tom Finegandb37c752017-11-30 17:02:27 -0800552 # TODO(tomfinegan): Make sure target has no C++ files before doing this as
553 # it's not necessary in that case.
Tom Finegan9412ec32017-02-01 11:41:43 -0800554 if (CONFIG_LIBYUV OR CONFIG_WEBM_IO)
555 # The Xcode generator does not obey LINKER_LANGUAGE. Because of the issue
556 # what looks like a C++ file needs to be in any target that Xcode will link
557 # when the target contains a C++ dependency.
558 # Without this Xcode will try to link with the C linker, which always ends
559 # badly when a dependency actually includes C++.
560 # Note: LINKER_LANGUAGE is explicitly set to C++ for all targets touched
561 # here, it really is the Xcode generator's fault, or just a deficiency in
562 # Xcode itself.
Tom Finegan9412ec32017-02-01 11:41:43 -0800563 foreach (aom_app ${AOM_APP_TARGETS})
Tom Finegan84f2d792017-06-15 23:06:44 -0700564 add_dummy_source_file_to_target("${aom_app}" "cc")
Tom Finegan9412ec32017-02-01 11:41:43 -0800565 endforeach ()
566 endif ()
567endif ()
Tom Finegan0a4ef082017-03-31 11:07:34 -0700568
Tom Finegan9befd172017-09-29 15:19:19 -0700569if (ENABLE_EXAMPLES AND "${CMAKE_GENERATOR}" MATCHES "Makefiles$")
Johanne07a6752018-01-10 12:47:44 -0800570 # For historical purposes place the example binaries in the example directory.
Tom Finegan78975672017-05-30 08:55:54 -0700571 file(MAKE_DIRECTORY "${AOM_CONFIG_DIR}/examples")
Tom Finegan938172c2017-10-07 13:58:34 -0700572
573 foreach (target ${AOM_EXAMPLE_TARGETS})
574 if (NOT "${target}" MATCHES "aomdec\|aomenc")
575 set_target_properties(${target} PROPERTIES
576 RUNTIME_OUTPUT_DIRECTORY
577 "${AOM_CONFIG_DIR}/examples")
578 endif ()
579 endforeach ()
Tom Finegane91bb452017-09-29 11:40:24 -0700580
Tom Finegan9befd172017-09-29 15:19:19 -0700581 if (ENABLE_TOOLS AND AOM_TOOL_TARGETS)
Tom Finegane91bb452017-09-29 11:40:24 -0700582 # The same expectation is true for tool targets.
583 file(MAKE_DIRECTORY "${AOM_CONFIG_DIR}/tools")
584 set_target_properties(${AOM_TOOL_TARGETS} PROPERTIES
585 RUNTIME_OUTPUT_DIRECTORY "${AOM_CONFIG_DIR}/tools")
586 endif ()
Tom Finegan78975672017-05-30 08:55:54 -0700587endif ()
588
Tom Finegan84f2d792017-06-15 23:06:44 -0700589if (BUILD_SHARED_LIBS)
590 include("${AOM_ROOT}/build/cmake/exports.cmake")
591 setup_exports_target()
Tom Finegan4a3a9c02017-07-14 08:34:20 -0700592 set_target_properties(aom PROPERTIES SOVERSION 0)
Tom Finegan84f2d792017-06-15 23:06:44 -0700593endif ()
594
Tom Fineganc8593982017-09-05 11:01:09 -0700595# Handle user supplied compile and link flags last to ensure they're obeyed.
596set_user_flags()
597
Tom Finegan0d066ce2017-05-30 11:07:05 -0700598# Aomedia documentation rule.
599if (ENABLE_DOCS)
600 include(FindDoxygen)
601 if (DOXYGEN_FOUND)
602 include("${AOM_ROOT}/docs.cmake")
603 setup_documentation_targets()
604 else ()
605 message("--- Cannot find doxygen, ENABLE_DOCS turned off.")
606 set(ENABLE_DOCS OFF)
607 endif ()
608endif ()
609
Tom Finegan0a4ef082017-03-31 11:07:34 -0700610# Aomedia install rule.
Tom Finegan393b79b2018-05-02 10:49:56 -0700611list(APPEND AOM_INSTALL_INCS
612 "${AOM_ROOT}/aom/aom.h"
613 "${AOM_ROOT}/aom/aom_codec.h"
614 "${AOM_ROOT}/aom/aom_frame_buffer.h"
615 "${AOM_ROOT}/aom/aom_image.h"
616 "${AOM_ROOT}/aom/aom_integer.h"
617 "${AOM_ROOT}/aom/aom.h")
Tom Fineganba02c242017-05-16 15:01:54 -0700618
619if (CONFIG_AV1_DECODER)
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700620 if (ENABLE_EXAMPLES)
Tom Finegan393b79b2018-05-02 10:49:56 -0700621 list(APPEND AOM_INSTALL_BINS aomdec)
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700622 endif ()
623
Tom Finegan393b79b2018-05-02 10:49:56 -0700624 list(APPEND AOM_INSTALL_INCS
Tom Fineganba02c242017-05-16 15:01:54 -0700625 "${AOM_ROOT}/aom/aom_decoder.h"
626 "${AOM_ROOT}/aom/aomdx.h")
627endif ()
628
629if (CONFIG_AV1_ENCODER)
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700630 if (ENABLE_EXAMPLES)
Tom Finegan393b79b2018-05-02 10:49:56 -0700631 list(APPEND AOM_INSTALL_BINS aomenc)
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700632 endif ()
633
Tom Finegan393b79b2018-05-02 10:49:56 -0700634 list(APPEND AOM_INSTALL_INCS
635 "${AOM_ROOT}/aom/aomcx.h"
636 "${AOM_ROOT}/aom/aom_encoder.h")
Tom Fineganba02c242017-05-16 15:01:54 -0700637endif ()
638
Tom Finegan0a4ef082017-03-31 11:07:34 -0700639set(AOM_INSTALL_LIBS aom)
640
641install(FILES ${AOM_INSTALL_INCS}
Robert-André Mauchinede351b2018-03-07 18:09:18 +0100642 DESTINATION "${INCLUDE_INSTALL_DIR}/aom")
Tom Finegan782cdc12017-05-12 10:08:53 -0700643install(FILES "${AOM_CONFIG_DIR}/aom.pc"
Robert-André Mauchinede351b2018-03-07 18:09:18 +0100644 DESTINATION "${LIB_INSTALL_DIR}/pkgconfig")
645install(TARGETS ${AOM_INSTALL_LIBS} DESTINATION "${LIB_INSTALL_DIR}")
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700646
647if (ENABLE_EXAMPLES)
648 install(TARGETS ${AOM_INSTALL_BINS} DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
649endif ()
Tom Finegan0d066ce2017-05-30 11:07:05 -0700650
Tom Finegan78975672017-05-30 08:55:54 -0700651# Aomedia dist rule.
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700652if (CONFIG_AV1_DECODER AND ENABLE_EXAMPLES)
Tom Finegan393b79b2018-05-02 10:49:56 -0700653 list(APPEND AOM_DIST_APPS $<TARGET_FILE:aomdec>)
Tom Finegan78975672017-05-30 08:55:54 -0700654endif ()
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700655if (CONFIG_AV1_ENCODER AND ENABLE_EXAMPLES)
Tom Finegan393b79b2018-05-02 10:49:56 -0700656 list(APPEND AOM_DIST_APPS $<TARGET_FILE:aomenc>)
Tom Finegan78975672017-05-30 08:55:54 -0700657endif ()
658
Tom Finegan9befd172017-09-29 15:19:19 -0700659if (ENABLE_EXAMPLES)
660 foreach (example ${AOM_EXAMPLE_TARGETS})
661 list(APPEND AOM_DIST_EXAMPLES $<TARGET_FILE:${example}>)
662 endforeach ()
663endif ()
Tom Finegan78975672017-05-30 08:55:54 -0700664
Tom Finegan9befd172017-09-29 15:19:19 -0700665if (ENABLE_TOOLS)
666 foreach (tool ${AOM_TOOL_TARGETS})
667 list(APPEND AOM_DIST_TOOLS $<TARGET_FILE:${tool}>)
668 endforeach ()
669endif ()
Tom Finegane91bb452017-09-29 11:40:24 -0700670
Tom Finegan78975672017-05-30 08:55:54 -0700671if (NOT AOM_DIST_DIR)
672 set(AOM_DIST_DIR "${AOM_CONFIG_DIR}/dist")
673endif ()
674
675add_custom_target(dist
676 COMMAND ${CMAKE_COMMAND}
677 -DAOM_ROOT=${AOM_ROOT}
678 -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
679 -DAOM_DIST_DIR=${AOM_DIST_DIR}
680 -DAOM_DIST_APPS="${AOM_DIST_APPS}"
681 -DAOM_DIST_EXAMPLES="${AOM_DIST_EXAMPLES}"
Tom Finegane91bb452017-09-29 11:40:24 -0700682 -DAOM_DIST_TOOLS="${AOM_DIST_TOOLS}"
Tom Finegan78975672017-05-30 08:55:54 -0700683 -DAOM_DIST_INCLUDES="${AOM_INSTALL_INCS}"
684 -DAOM_DIST_LIBS=$<TARGET_FILE:aom>
685 -DENABLE_DOCS=${ENABLE_DOCS}
686 -P "${AOM_ROOT}/build/cmake/dist.cmake"
687 DEPENDS ${AOM_INSTALL_BINS} ${AOM_INSTALL_LIBS}
Tom Finegan9cc0cfe2017-10-03 16:19:43 -0700688 ${AOM_INSTALL_INCS} ${AOM_EXAMPLE_TARGETS}
689 ${AOM_TOOL_TARGETS})
Tom Finegan78975672017-05-30 08:55:54 -0700690
Tom Finegan0d066ce2017-05-30 11:07:05 -0700691if (ENABLE_DOCS)
Tom Finegan78975672017-05-30 08:55:54 -0700692 add_dependencies(dist docs)
Tom Finegan0d066ce2017-05-30 11:07:05 -0700693endif ()
Tom Fineganc34abc82017-10-13 12:04:59 -0700694
695# Collect all variables containing libaom source files.
696get_cmake_property(all_cmake_vars VARIABLES)
697foreach (var ${all_cmake_vars})
698 if ("${var}" MATCHES "SOURCES$\|_INTRIN_\|_ASM_" AND NOT
699 "${var}" MATCHES "_APP_\|DOXYGEN\|LIBWEBM\|LIBYUV\|_PKG_\|TEST")
700 list(APPEND aom_source_vars ${var})
701 endif ()
702endforeach ()
703
704# Libaom_srcs.txt generation.
705set(libaom_srcs_txt_file "${AOM_CONFIG_DIR}/libaom_srcs.txt")
706file(WRITE "${libaom_srcs_txt_file}" "# This file is generated. DO NOT EDIT.\n")
707
708# Static source file list first.
709foreach (aom_source_var ${aom_source_vars})
710 foreach (file ${${aom_source_var}})
711 if (NOT "${file}" MATCHES "${AOM_CONFIG_DIR}")
712 string(REPLACE "${AOM_ROOT}/" "" file "${file}")
713 file(APPEND "${libaom_srcs_txt_file}" "${file}\n")
714 endif ()
715 endforeach ()
716endforeach ()
717
718file(APPEND "${libaom_srcs_txt_file}"
719 "# Files below this line are generated by the libaom build system.\n")
720foreach (aom_source_var ${aom_source_vars})
721 foreach (file ${${aom_source_var}})
722 if ("${file}" MATCHES "${AOM_CONFIG_DIR}")
723 string(REPLACE "${AOM_CONFIG_DIR}/" "" file "${file}")
724 file(APPEND "${libaom_srcs_txt_file}" "${file}\n")
725 endif ()
726 endforeach ()
727endforeach ()
728
729# Libaom_srcs.gni generation.
730set(libaom_srcs_gni_file "${AOM_CONFIG_DIR}/libaom_srcs.gni")
731file(WRITE "${libaom_srcs_gni_file}" "# This file is generated. DO NOT EDIT.\n")
732
733foreach (aom_source_var ${aom_source_vars})
734 if ("${${aom_source_var}}" MATCHES "${AOM_ROOT}")
735 string(TOLOWER ${aom_source_var} aom_source_var_lowercase)
736 file(APPEND "${libaom_srcs_gni_file}" "\n${aom_source_var_lowercase} = [\n")
737 endif ()
738
739 foreach (file ${${aom_source_var}})
740 if (NOT "${file}" MATCHES "${AOM_CONFIG_DIR}")
Johann2ef3da22018-04-05 13:33:55 -0700741 string(REPLACE "${AOM_ROOT}" "//third_party/libaom/source/libaom"
742 file "${file}")
Tom Fineganc34abc82017-10-13 12:04:59 -0700743 file(APPEND "${libaom_srcs_gni_file}" " \"${file}\",\n")
744 endif ()
745 endforeach ()
746
747 if ("${${aom_source_var}}" MATCHES "${AOM_ROOT}")
748 file(APPEND "${libaom_srcs_gni_file}" "]\n")
749 endif ()
750endforeach ()
751
752file(APPEND "${libaom_srcs_gni_file}"
753 "\n# Files below this line are generated by the libaom build system.\n")
754
755foreach (aom_source_var ${aom_source_vars})
756 if ("${${aom_source_var}}" MATCHES "${AOM_CONFIG_DIR}")
757 string(TOLOWER ${aom_source_var} aom_source_var_lowercase)
758 file(APPEND "${libaom_srcs_gni_file}"
759 "\n${aom_source_var_lowercase}_gen = [\n")
760 endif ()
761 foreach (file ${${aom_source_var}})
762 if (NOT "${file}" MATCHES "${AOM_ROOT}")
Johann2ef3da22018-04-05 13:33:55 -0700763 string(REPLACE "${AOM_CONFIG_DIR}" "//third_party/libaom/source/libaom"
764 file "${file}")
Tom Fineganc34abc82017-10-13 12:04:59 -0700765 file(APPEND "${libaom_srcs_gni_file}" " \"${file}\",\n")
766 endif ()
767 endforeach ()
768
769 if ("${${aom_source_var}}" MATCHES "${AOM_CONFIG_DIR}")
770 file(APPEND "${libaom_srcs_gni_file}" "]\n")
771 endif ()
772endforeach ()