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