• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 the
5# Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License was
6# not distributed with this source code in the LICENSE file, you can obtain it
7# at www.aomedia.org/license/software. If the Alliance for Open Media Patent
8# License 1.0 was not distributed with this source code in the PATENTS file, you
9# can obtain it at www.aomedia.org/license/patent.
10#
11if(AOM_BUILD_CMAKE_AOM_CONFIGURE_CMAKE_)
12  return()
13endif() # AOM_BUILD_CMAKE_AOM_CONFIGURE_CMAKE_
14set(AOM_BUILD_CMAKE_AOM_CONFIGURE_CMAKE_ 1)
15
16include(FindThreads)
17
18include("${AOM_ROOT}/build/cmake/aom_config_defaults.cmake")
19include("${AOM_ROOT}/build/cmake/aom_experiment_deps.cmake")
20include("${AOM_ROOT}/build/cmake/aom_optimization.cmake")
21include("${AOM_ROOT}/build/cmake/compiler_flags.cmake")
22include("${AOM_ROOT}/build/cmake/compiler_tests.cmake")
23include("${AOM_ROOT}/build/cmake/util.cmake")
24
25if(DEFINED CONFIG_LOWBITDEPTH)
26  message(WARNING "CONFIG_LOWBITDEPTH has been removed. \
27    Use -DFORCE_HIGHBITDEPTH_DECODING=1 instead of -DCONFIG_LOWBITDEPTH=0 \
28    and -DFORCE_HIGHBITDEPTH_DECODING=0 instead of -DCONFIG_LOWBITDEPTH=1.")
29  if(NOT CONFIG_LOWBITDEPTH)
30    set(FORCE_HIGHBITDEPTH_DECODING
31        1
32        CACHE STRING "${cmake_cmdline_helpstring}" FORCE)
33  endif()
34endif()
35
36if(FORCE_HIGHBITDEPTH_DECODING AND NOT CONFIG_AV1_HIGHBITDEPTH)
37  change_config_and_warn(CONFIG_AV1_HIGHBITDEPTH 1
38                         "FORCE_HIGHBITDEPTH_DECODING")
39endif()
40
41if(CONFIG_THREE_PASS AND NOT CONFIG_AV1_DECODER)
42  change_config_and_warn(CONFIG_THREE_PASS 0 "CONFIG_AV1_DECODER=0")
43endif()
44
45# Generate the user config settings.
46list(APPEND aom_build_vars ${AOM_CONFIG_VARS} ${AOM_OPTION_VARS})
47foreach(cache_var ${aom_build_vars})
48  get_property(cache_var_helpstring CACHE ${cache_var} PROPERTY HELPSTRING)
49  if(cache_var_helpstring STREQUAL cmake_cmdline_helpstring)
50    set(AOM_CMAKE_CONFIG "${AOM_CMAKE_CONFIG} -D${cache_var}=${${cache_var}}")
51  endif()
52endforeach()
53string(STRIP "${AOM_CMAKE_CONFIG}" AOM_CMAKE_CONFIG)
54
55# Detect target CPU.
56if(NOT AOM_TARGET_CPU)
57  string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" cpu_lowercase)
58  if(cpu_lowercase STREQUAL "amd64" OR cpu_lowercase STREQUAL "x86_64")
59    if(CMAKE_SIZEOF_VOID_P EQUAL 4)
60      set(AOM_TARGET_CPU "x86")
61    elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
62      set(AOM_TARGET_CPU "x86_64")
63    else()
64      message(
65        FATAL_ERROR "--- Unexpected pointer size (${CMAKE_SIZEOF_VOID_P}) for\n"
66                    "      CMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}\n"
67                    "      CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}\n"
68                    "      CMAKE_GENERATOR=${CMAKE_GENERATOR}\n")
69    endif()
70  elseif(cpu_lowercase STREQUAL "i386" OR cpu_lowercase STREQUAL "x86")
71    set(AOM_TARGET_CPU "x86")
72  elseif(cpu_lowercase MATCHES "^arm")
73    set(AOM_TARGET_CPU "${cpu_lowercase}")
74  elseif(cpu_lowercase MATCHES "aarch64")
75    set(AOM_TARGET_CPU "arm64")
76  elseif(cpu_lowercase MATCHES "^ppc")
77    set(AOM_TARGET_CPU "ppc")
78  else()
79    message(WARNING "The architecture ${CMAKE_SYSTEM_PROCESSOR} is not "
80                    "supported, falling back to the generic target")
81    set(AOM_TARGET_CPU "generic")
82  endif()
83endif()
84
85if(CMAKE_TOOLCHAIN_FILE) # Add toolchain file to config string.
86  if(IS_ABSOLUTE "${CMAKE_TOOLCHAIN_FILE}")
87    file(RELATIVE_PATH toolchain_path "${AOM_CONFIG_DIR}"
88         "${CMAKE_TOOLCHAIN_FILE}")
89  else()
90    set(toolchain_path "${CMAKE_TOOLCHAIN_FILE}")
91  endif()
92  set(toolchain_string "-DCMAKE_TOOLCHAIN_FILE=\\\"${toolchain_path}\\\"")
93  set(AOM_CMAKE_CONFIG "${toolchain_string} ${AOM_CMAKE_CONFIG}")
94else()
95
96  # Add detected CPU to the config string.
97  set(AOM_CMAKE_CONFIG "-DAOM_TARGET_CPU=${AOM_TARGET_CPU} ${AOM_CMAKE_CONFIG}")
98endif()
99set(AOM_CMAKE_CONFIG "-G \\\"${CMAKE_GENERATOR}\\\" ${AOM_CMAKE_CONFIG}")
100file(RELATIVE_PATH source_path "${AOM_CONFIG_DIR}" "${AOM_ROOT}")
101set(AOM_CMAKE_CONFIG "cmake ${source_path} ${AOM_CMAKE_CONFIG}")
102string(STRIP "${AOM_CMAKE_CONFIG}" AOM_CMAKE_CONFIG)
103
104message("--- aom_configure: Detected CPU: ${AOM_TARGET_CPU}")
105set(AOM_TARGET_SYSTEM ${CMAKE_SYSTEM_NAME})
106
107string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type_lowercase)
108if(build_type_lowercase STREQUAL "debug")
109  set(CONFIG_DEBUG 1)
110endif()
111
112if(BUILD_SHARED_LIBS)
113  set(CONFIG_PIC 1)
114  set(CONFIG_SHARED 1)
115elseif(NOT CONFIG_PIC)
116  # Update the variable only when it does not carry the CMake assigned help
117  # string for variables specified via the command line. This allows the user to
118  # force CONFIG_PIC=0.
119  unset(cache_helpstring)
120  get_property(cache_helpstring CACHE CONFIG_PIC PROPERTY HELPSTRING)
121  if(NOT "${cache_helpstring}" STREQUAL "${cmake_cmdline_helpstring}")
122    aom_check_c_compiles("pie_check" "
123                          #if !(__pie__ || __PIE__)
124                          #error Neither __pie__ or __PIE__ are set
125                          #endif
126                          extern void unused(void);
127                          void unused(void) {}" HAVE_PIE)
128
129    if(HAVE_PIE)
130      # If -fpie or -fPIE are used ensure the assembly code has PIC enabled to
131      # avoid DT_TEXTRELs: /usr/bin/ld: warning: creating DT_TEXTREL in a PIE
132      set(CONFIG_PIC 1)
133      message(
134        "CONFIG_PIC enabled for position independent executable (PIE) build")
135    endif()
136  endif()
137  unset(cache_helpstring)
138endif()
139
140if(NOT MSVC)
141  if(CONFIG_PIC)
142
143    # TODO(tomfinegan): clang needs -pie in CMAKE_EXE_LINKER_FLAGS for this to
144    # work.
145    set(CMAKE_POSITION_INDEPENDENT_CODE ON)
146    if(AOM_TARGET_SYSTEM STREQUAL "Linux"
147       AND AOM_TARGET_CPU MATCHES "^armv[78]")
148      set(AOM_AS_FLAGS ${AOM_AS_FLAGS} --defsym PIC=1)
149    else()
150      set(AOM_AS_FLAGS ${AOM_AS_FLAGS} -DPIC)
151    endif()
152  endif()
153endif()
154
155if(AOM_TARGET_CPU STREQUAL "x86" OR AOM_TARGET_CPU STREQUAL "x86_64")
156  find_program(CMAKE_ASM_NASM_COMPILER yasm $ENV{YASM_PATH})
157  if(NOT CMAKE_ASM_NASM_COMPILER OR ENABLE_NASM)
158    unset(CMAKE_ASM_NASM_COMPILER CACHE)
159    find_program(CMAKE_ASM_NASM_COMPILER nasm $ENV{NASM_PATH})
160  endif()
161
162  include(CheckLanguage)
163  check_language(ASM_NASM)
164  if(CMAKE_ASM_NASM_COMPILER)
165    get_asm_obj_format("objformat")
166    unset(CMAKE_ASM_NASM_OBJECT_FORMAT)
167    set(CMAKE_ASM_NASM_OBJECT_FORMAT ${objformat})
168    enable_language(ASM_NASM)
169    if(CMAKE_ASM_NASM_COMPILER_ID STREQUAL "NASM")
170      test_nasm()
171    endif()
172    # Xcode requires building the objects manually, so pass the object format
173    # flag.
174    if(XCODE)
175      set(AOM_AS_FLAGS -f ${objformat} ${AOM_AS_FLAGS})
176    endif()
177  else()
178    message(
179      FATAL_ERROR
180        "Unable to find assembler. Install 'yasm' or 'nasm.' "
181        "To build without optimizations, add -DAOM_TARGET_CPU=generic to "
182        "your cmake command line.")
183  endif()
184  string(STRIP "${AOM_AS_FLAGS}" AOM_AS_FLAGS)
185elseif(AOM_TARGET_CPU MATCHES "arm")
186  if(AOM_TARGET_SYSTEM STREQUAL "Darwin")
187    if(NOT CMAKE_ASM_COMPILER)
188      set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
189    endif()
190    set(AOM_AS_FLAGS -arch ${AOM_TARGET_CPU} -isysroot ${CMAKE_OSX_SYSROOT})
191  elseif(AOM_TARGET_SYSTEM STREQUAL "Windows")
192    if(NOT CMAKE_ASM_COMPILER)
193      set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER} -c -mimplicit-it=always)
194    endif()
195  else()
196    if(NOT CMAKE_ASM_COMPILER)
197      set(CMAKE_ASM_COMPILER as)
198    endif()
199  endif()
200  include(CheckLanguage)
201  check_language(ASM)
202  if(NOT CMAKE_ASM_COMPILER)
203    message(
204      FATAL_ERROR
205        "Unable to find assembler and optimizations are enabled."
206        "Searched for ${CMAKE_ASM_COMPILER}. Install it, add it to your path,"
207        "or set the assembler directly by adding "
208        "-DCMAKE_ASM_COMPILER=<assembler path> to your CMake command line."
209        "To build without optimizations, add -DAOM_TARGET_CPU=generic to your "
210        "cmake command line.")
211  endif()
212  enable_language(ASM)
213  string(STRIP "${AOM_AS_FLAGS}" AOM_AS_FLAGS)
214endif()
215
216if(CONFIG_ANALYZER)
217  find_package(wxWidgets REQUIRED adv base core)
218  include(${wxWidgets_USE_FILE})
219endif()
220
221if(NOT MSVC AND CMAKE_C_COMPILER_ID MATCHES "GNU\|Clang")
222  set(CONFIG_GCC 1)
223endif()
224
225if(CONFIG_GCOV)
226  message("--- Testing for CONFIG_GCOV support.")
227  require_linker_flag("-fprofile-arcs -ftest-coverage")
228  require_compiler_flag("-fprofile-arcs -ftest-coverage" YES)
229endif()
230
231if(CONFIG_GPROF)
232  message("--- Testing for CONFIG_GPROF support.")
233  require_compiler_flag("-pg" YES)
234endif()
235
236if(AOM_TARGET_SYSTEM MATCHES "Darwin\|Linux\|Windows\|Android")
237  set(CONFIG_OS_SUPPORT 1)
238endif()
239
240if(AOM_TARGET_SYSTEM STREQUAL "Windows")
241  # The default _WIN32_WINNT value in MinGW is 0x0502 (Windows XP with SP2). Set
242  # it to 0x0601 (Windows 7).
243  add_compiler_flag_if_supported("-D_WIN32_WINNT=0x0601")
244  # Quiet warnings related to fopen, printf, etc.
245  add_compiler_flag_if_supported("-D_CRT_SECURE_NO_WARNINGS")
246endif()
247
248#
249# Fix CONFIG_* dependencies. This must be done before including cpu.cmake to
250# ensure RTCD_CONFIG_* are properly set.
251fix_experiment_configs()
252
253# Test compiler support.
254aom_get_inline("INLINE")
255
256# Don't just check for pthread.h, but use the result of the full pthreads
257# including a linking check in FindThreads above.
258set(HAVE_PTHREAD_H ${CMAKE_USE_PTHREADS_INIT})
259aom_check_source_compiles("unistd_check" "#include <unistd.h>" HAVE_UNISTD_H)
260
261if(NOT WIN32)
262  aom_push_var(CMAKE_REQUIRED_LIBRARIES "m")
263  aom_check_c_compiles("fenv_check" "#define _GNU_SOURCE
264                        #include <fenv.h>
265                        void unused(void) {
266                          (void)unused;
267                          (void)feenableexcept(FE_DIVBYZERO | FE_INVALID);
268                        }" HAVE_FEXCEPT)
269  aom_pop_var(CMAKE_REQUIRED_LIBRARIES)
270endif()
271
272include("${AOM_ROOT}/build/cmake/cpu.cmake")
273
274if(ENABLE_CCACHE)
275  set_compiler_launcher(ENABLE_CCACHE ccache)
276endif()
277
278if(ENABLE_DISTCC)
279  set_compiler_launcher(ENABLE_DISTCC distcc)
280endif()
281
282if(ENABLE_GOMA)
283  set_compiler_launcher(ENABLE_GOMA gomacc)
284endif()
285
286if(NOT CONFIG_AV1_DECODER AND NOT CONFIG_AV1_ENCODER)
287  message(FATAL_ERROR "Decoder and encoder disabled, nothing to build.")
288endif()
289
290if(DECODE_HEIGHT_LIMIT OR DECODE_WIDTH_LIMIT)
291  change_config_and_warn(CONFIG_SIZE_LIMIT 1
292                         "DECODE_HEIGHT_LIMIT and DECODE_WIDTH_LIMIT")
293endif()
294
295if(CONFIG_SIZE_LIMIT)
296  if(NOT DECODE_HEIGHT_LIMIT OR NOT DECODE_WIDTH_LIMIT)
297    message(FATAL_ERROR "When setting CONFIG_SIZE_LIMIT, DECODE_HEIGHT_LIMIT "
298                        "and DECODE_WIDTH_LIMIT must be set.")
299  endif()
300endif()
301
302# Test compiler flags.
303if(MSVC)
304  # It isn't possible to specify C99 conformance for MSVC. MSVC doesn't support
305  # C++ standards modes earlier than C++14.
306  add_cxx_flag_if_supported("/std:c++14")
307  add_compiler_flag_if_supported("/W3")
308
309  # Disable MSVC warnings that suggest making code non-portable.
310  add_compiler_flag_if_supported("/wd4996")
311  if(ENABLE_WERROR)
312    add_compiler_flag_if_supported("/WX")
313  endif()
314else()
315  require_c_flag("-std=c99" YES)
316  if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
317     AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU"
318     AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
319    # Microsoft's C++ Standard Library requires C++14 as it's MSVC's default and
320    # minimum supported C++ version. If Clang is using this Standard Library
321    # implementation, it cannot target C++11.
322    require_cxx_flag_nomsvc("-std=c++14" YES)
323  elseif(CYGWIN AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
324    # The GNU C++ compiler in Cygwin needs the -std=gnu++11 flag to make the
325    # POSIX function declarations visible in the Standard C Library headers.
326    require_cxx_flag_nomsvc("-std=gnu++11" YES)
327  else()
328    require_cxx_flag_nomsvc("-std=c++11" YES)
329  endif()
330  add_compiler_flag_if_supported("-Wall")
331  add_compiler_flag_if_supported("-Wdisabled-optimization")
332  add_compiler_flag_if_supported("-Wextra")
333  # Prior to version 3.19.0 cmake would fail to parse the warning emitted by gcc
334  # with this flag. Note the order of this check and -Wextra-semi-stmt is
335  # important due to is_flag_present() matching substrings with string(FIND
336  # ...).
337  if(CMAKE_VERSION VERSION_LESS "3.19"
338     AND CMAKE_C_COMPILER_ID STREQUAL "GNU"
339     AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
340    add_cxx_flag_if_supported("-Wextra-semi")
341  else()
342    add_compiler_flag_if_supported("-Wextra-semi")
343  endif()
344  add_compiler_flag_if_supported("-Wextra-semi-stmt")
345  add_compiler_flag_if_supported("-Wfloat-conversion")
346  add_compiler_flag_if_supported("-Wformat=2")
347  add_c_flag_if_supported("-Wimplicit-function-declaration")
348  add_compiler_flag_if_supported("-Wlogical-op")
349  add_compiler_flag_if_supported("-Wpointer-arith")
350  add_compiler_flag_if_supported("-Wshadow")
351  add_compiler_flag_if_supported("-Wshorten-64-to-32")
352  add_compiler_flag_if_supported("-Wsign-compare")
353  add_compiler_flag_if_supported("-Wstring-conversion")
354  add_compiler_flag_if_supported("-Wtype-limits")
355  add_compiler_flag_if_supported("-Wuninitialized")
356  add_compiler_flag_if_supported("-Wunreachable-code-aggressive")
357  add_compiler_flag_if_supported("-Wunused")
358  add_compiler_flag_if_supported("-Wvla")
359  add_cxx_flag_if_supported("-Wc++14-extensions")
360  add_cxx_flag_if_supported("-Wc++17-extensions")
361  add_cxx_flag_if_supported("-Wc++20-extensions")
362
363  if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND SANITIZE MATCHES "address|undefined")
364
365    # This combination has more stack overhead, so we account for it by
366    # providing higher stack limit than usual.
367    add_c_flag_if_supported("-Wstack-usage=285000")
368    add_cxx_flag_if_supported("-Wstack-usage=270000")
369  elseif(CONFIG_RD_DEBUG) # Another case where higher stack usage is expected.
370    add_c_flag_if_supported("-Wstack-usage=135000")
371    add_cxx_flag_if_supported("-Wstack-usage=240000")
372  else()
373    add_c_flag_if_supported("-Wstack-usage=100000")
374    add_cxx_flag_if_supported("-Wstack-usage=240000")
375  endif()
376
377  if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND SANITIZE MATCHES "address")
378    # Disable no optimization warning when compiling with sanitizers
379    add_compiler_flag_if_supported("-Wno-disabled-optimization")
380  endif()
381
382  # Add -Wundef only for C files to avoid massive gtest warning spam.
383  add_c_flag_if_supported("-Wundef")
384
385  # Quiet gcc 6 vs 7 abi warnings:
386  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77728
387  if(AOM_TARGET_CPU MATCHES "arm")
388    add_cxx_flag_if_supported("-Wno-psabi")
389  endif()
390
391  if(ENABLE_WERROR)
392    add_compiler_flag_if_supported("-Werror")
393  endif()
394
395  if(build_type_lowercase MATCHES "rel")
396    add_compiler_flag_if_supported("-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0")
397  endif()
398  add_compiler_flag_if_supported("-D_LARGEFILE_SOURCE")
399  add_compiler_flag_if_supported("-D_FILE_OFFSET_BITS=64")
400
401  # Do not allow implicit vector type conversions on Clang builds (this is
402  # already the default on GCC builds).
403  if(CMAKE_C_COMPILER_ID MATCHES "Clang")
404    # Clang 8.0.1 (in Cygwin) doesn't support -flax-vector-conversions=none.
405    add_compiler_flag_if_supported("-flax-vector-conversions=none")
406  endif()
407endif()
408
409# Prior to r23, or with ANDROID_USE_LEGACY_TOOLCHAIN_FILE set,
410# android.toolchain.cmake would set normal (non-cache) versions of variables
411# like CMAKE_C_FLAGS_RELEASE which would mask the ones added to the cache
412# variable in add_compiler_flag_if_supported(), etc. As a workaround we add
413# everything accumulated in AOM_C/CXX_FLAGS to the normal versions. This could
414# also be addressed by reworking the flag tests and adding the results directly
415# to target_compile_options() as in e.g., libgav1, but that's a larger task.
416# https://github.com/android/ndk/wiki/Changelog-r23#changes
417if(ANDROID
418   AND ("${ANDROID_NDK_MAJOR}" LESS 23 OR ANDROID_USE_LEGACY_TOOLCHAIN_FILE))
419  foreach(lang C;CXX)
420    string(STRIP "${AOM_${lang}_FLAGS}" AOM_${lang}_FLAGS)
421    if(AOM_${lang}_FLAGS)
422      foreach(config ${AOM_${lang}_CONFIGS})
423        set(${config} "${${config}} ${AOM_${lang}_FLAGS}")
424      endforeach()
425    endif()
426  endforeach()
427endif()
428
429set(AOM_LIB_LINK_TYPE PUBLIC)
430if(EMSCRIPTEN)
431
432  # Avoid CMake generation time errors resulting from collisions with the form
433  # of target_link_libraries() used by Emscripten.cmake.
434  unset(AOM_LIB_LINK_TYPE)
435endif()
436
437# Generate aom_config templates.
438set(aom_config_asm_template "${AOM_CONFIG_DIR}/config/aom_config.asm.cmake")
439set(aom_config_h_template "${AOM_CONFIG_DIR}/config/aom_config.h.cmake")
440execute_process(
441  COMMAND ${CMAKE_COMMAND}
442          -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR} -DAOM_ROOT=${AOM_ROOT} -P
443          "${AOM_ROOT}/build/cmake/generate_aom_config_templates.cmake")
444
445# Generate aom_config.{asm,h}.
446configure_file("${aom_config_asm_template}"
447               "${AOM_CONFIG_DIR}/config/aom_config.asm")
448configure_file("${aom_config_h_template}"
449               "${AOM_CONFIG_DIR}/config/aom_config.h")
450
451# Read the current git hash.
452find_package(Git)
453if(NOT GIT_FOUND)
454  message("--- Git missing, version will be read from CHANGELOG.")
455endif()
456
457string(TIMESTAMP year "%Y")
458configure_file("${AOM_ROOT}/build/cmake/aom_config.c.template"
459               "${AOM_CONFIG_DIR}/config/aom_config.c")
460
461# Find Perl and generate the RTCD sources.
462find_package(Perl)
463if(NOT PERL_FOUND)
464  message(FATAL_ERROR "Perl is required to build libaom.")
465endif()
466
467set(AOM_RTCD_CONFIG_FILE_LIST "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd_defs.pl"
468                              "${AOM_ROOT}/aom_scale/aom_scale_rtcd.pl"
469                              "${AOM_ROOT}/av1/common/av1_rtcd_defs.pl")
470set(AOM_RTCD_HEADER_FILE_LIST "${AOM_CONFIG_DIR}/config/aom_dsp_rtcd.h"
471                              "${AOM_CONFIG_DIR}/config/aom_scale_rtcd.h"
472                              "${AOM_CONFIG_DIR}/config/av1_rtcd.h")
473set(AOM_RTCD_SOURCE_FILE_LIST "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd.c"
474                              "${AOM_ROOT}/aom_scale/aom_scale_rtcd.c"
475                              "${AOM_ROOT}/av1/common/av1_rtcd.c")
476set(AOM_RTCD_SYMBOL_LIST aom_dsp_rtcd aom_scale_rtcd av1_rtcd)
477list(LENGTH AOM_RTCD_SYMBOL_LIST AOM_RTCD_CUSTOM_COMMAND_COUNT)
478math(EXPR AOM_RTCD_CUSTOM_COMMAND_COUNT "${AOM_RTCD_CUSTOM_COMMAND_COUNT} - 1")
479
480foreach(NUM RANGE ${AOM_RTCD_CUSTOM_COMMAND_COUNT})
481  list(GET AOM_RTCD_CONFIG_FILE_LIST ${NUM} AOM_RTCD_CONFIG_FILE)
482  list(GET AOM_RTCD_HEADER_FILE_LIST ${NUM} AOM_RTCD_HEADER_FILE)
483  list(GET AOM_RTCD_SOURCE_FILE_LIST ${NUM} AOM_RTCD_SOURCE_FILE)
484  list(GET AOM_RTCD_SYMBOL_LIST ${NUM} AOM_RTCD_SYMBOL)
485  execute_process(
486    COMMAND
487      ${PERL_EXECUTABLE} "${AOM_ROOT}/build/cmake/rtcd.pl"
488      --arch=${AOM_TARGET_CPU}
489      --sym=${AOM_RTCD_SYMBOL} ${AOM_RTCD_FLAGS}
490      --config=${AOM_CONFIG_DIR}/config/aom_config.h ${AOM_RTCD_CONFIG_FILE}
491    OUTPUT_FILE ${AOM_RTCD_HEADER_FILE})
492endforeach()
493
494# Generate aom_version.h.
495execute_process(COMMAND ${CMAKE_COMMAND}
496                        -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
497                        -DAOM_ROOT=${AOM_ROOT}
498                        -DGIT_EXECUTABLE=${GIT_EXECUTABLE}
499                        -DPERL_EXECUTABLE=${PERL_EXECUTABLE} -P
500                        "${AOM_ROOT}/build/cmake/version.cmake")
501