1# 2# Copyright (c) 2017, 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# 11cmake_minimum_required(VERSION 3.5) 12 13string(TIMESTAMP year "%Y") 14set(asm_file_header_block "\; 15\; Copyright (c) ${year}, Alliance for Open Media. All rights reserved 16\; 17\; This source code is subject to the terms of the BSD 2 Clause License and 18\; the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License 19\; was not distributed with this source code in the LICENSE file, you can 20\; obtain it at www.aomedia.org/license/software. If the Alliance for Open 21\; Media Patent License 1.0 was not distributed with this source code in the 22\; PATENTS file, you can obtain it at www.aomedia.org/license/patent. 23\; 24") 25set(h_file_header_block "/* 26 * Copyright (c) ${year}, Alliance for Open Media. All rights reserved 27 * 28 * This source code is subject to the terms of the BSD 2 Clause License and 29 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License 30 * was not distributed with this source code in the LICENSE file, you can 31 * obtain it at www.aomedia.org/license/software. If the Alliance for Open 32 * Media Patent License 1.0 was not distributed with this source code in the 33 * PATENTS file, you can obtain it at www.aomedia.org/license/patent. 34 */ 35\#ifndef AOM_CONFIG_H_ 36\#define AOM_CONFIG_H_ 37") 38set(cmake_file_header_block "## 39## Copyright (c) ${year}, Alliance for Open Media. All rights reserved 40## 41## This source code is subject to the terms of the BSD 2 Clause License and 42## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License 43## was not distributed with this source code in the LICENSE file, you can 44## obtain it at www.aomedia.org/license/software. If the Alliance for Open 45## Media Patent License 1.0 was not distributed with this source code in the 46## PATENTS file, you can obtain it at www.aomedia.org/license/patent. 47## 48") 49 50# Terminates cmake execution when $var_name is an empty string, or the variable 51# name it contains does not expand to an existing directory. 52function(check_directory_var var_name) 53 if("${var_name}" STREQUAL "") 54 message(FATAL_ERROR "The CMake variable ${var_name} must be defined.") 55 endif() 56 57 if(NOT EXISTS "${${var_name}}") 58 message(FATAL_ERROR "${${var_name}} (${var_name}) missing.") 59 endif() 60endfunction() 61 62check_directory_var(AOM_CONFIG_DIR) 63check_directory_var(AOM_ROOT) 64 65set(AOM_DEFAULTS "${AOM_ROOT}/build/cmake/aom_config_defaults.cmake") 66if(NOT EXISTS "${AOM_DEFAULTS}") 67 message( 68 FATAL_ERROR "Configuration default values file (${AOM_DEFAULTS}) missing.") 69endif() 70 71include("${AOM_ROOT}/build/cmake/aom_config_defaults.cmake") 72list(APPEND aom_build_vars ${AOM_DETECT_VARS} ${AOM_CONFIG_VARS}) 73list(SORT aom_build_vars) 74 75set(aom_config_h_template "${AOM_CONFIG_DIR}/config/aom_config.h.cmake") 76file(WRITE "${aom_config_h_template}" ${h_file_header_block}) 77foreach(aom_var ${aom_build_vars}) 78 if(NOT "${aom_var}" STREQUAL "AOM_RTCD_FLAGS") 79 file(APPEND "${aom_config_h_template}" 80 "\#define ${aom_var} \${${aom_var}}\n") 81 endif() 82endforeach() 83file(APPEND "${aom_config_h_template}" "\#endif // AOM_CONFIG_H_") 84 85set(aom_asm_config_template "${AOM_CONFIG_DIR}/config/aom_config.asm.cmake") 86file(WRITE "${aom_asm_config_template}" ${asm_file_header_block}) 87foreach(aom_var ${aom_build_vars}) 88 if(NOT "${aom_var}" STREQUAL "INLINE" 89 AND NOT "${aom_var}" STREQUAL "AOM_RTCD_FLAGS") 90 file(APPEND "${aom_asm_config_template}" "${aom_var} equ \${${aom_var}}\n") 91 endif() 92endforeach() 93