aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Kay <chris.kay@arm.com>2021-07-23 14:14:24 +0100
committerChris Kay <chris.kay@arm.com>2022-01-11 17:21:54 +0000
commitfd5256aa99521733cca42fbaf8dc05b326ae8749 (patch)
treed142e797cf016fb5117cd83e15be3c3cba53fca8
parentfdee5cba973d6d5aa27bd7754be39e8255778ca3 (diff)
downloadtrusted-firmware-a-fd5256aa99521733cca42fbaf8dc05b326ae8749.tar.gz
build(cmake): configure build types
Adds the logic which configures the current build configuration on single-config generators, or the possible build configurations on multi-config generators. When generating with a single-config generator, CMake uses the `CMAKE_BUILD_TYPE` variable to determine the build type. For this we default to a minimum-size release build (`MinSizeRel`). When generating with a multi-config generators, CMake expects a list of recognised build types in `CMAKE_CONFIGURATION_TYPES`, and when building the generator will treat `CMAKE_DEFAULT_BUILD_TYPE` as the default. The build types introduced by this change represent the default build types defined by CMake, and are common across and recognised by most CMake projects. We could potentially extend these in the future (or limit them, if we so wished), but we would need to consider the impact on our toolchain files and our third-party dependencies. Change-Id: I6cadd3535dccec7372aae5d324c7123c4153ca1f Signed-off-by: Chris Kay <chris.kay@arm.com>
-rw-r--r--CMakeLists.txt31
-rw-r--r--docs/cmake/manual/variable/intrinsic/CMAKE_BUILD_TYPE.rst27
-rw-r--r--docs/cmake/manual/variable/intrinsic/CMAKE_CONFIGURATION_TYPES.rst15
-rw-r--r--docs/cmake/manual/variable/intrinsic/CMAKE_DEFAULT_BUILD_TYPE.rst16
-rw-r--r--docs/cmake/manual/variables.rst2
5 files changed, 91 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index eb8d1f1f04..f095867469 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,6 +12,37 @@ cmake_minimum_required(VERSION 3.20)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules")
+include(ArmConfigOption)
+
+#
+# Set up the configuration types for both single and multi-configuration
+# generators.
+#
+
+set(config-types "Debug" "RelWithDebInfo" "MinSizeRel" "Release")
+set(default-config "MinSizeRel")
+
+get_property(multi-config GLOBAL PROPERTY "GENERATOR_IS_MULTI_CONFIG")
+
+if(multi-config)
+ arm_config_option(
+ NAME CMAKE_CONFIGURATION_TYPES HIDDEN
+ HELP "Multi-generator configuration types."
+ DEFAULT ${config-types})
+
+ arm_config_option(
+ NAME CMAKE_DEFAULT_BUILD_TYPE HIDDEN
+ HELP "Default multi-generator configuration type."
+ DEFAULT "${default-config}")
+else()
+ arm_config_option(
+ NAME CMAKE_BUILD_TYPE
+ HELP "Build type."
+ STRINGS ${config-types}
+ DEFAULT ${default-config}
+ FORCE NOT CMAKE_BUILD_TYPE)
+endif()
+
#
# We're done with very early setup, so we can now create the project. This will
# do some of the automatic compiler detection, which we need for setting up
diff --git a/docs/cmake/manual/variable/intrinsic/CMAKE_BUILD_TYPE.rst b/docs/cmake/manual/variable/intrinsic/CMAKE_BUILD_TYPE.rst
new file mode 100644
index 0000000000..ce7bef3372
--- /dev/null
+++ b/docs/cmake/manual/variable/intrinsic/CMAKE_BUILD_TYPE.rst
@@ -0,0 +1,27 @@
+CMAKE_BUILD_TYPE
+================
+
+.. default-domain:: cmake
+
+.. variable:: CMAKE_BUILD_TYPE
+
+Specifies the build type on single-configuration generators. See
+:variable:`CMAKE_BUILD_TYPE <variable:CMAKE_BUILD_TYPE>`.
+
+Supported values are as follows:
+
++--------------------+---------+---------------+------------+
+| Value | Profile | Optimizations | Assertions |
++====================+=========+===============+============+
+| ``Debug`` | Debug | None | Enabled |
++--------------------+---------+---------------+------------+
+| ``RelWithDebInfo`` | Release | Performance | Enabled |
++--------------------+---------+---------------+------------+
+| ``Release`` | Release | Performance | Disabled |
++--------------------+---------+---------------+------------+
+| ``MinSizeRel`` | Release | Size | Disabled |
++--------------------+---------+---------------+------------+
+
+--------------
+
+*Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.*
diff --git a/docs/cmake/manual/variable/intrinsic/CMAKE_CONFIGURATION_TYPES.rst b/docs/cmake/manual/variable/intrinsic/CMAKE_CONFIGURATION_TYPES.rst
new file mode 100644
index 0000000000..d930a3b0e0
--- /dev/null
+++ b/docs/cmake/manual/variable/intrinsic/CMAKE_CONFIGURATION_TYPES.rst
@@ -0,0 +1,15 @@
+CMAKE_CONFIGURATION_TYPES
+=========================
+
+.. default-domain:: cmake
+
+.. variable:: CMAKE_CONFIGURATION_TYPES
+
+Specifies the available build types on multi-configuration generators. See
+:variable:`CMAKE_CONFIGURATION_TYPES <variable:CMAKE_CONFIGURATION_TYPES>`.
+
+See :variable:`CMAKE_BUILD_TYPE` for the various build types.
+
+--------------
+
+*Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.*
diff --git a/docs/cmake/manual/variable/intrinsic/CMAKE_DEFAULT_BUILD_TYPE.rst b/docs/cmake/manual/variable/intrinsic/CMAKE_DEFAULT_BUILD_TYPE.rst
new file mode 100644
index 0000000000..2ba2674ed3
--- /dev/null
+++ b/docs/cmake/manual/variable/intrinsic/CMAKE_DEFAULT_BUILD_TYPE.rst
@@ -0,0 +1,16 @@
+CMAKE_DEFAULT_BUILD_TYPE
+========================
+
+.. default-domain:: cmake
+
+.. variable:: CMAKE_DEFAULT_BUILD_TYPE
+
+Specifies the default build type on multi-configuration generators. See
+:variable:`CMAKE_DEFAULT_BUILD_TYPE <variable:CMAKE_DEFAULT_BUILD_TYPE>`.
+
+The value of this variable is fixed to ``MinSizeRel``. See
+:variable:`CMAKE_BUILD_TYPE` for the various build types.
+
+--------------
+
+*Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.*
diff --git a/docs/cmake/manual/variables.rst b/docs/cmake/manual/variables.rst
index e61ede6d2b..699ae7eb07 100644
--- a/docs/cmake/manual/variables.rst
+++ b/docs/cmake/manual/variables.rst
@@ -22,6 +22,8 @@ manual.
:glob:
:maxdepth: 1
+ variable/intrinsic/*
+
Common Variables
----------------