diff options
author | Chris Kay <chris.kay@arm.com> | 2021-08-19 14:40:23 +0100 |
---|---|---|
committer | Chris Kay <chris.kay@arm.com> | 2022-01-11 17:19:12 +0000 |
commit | 15219db30cf372071f6f96260cfcdb1ba0cc5db0 (patch) | |
tree | 5a1af2b5793b14e3e90b086c5ae7b1bc5024fa3f | |
parent | d18087357b7e84b7d97f1cf9b756538d541b914d (diff) | |
download | trusted-firmware-a-15219db30cf372071f6f96260cfcdb1ba0cc5db0.tar.gz |
build(cmake): add legacy option helper
To assist in moving from the legacy Makefile build system to the CMake
build system, we are introducing a legacy option helper function, which
detects usage of legacy build system options and directs users towards
their replacements.
Change-Id: I2a8f57e6361006475c40d3b874b0f31ce48a77f7
Signed-off-by: Chris Kay <chris.kay@arm.com>
-rw-r--r-- | cmake/Modules/TFALegacyOption.cmake | 81 | ||||
-rw-r--r-- | docs/cmake/manual/module/internal/TFALegacyOption.rst | 5 |
2 files changed, 86 insertions, 0 deletions
diff --git a/cmake/Modules/TFALegacyOption.cmake b/cmake/Modules/TFALegacyOption.cmake new file mode 100644 index 0000000000..05cedc48ab --- /dev/null +++ b/cmake/Modules/TFALegacyOption.cmake @@ -0,0 +1,81 @@ +#[=======================================================================[.rst: +TFALegacyOption +--------------- + +.. default-domain:: cmake + +.. command:: tfa_legacy_option + +Warn the user about a legacy build system configuration option, and offer +alternatives understood by the CMake build system. + +.. code-block:: cmake + + tfa_legacy_option(OLD <old>... NEW <new>...) + +Generate a warning when any of the variables specified by ``<old>...`` are +defined which directs the user to an alternative set of configuration options +defined by ``<new>...``. + +.. code-block:: cmake + :caption: Usage example + :linenos: + + # cmake -DOLD_OPTION_B=ON ... + + tfa_legacy_option( + OLD OLD_OPTION_A OLD_OPTION_B + NEW NEW_OPTION_C NEW_OPTION_D) + + # The following configuration option relates to Trusted Firmware-A's legacy + # build system: + # + # - OLD_OPTION_B + # + # This option has been superceded. Please see the documentation for the + # following configuration options: + # + # - NEW_OPTION_C + # - NEW_OPTION_D +#]=======================================================================] + +include_guard() + +function(tfa_legacy_option) + set(options "") + set(single-args "") + set(multi-args "OLD;NEW") + + cmake_parse_arguments( + ARG "${options}" "${single-args}" "${multi-args}" ${ARGN}) + + list(LENGTH ARG_NEW count) + + foreach(old IN LISTS ARG_OLD) + if(DEFINED ${old}) + if(ARG_NEW) + string(CONCAT message + "The following configuration option relates to Trusted " + "Firmware-A's legacy build system:\n" + + " - ${old}\n" + + "This option has been superceded. Please see the " + "documentation for the following configuration options:") + + foreach(new IN LISTS ARG_NEW) + string(APPEND message "\n - ${new}") + endforeach() + else() + string(CONCAT message + "The following configuration option relates to Trusted " + "Firmware-A's legacy build system, and is no longer " + "necessary:\n" + + " - ${old}") + endif() + + message(WARNING "${message}") + endif() + endforeach() +endfunction() diff --git a/docs/cmake/manual/module/internal/TFALegacyOption.rst b/docs/cmake/manual/module/internal/TFALegacyOption.rst new file mode 100644 index 0000000000..135c7447c3 --- /dev/null +++ b/docs/cmake/manual/module/internal/TFALegacyOption.rst @@ -0,0 +1,5 @@ +.. cmake-module:: ../../../../../cmake/Modules/TFALegacyOption.cmake + +-------------- + +*Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.* |