blob: eef5eb8e65d89224a3f56104fa30797d116e4c9a [file] [log] [blame]
Johann589bae82018-04-27 10:57:44 -07001#
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 Finegan2cf53292017-04-25 22:52:52 -070011cmake_minimum_required(VERSION 3.5)
12
13string(TIMESTAMP year "%Y")
Johann589bae82018-04-27 10:57:44 -070014set(
15 asm_file_header_block
16 "\;
Tom Finegan2cf53292017-04-25 22:52:52 -070017\; 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\;
Johann589bae82018-04-27 10:57:44 -070026"
27 )
28set(
29 h_file_header_block
30 "/*
Tom Finegan2cf53292017-04-25 22:52:52 -070031 * 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_
Johann589bae82018-04-27 10:57:44 -070042"
43 )
44set(
45 cmake_file_header_block
46 "##
Tom Finegan4e351d32017-05-09 11:06:32 -070047## 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##
Johann589bae82018-04-27 10:57:44 -070056"
57 )
Tom Finegan2cf53292017-04-25 22:52:52 -070058
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.
Johann589bae82018-04-27 10:57:44 -070061function(check_directory_var var_name)
62 if("${var_name}" STREQUAL "")
Tom Finegan2cf53292017-04-25 22:52:52 -070063 message(FATAL_ERROR "The CMake variable ${var_name} must be defined.")
Johann589bae82018-04-27 10:57:44 -070064 endif()
Tom Finegan2cf53292017-04-25 22:52:52 -070065
Johann589bae82018-04-27 10:57:44 -070066 if(NOT EXISTS "${${var_name}}")
Tom Finegan2cf53292017-04-25 22:52:52 -070067 message(FATAL_ERROR "${${var_name}} (${var_name}) missing.")
Johann589bae82018-04-27 10:57:44 -070068 endif()
69endfunction()
Tom Finegan2cf53292017-04-25 22:52:52 -070070
71check_directory_var(AOM_CONFIG_DIR)
72check_directory_var(AOM_ROOT)
73
74set(AOM_DEFAULTS "${AOM_ROOT}/build/cmake/aom_config_defaults.cmake")
Johann589bae82018-04-27 10:57:44 -070075if(NOT EXISTS "${AOM_DEFAULTS}")
Tom Finegan2cf53292017-04-25 22:52:52 -070076 message(FATAL_ERROR
Johann589bae82018-04-27 10:57:44 -070077 "Configuration default values file (${AOM_DEFAULTS}) missing.")
78endif()
Tom Finegan2cf53292017-04-25 22:52:52 -070079
80include("${AOM_ROOT}/build/cmake/aom_config_defaults.cmake")
81get_cmake_property(cmake_cache_vars CACHE_VARIABLES)
82
83set(aom_config_h_template "${AOM_CONFIG_DIR}/aom_config.h.cmake")
84file(WRITE "${aom_config_h_template}" ${h_file_header_block})
85foreach(cache_var ${cmake_cache_vars})
Johann589bae82018-04-27 10:57:44 -070086 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 Finegan2cf53292017-04-25 22:52:52 -070090endforeach()
91file(APPEND "${aom_config_h_template}" "\#endif /* AOM_CONFIG_H_ */")
92
93set(aom_asm_config_template "${AOM_CONFIG_DIR}/aom_config.asm.cmake")
94file(WRITE "${aom_asm_config_template}" ${asm_file_header_block})
95foreach(cache_var ${cmake_cache_vars})
Johann589bae82018-04-27 10:57:44 -070096 if(NOT "${cache_var}" MATCHES "AOM_CONFIG_DIR\|AOM_ROOT\|^CMAKE_\|INLINE")
Tom Finegan2cf53292017-04-25 22:52:52 -070097 file(APPEND "${aom_asm_config_template}"
Johann589bae82018-04-27 10:57:44 -070098 "${cache_var} equ \${${cache_var}}\n")
99 endif()
100endforeach()
Tom Finegan2cf53292017-04-25 22:52:52 -0700101
Tom Finegan4e351d32017-05-09 11:06:32 -0700102set(aom_rtcd_config_template "${AOM_CONFIG_DIR}/rtcd_config.cmake")
103file(WRITE "${aom_rtcd_config_template}" ${cmake_file_header_block})
104foreach(cache_var ${cmake_cache_vars})
Johann589bae82018-04-27 10:57:44 -0700105 if(NOT "${cache_var}" MATCHES "AOM_CONFIG_DIR\|AOM_ROOT\|^CMAKE_\|INLINE")
Tom Finegan4e351d32017-05-09 11:06:32 -0700106 file(APPEND "${aom_rtcd_config_template}"
Johann589bae82018-04-27 10:57:44 -0700107 "${cache_var}=\${RTCD_${cache_var}}\n")
108 endif()
109endforeach()
Tom Finegan4e351d32017-05-09 11:06:32 -0700110