Build: add build type support
Refactor cmake files to support setting the "build type" following CMake
idioms. A "build type" is a set of compiler flags controlling code
optimization and debug information generation. For more information on
the supported types and their meaning please refer to the documentation.
This change extends build type support to external components too. The
build type of each component can be independently controlled using
command line settings. For details about the supported types and
settings, please refer to the cmake file of the external component and
the documentation of the external project.
This change tries to be backwards compatible and selects the default
build type to be "Debug". This may change in the future.
Change-Id: Ic041140bb8d4aaf0f07be9c4cac0638c03996eb5
Signed-off-by: Gyorgy Szing <Gyorgy.Szing@arm.com>
diff --git a/docs/developer/build-instructions.rst b/docs/developer/build-instructions.rst
index 5fe6c63..d5f23bc 100644
--- a/docs/developer/build-instructions.rst
+++ b/docs/developer/build-instructions.rst
@@ -25,6 +25,39 @@
.. uml:: uml/BuildFlow.puml
+Selecting the build type
+-------------------------
+The build type selects code optimization and debug information related compiler settings. The build system follows the
+standard CMake methodology and uses the `CMAKE_BUILD_TYPE`_ variable.
+
+The build system uses the following build types:
+
+.. list-table:: Supported build types
+ :header-rows: 1
+
+ * - Build type
+ - Purpose
+ - Description
+ * - Debug
+ - For debugging purposes.
+ - Optimization is off, debugging information generation is enabled.
+ * - MinSizeRel
+ - Size optimized release build.
+ - Optimization is configured to prefer small code size, debugging information is not generated.
+ * - MinSizWithDebInfo
+ - For debugging size optimized release build.
+ - Optimization is configured to prefer small code size, debugging information generation is enabled.
+ * - Release
+ - Speed optimized release build.
+ - Optimization is configured to prefer execution speed, debugging information is not generated.
+ * - RelWithDebugInfo
+ - For debugging speed optimized release build.
+ - Optimization is configured to prefer execution speed, debugging information generation is enabled.
+
+Build type of external components can be configured with command line parameters. Parameter names follow this pattern:
+``-D<upper case component name>_BUILD_TYPE=<value>`` e.g. ``-DNANOPB_BUILD_TYPE=Release``. Supported values are
+component specific, please refer to the appropriate cmake file under ``<TS_ROOT>/external/<name>``.
+
Building and Installing
-----------------------
When building from a clean environment where no generated build files exist, it is necessary to run
@@ -135,6 +168,8 @@
--------------
-*Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.*
+.. _CMAKE_BUILD_TYPE: https://cmake.org/cmake/help/v3.18/variable/CMAKE_BUILD_TYPE.html
+
+*Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.*
SPDX-License-Identifier: BSD-3-Clause