blob: b41f9e9f0e17fd1f737773e85c5566a664265e38 [file] [log] [blame]
Chris Kay74665262021-03-09 18:57:01 +00001#
2# Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
3#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6
7cmake_minimum_required(VERSION 3.20)
8
9#
Chris Kay794a13a2021-06-25 15:10:00 +010010# Ensure our own CMake modules can be loaded.
11#
12
13list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules")
14
Chris Kayfd5256a2021-07-23 14:14:24 +010015include(ArmConfigOption)
16
Chris Kay2e4ea1d2021-07-21 12:29:13 +010017include(TFAMetadata)
18
Chris Kayfd5256a2021-07-23 14:14:24 +010019#
20# Set up the configuration types for both single and multi-configuration
21# generators.
22#
23
24set(config-types "Debug" "RelWithDebInfo" "MinSizeRel" "Release")
25set(default-config "MinSizeRel")
26
27get_property(multi-config GLOBAL PROPERTY "GENERATOR_IS_MULTI_CONFIG")
28
29if(multi-config)
30 arm_config_option(
31 NAME CMAKE_CONFIGURATION_TYPES HIDDEN
32 HELP "Multi-generator configuration types."
33 DEFAULT ${config-types})
34
35 arm_config_option(
36 NAME CMAKE_DEFAULT_BUILD_TYPE HIDDEN
37 HELP "Default multi-generator configuration type."
38 DEFAULT "${default-config}")
39else()
40 arm_config_option(
41 NAME CMAKE_BUILD_TYPE
42 HELP "Build type."
43 STRINGS ${config-types}
44 DEFAULT ${default-config}
45 FORCE NOT CMAKE_BUILD_TYPE)
46endif()
47
Chris Kay794a13a2021-06-25 15:10:00 +010048#
Chris Kay2e4ea1d2021-07-21 12:29:13 +010049# Retrieve the list of platforms from the global metadata file and present them
50# to the user.
51#
52
53tfa_platforms(platforms)
54
55arm_assert(
56 CONDITION platforms
57 MESSAGE "No platforms defined!")
58
59arm_config_option(
60 NAME TFA_PLATFORM
61 HELP "Platform to build."
62 STRINGS ${platforms})
63
64tfa_platform_path(TFA_PLATFORM_SOURCE_DIR
65 PLATFORM "${TFA_PLATFORM}")
66
67arm_assert(
68 CONDITION EXISTS "${TFA_PLATFORM_SOURCE_DIR}"
69 MESSAGE "The source directory for the current platform does not exist:\n"
70
71 "${TFA_PLATFORM_SOURCE_DIR}")
72
73#
Chris Kay74665262021-03-09 18:57:01 +000074# We're done with very early setup, so we can now create the project. This will
75# do some of the automatic compiler detection, which we need for setting up
76# further configuration options.
77#
78# Note that this creates the following version variables:
79#
80# - `TFA_VERSION`
81# - `TFA_VERSION_MAJOR`
82# - `TFA_VERSION_MINOR`
83# - `TFA_VERSION_PATCH`
84# - `TFA_VERSION_TWEAK`
85#
86# Also, these directory variables:
87#
88# - `TFA_SOURCE_DIR`
89# - `TFA_BINARY_DIR`
90#
91# Don't swap `C` and `ASM`. Per the CMake documentation:
92#
93# > If enabling `ASM`, list it last so that CMake can check whether compilers
94# > for other languages like `C` work for assembly too.
95#
96
97project(TFA VERSION 2.5 LANGUAGES C ASM)