tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

aom_configure.cmake (18951B)


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