xref: /aosp_15_r20/external/libaom/build/cmake/aom_configure.cmake (revision 77c1e3ccc04c968bd2bc212e87364f250e820521)
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# Don't just check for pthread.h, but use the result of the full pthreads
254# including a linking check in FindThreads above.
255set(HAVE_PTHREAD_H ${CMAKE_USE_PTHREADS_INIT})
256aom_check_source_compiles("unistd_check" "#include <unistd.h>" HAVE_UNISTD_H)
257
258if(NOT WIN32)
259  aom_push_var(CMAKE_REQUIRED_LIBRARIES "m")
260  aom_check_c_compiles("fenv_check" "#define _GNU_SOURCE
261                        #include <fenv.h>
262                        void unused(void) {
263                          (void)unused;
264                          (void)feenableexcept(FE_DIVBYZERO | FE_INVALID);
265                        }" HAVE_FEXCEPT)
266  aom_pop_var(CMAKE_REQUIRED_LIBRARIES)
267endif()
268
269include("${AOM_ROOT}/build/cmake/cpu.cmake")
270
271if(ENABLE_CCACHE)
272  set_compiler_launcher(ENABLE_CCACHE ccache)
273endif()
274
275if(ENABLE_DISTCC)
276  set_compiler_launcher(ENABLE_DISTCC distcc)
277endif()
278
279if(ENABLE_GOMA)
280  set_compiler_launcher(ENABLE_GOMA gomacc)
281endif()
282
283if(NOT CONFIG_AV1_DECODER AND NOT CONFIG_AV1_ENCODER)
284  message(FATAL_ERROR "Decoder and encoder disabled, nothing to build.")
285endif()
286
287if(DECODE_HEIGHT_LIMIT OR DECODE_WIDTH_LIMIT)
288  change_config_and_warn(CONFIG_SIZE_LIMIT 1
289                         "DECODE_HEIGHT_LIMIT and DECODE_WIDTH_LIMIT")
290endif()
291
292if(CONFIG_SIZE_LIMIT)
293  if(NOT DECODE_HEIGHT_LIMIT OR NOT DECODE_WIDTH_LIMIT)
294    message(FATAL_ERROR "When setting CONFIG_SIZE_LIMIT, DECODE_HEIGHT_LIMIT "
295                        "and DECODE_WIDTH_LIMIT must be set.")
296  endif()
297endif()
298
299# Test compiler flags.
300if(MSVC)
301  # It isn't possible to specify C99 conformance for MSVC. MSVC doesn't support
302  # C++ standards modes earlier than C++14.
303  add_cxx_flag_if_supported("/std:c++14")
304  add_compiler_flag_if_supported("/W3")
305
306  # Disable MSVC warnings that suggest making code non-portable.
307  add_compiler_flag_if_supported("/wd4996")
308  if(ENABLE_WERROR)
309    add_compiler_flag_if_supported("/WX")
310  endif()
311else()
312  require_c_flag("-std=c99" YES)
313  if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
314     AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "GNU"
315     AND CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
316    # Microsoft's C++ Standard Library requires C++14 as it's MSVC's default and
317    # minimum supported C++ version. If Clang is using this Standard Library
318    # implementation, it cannot target C++11.
319    require_cxx_flag_nomsvc("-std=c++14" YES)
320  elseif(CYGWIN AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
321    # The GNU C++ compiler in Cygwin needs the -std=gnu++11 flag to make the
322    # POSIX function declarations visible in the Standard C Library headers.
323    require_cxx_flag_nomsvc("-std=gnu++11" YES)
324  else()
325    require_cxx_flag_nomsvc("-std=c++11" YES)
326  endif()
327  add_compiler_flag_if_supported("-Wall")
328  add_compiler_flag_if_supported("-Wdisabled-optimization")
329  add_compiler_flag_if_supported("-Wextra")
330  # Prior to version 3.19.0 cmake would fail to parse the warning emitted by gcc
331  # with this flag. Note the order of this check and -Wextra-semi-stmt is
332  # important due to is_flag_present() matching substrings with string(FIND
333  # ...).
334  if(CMAKE_VERSION VERSION_LESS "3.19"
335     AND CMAKE_C_COMPILER_ID STREQUAL "GNU"
336     AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10)
337    add_cxx_flag_if_supported("-Wextra-semi")
338  else()
339    add_compiler_flag_if_supported("-Wextra-semi")
340  endif()
341  add_compiler_flag_if_supported("-Wextra-semi-stmt")
342  add_compiler_flag_if_supported("-Wfloat-conversion")
343  add_compiler_flag_if_supported("-Wformat=2")
344  add_c_flag_if_supported("-Wimplicit-function-declaration")
345  add_compiler_flag_if_supported("-Wlogical-op")
346  add_compiler_flag_if_supported("-Wmissing-declarations")
347  if(CMAKE_C_COMPILER_ID MATCHES "Clang")
348    add_compiler_flag_if_supported("-Wmissing-prototypes")
349  else()
350    add_c_flag_if_supported("-Wmissing-prototypes")
351  endif()
352  add_compiler_flag_if_supported("-Wpointer-arith")
353  add_compiler_flag_if_supported("-Wshadow")
354  add_compiler_flag_if_supported("-Wshorten-64-to-32")
355  add_compiler_flag_if_supported("-Wsign-compare")
356  add_compiler_flag_if_supported("-Wstring-conversion")
357  add_compiler_flag_if_supported("-Wtype-limits")
358  add_compiler_flag_if_supported("-Wundef")
359  add_compiler_flag_if_supported("-Wuninitialized")
360  add_compiler_flag_if_supported("-Wunreachable-code-aggressive")
361  add_compiler_flag_if_supported("-Wunused")
362  add_compiler_flag_if_supported("-Wvla")
363  add_cxx_flag_if_supported("-Wc++14-extensions")
364  add_cxx_flag_if_supported("-Wc++17-extensions")
365  add_cxx_flag_if_supported("-Wc++20-extensions")
366
367  if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND SANITIZE MATCHES "address|undefined")
368
369    # This combination has more stack overhead, so we account for it by
370    # providing higher stack limit than usual.
371    add_c_flag_if_supported("-Wstack-usage=285000")
372    add_cxx_flag_if_supported("-Wstack-usage=270000")
373  elseif(CONFIG_RD_DEBUG) # Another case where higher stack usage is expected.
374    add_c_flag_if_supported("-Wstack-usage=135000")
375    add_cxx_flag_if_supported("-Wstack-usage=240000")
376  else()
377    add_c_flag_if_supported("-Wstack-usage=100000")
378    add_cxx_flag_if_supported("-Wstack-usage=240000")
379  endif()
380
381  if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND SANITIZE MATCHES "address")
382    # Disable no optimization warning when compiling with sanitizers
383    add_compiler_flag_if_supported("-Wno-disabled-optimization")
384  endif()
385
386  # Quiet gcc 6 vs 7 abi warnings:
387  # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77728
388  if(AOM_TARGET_CPU MATCHES "arm")
389    add_cxx_flag_if_supported("-Wno-psabi")
390  endif()
391
392  if(ENABLE_WERROR)
393    add_compiler_flag_if_supported("-Werror")
394  endif()
395
396  if(build_type_lowercase MATCHES "rel")
397    add_compiler_flag_if_supported("-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0")
398  endif()
399  add_compiler_flag_if_supported("-D_LARGEFILE_SOURCE")
400  add_compiler_flag_if_supported("-D_FILE_OFFSET_BITS=64")
401
402  # Do not allow implicit vector type conversions on Clang builds (this is
403  # already the default on GCC builds).
404  if(CMAKE_C_COMPILER_ID MATCHES "Clang")
405    # Clang 8.0.1 (in Cygwin) doesn't support -flax-vector-conversions=none.
406    add_compiler_flag_if_supported("-flax-vector-conversions=none")
407  endif()
408endif()
409
410# Prior to r23, or with ANDROID_USE_LEGACY_TOOLCHAIN_FILE set,
411# android.toolchain.cmake would set normal (non-cache) versions of variables
412# like CMAKE_C_FLAGS_RELEASE which would mask the ones added to the cache
413# variable in add_compiler_flag_if_supported(), etc. As a workaround we add
414# everything accumulated in AOM_C/CXX_FLAGS to the normal versions. This could
415# also be addressed by reworking the flag tests and adding the results directly
416# to target_compile_options() as in e.g., libgav1, but that's a larger task.
417# https://github.com/android/ndk/wiki/Changelog-r23#changes
418if(ANDROID
419   AND ("${ANDROID_NDK_MAJOR}" LESS 23 OR ANDROID_USE_LEGACY_TOOLCHAIN_FILE))
420  foreach(lang C;CXX)
421    string(STRIP "${AOM_${lang}_FLAGS}" AOM_${lang}_FLAGS)
422    if(AOM_${lang}_FLAGS)
423      foreach(config ${AOM_${lang}_CONFIGS})
424        set(${config} "${${config}} ${AOM_${lang}_FLAGS}")
425      endforeach()
426    endif()
427  endforeach()
428endif()
429
430set(AOM_LIB_LINK_TYPE PUBLIC)
431if(EMSCRIPTEN)
432
433  # Avoid CMake generation time errors resulting from collisions with the form
434  # of target_link_libraries() used by Emscripten.cmake.
435  unset(AOM_LIB_LINK_TYPE)
436endif()
437
438# Generate aom_config templates.
439set(aom_config_asm_template "${AOM_CONFIG_DIR}/config/aom_config.asm.cmake")
440set(aom_config_h_template "${AOM_CONFIG_DIR}/config/aom_config.h.cmake")
441execute_process(
442  COMMAND ${CMAKE_COMMAND}
443          -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR} -DAOM_ROOT=${AOM_ROOT} -P
444          "${AOM_ROOT}/build/cmake/generate_aom_config_templates.cmake")
445
446# Generate aom_config.{asm,h}.
447configure_file("${aom_config_asm_template}"
448               "${AOM_CONFIG_DIR}/config/aom_config.asm")
449configure_file("${aom_config_h_template}"
450               "${AOM_CONFIG_DIR}/config/aom_config.h")
451
452# Read the current git hash.
453find_package(Git)
454if(NOT GIT_FOUND)
455  message("--- Git missing, version will be read from CHANGELOG.")
456endif()
457
458string(TIMESTAMP year "%Y")
459configure_file("${AOM_ROOT}/build/cmake/aom_config.c.template"
460               "${AOM_CONFIG_DIR}/config/aom_config.c")
461
462# Find Perl and generate the RTCD sources.
463find_package(Perl)
464if(NOT PERL_FOUND)
465  message(FATAL_ERROR "Perl is required to build libaom.")
466endif()
467
468set(AOM_RTCD_CONFIG_FILE_LIST "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd_defs.pl"
469                              "${AOM_ROOT}/aom_scale/aom_scale_rtcd.pl"
470                              "${AOM_ROOT}/av1/common/av1_rtcd_defs.pl")
471set(AOM_RTCD_HEADER_FILE_LIST "${AOM_CONFIG_DIR}/config/aom_dsp_rtcd.h"
472                              "${AOM_CONFIG_DIR}/config/aom_scale_rtcd.h"
473                              "${AOM_CONFIG_DIR}/config/av1_rtcd.h")
474set(AOM_RTCD_SOURCE_FILE_LIST "${AOM_ROOT}/aom_dsp/aom_dsp_rtcd.c"
475                              "${AOM_ROOT}/aom_scale/aom_scale_rtcd.c"
476                              "${AOM_ROOT}/av1/common/av1_rtcd.c")
477set(AOM_RTCD_SYMBOL_LIST aom_dsp_rtcd aom_scale_rtcd av1_rtcd)
478list(LENGTH AOM_RTCD_SYMBOL_LIST AOM_RTCD_CUSTOM_COMMAND_COUNT)
479math(EXPR AOM_RTCD_CUSTOM_COMMAND_COUNT "${AOM_RTCD_CUSTOM_COMMAND_COUNT} - 1")
480
481foreach(NUM RANGE ${AOM_RTCD_CUSTOM_COMMAND_COUNT})
482  list(GET AOM_RTCD_CONFIG_FILE_LIST ${NUM} AOM_RTCD_CONFIG_FILE)
483  list(GET AOM_RTCD_HEADER_FILE_LIST ${NUM} AOM_RTCD_HEADER_FILE)
484  list(GET AOM_RTCD_SOURCE_FILE_LIST ${NUM} AOM_RTCD_SOURCE_FILE)
485  list(GET AOM_RTCD_SYMBOL_LIST ${NUM} AOM_RTCD_SYMBOL)
486  execute_process(
487    COMMAND
488      ${PERL_EXECUTABLE} "${AOM_ROOT}/build/cmake/rtcd.pl"
489      --arch=${AOM_TARGET_CPU}
490      --sym=${AOM_RTCD_SYMBOL} ${AOM_RTCD_FLAGS}
491      --config=${AOM_CONFIG_DIR}/config/aom_config.h ${AOM_RTCD_CONFIG_FILE}
492    OUTPUT_FILE ${AOM_RTCD_HEADER_FILE})
493endforeach()
494
495# Generate aom_version.h.
496execute_process(COMMAND ${CMAKE_COMMAND}
497                        -DAOM_CONFIG_DIR=${AOM_CONFIG_DIR}
498                        -DAOM_ROOT=${AOM_ROOT}
499                        -DGIT_EXECUTABLE=${GIT_EXECUTABLE}
500                        -DPERL_EXECUTABLE=${PERL_EXECUTABLE} -P
501                        "${AOM_ROOT}/build/cmake/version.cmake")
502