blob: b91c036de8cdd94457ba378a9a4edf9fd234f388 [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")
Tom Finegand9854ab2018-07-30 13:30:35 -070081list(APPEND aom_build_vars ${AOM_DETECT_VARS} ${AOM_CONFIG_VARS})
Tom Finegan5811b1e2018-08-07 14:56:46 -070082list(SORT aom_build_vars)
Tom Finegan2cf53292017-04-25 22:52:52 -070083
Tom Finegan60e653d2018-05-22 11:34:58 -070084set(aom_config_h_template "${AOM_CONFIG_DIR}/config/aom_config.h.cmake")
Tom Finegan2cf53292017-04-25 22:52:52 -070085file(WRITE "${aom_config_h_template}" ${h_file_header_block})
Tom Finegand9854ab2018-07-30 13:30:35 -070086foreach(aom_var ${aom_build_vars})
Johann779d0662018-08-30 10:37:34 -070087 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 Finegan2cf53292017-04-25 22:52:52 -070091endforeach()
Wan-Teh Changa1e38052018-08-08 15:22:15 -070092file(APPEND "${aom_config_h_template}" "\#endif // AOM_CONFIG_H_")
Tom Finegan2cf53292017-04-25 22:52:52 -070093
Tom Finegan60e653d2018-05-22 11:34:58 -070094set(aom_asm_config_template "${AOM_CONFIG_DIR}/config/aom_config.asm.cmake")
Tom Finegan2cf53292017-04-25 22:52:52 -070095file(WRITE "${aom_asm_config_template}" ${asm_file_header_block})
Tom Finegand9854ab2018-07-30 13:30:35 -070096foreach(aom_var ${aom_build_vars})
Johann779d0662018-08-30 10:37:34 -070097 if(NOT "${aom_var}" STREQUAL "INLINE" AND NOT "${aom_var}" STREQUAL
98 "AOM_RTCD_FLAGS")
Tom Finegand9854ab2018-07-30 13:30:35 -070099 file(APPEND "${aom_asm_config_template}" "${aom_var} equ \${${aom_var}}\n")
Johann589bae82018-04-27 10:57:44 -0700100 endif()
101endforeach()