Chris Kay | 7466526 | 2021-03-09 18:57:01 +0000 | [diff] [blame] | 1 | # |
| 2 | # Copyright (c) 2021, Arm Limited and Contributors. All rights reserved. |
| 3 | # |
| 4 | # SPDX-License-Identifier: BSD-3-Clause |
| 5 | # |
| 6 | |
| 7 | cmake_minimum_required(VERSION 3.20) |
| 8 | |
| 9 | # |
Chris Kay | 794a13a | 2021-06-25 15:10:00 +0100 | [diff] [blame] | 10 | # Ensure our own CMake modules can be loaded. |
| 11 | # |
| 12 | |
| 13 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules") |
| 14 | |
Chris Kay | fd5256a | 2021-07-23 14:14:24 +0100 | [diff] [blame] | 15 | include(ArmConfigOption) |
| 16 | |
Chris Kay | 2e4ea1d | 2021-07-21 12:29:13 +0100 | [diff] [blame^] | 17 | include(TFAMetadata) |
| 18 | |
Chris Kay | fd5256a | 2021-07-23 14:14:24 +0100 | [diff] [blame] | 19 | # |
| 20 | # Set up the configuration types for both single and multi-configuration |
| 21 | # generators. |
| 22 | # |
| 23 | |
| 24 | set(config-types "Debug" "RelWithDebInfo" "MinSizeRel" "Release") |
| 25 | set(default-config "MinSizeRel") |
| 26 | |
| 27 | get_property(multi-config GLOBAL PROPERTY "GENERATOR_IS_MULTI_CONFIG") |
| 28 | |
| 29 | if(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}") |
| 39 | else() |
| 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) |
| 46 | endif() |
| 47 | |
Chris Kay | 794a13a | 2021-06-25 15:10:00 +0100 | [diff] [blame] | 48 | # |
Chris Kay | 2e4ea1d | 2021-07-21 12:29:13 +0100 | [diff] [blame^] | 49 | # Retrieve the list of platforms from the global metadata file and present them |
| 50 | # to the user. |
| 51 | # |
| 52 | |
| 53 | tfa_platforms(platforms) |
| 54 | |
| 55 | arm_assert( |
| 56 | CONDITION platforms |
| 57 | MESSAGE "No platforms defined!") |
| 58 | |
| 59 | arm_config_option( |
| 60 | NAME TFA_PLATFORM |
| 61 | HELP "Platform to build." |
| 62 | STRINGS ${platforms}) |
| 63 | |
| 64 | tfa_platform_path(TFA_PLATFORM_SOURCE_DIR |
| 65 | PLATFORM "${TFA_PLATFORM}") |
| 66 | |
| 67 | arm_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 Kay | 7466526 | 2021-03-09 18:57:01 +0000 | [diff] [blame] | 74 | # 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 | |
| 97 | project(TFA VERSION 2.5 LANGUAGES C ASM) |