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") |
| 81 | get_cmake_property(cmake_cache_vars CACHE_VARIABLES) |
| 82 | |
| 83 | set(aom_config_h_template "${AOM_CONFIG_DIR}/aom_config.h.cmake") |
| 84 | file(WRITE "${aom_config_h_template}" ${h_file_header_block}) |
| 85 | foreach(cache_var ${cmake_cache_vars}) |
Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame^] | 86 | if(NOT "${cache_var}" MATCHES "AOM_CONFIG_DIR\|AOM_ROOT\|^CMAKE_") |
| 87 | file(APPEND "${aom_config_h_template}" |
| 88 | "\#define ${cache_var} \${${cache_var}}\n") |
| 89 | endif() |
Tom Finegan | 2cf5329 | 2017-04-25 22:52:52 -0700 | [diff] [blame] | 90 | endforeach() |
| 91 | file(APPEND "${aom_config_h_template}" "\#endif /* AOM_CONFIG_H_ */") |
| 92 | |
| 93 | set(aom_asm_config_template "${AOM_CONFIG_DIR}/aom_config.asm.cmake") |
| 94 | file(WRITE "${aom_asm_config_template}" ${asm_file_header_block}) |
| 95 | foreach(cache_var ${cmake_cache_vars}) |
Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame^] | 96 | if(NOT "${cache_var}" MATCHES "AOM_CONFIG_DIR\|AOM_ROOT\|^CMAKE_\|INLINE") |
Tom Finegan | 2cf5329 | 2017-04-25 22:52:52 -0700 | [diff] [blame] | 97 | file(APPEND "${aom_asm_config_template}" |
Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame^] | 98 | "${cache_var} equ \${${cache_var}}\n") |
| 99 | endif() |
| 100 | endforeach() |
Tom Finegan | 2cf5329 | 2017-04-25 22:52:52 -0700 | [diff] [blame] | 101 | |
Tom Finegan | 4e351d3 | 2017-05-09 11:06:32 -0700 | [diff] [blame] | 102 | set(aom_rtcd_config_template "${AOM_CONFIG_DIR}/rtcd_config.cmake") |
| 103 | file(WRITE "${aom_rtcd_config_template}" ${cmake_file_header_block}) |
| 104 | foreach(cache_var ${cmake_cache_vars}) |
Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame^] | 105 | if(NOT "${cache_var}" MATCHES "AOM_CONFIG_DIR\|AOM_ROOT\|^CMAKE_\|INLINE") |
Tom Finegan | 4e351d3 | 2017-05-09 11:06:32 -0700 | [diff] [blame] | 106 | file(APPEND "${aom_rtcd_config_template}" |
Johann | 589bae8 | 2018-04-27 10:57:44 -0700 | [diff] [blame^] | 107 | "${cache_var}=\${RTCD_${cache_var}}\n") |
| 108 | endif() |
| 109 | endforeach() |
Tom Finegan | 4e351d3 | 2017-05-09 11:06:32 -0700 | [diff] [blame] | 110 | |