toolchain_overridable_option() : user + toolchain overridable project options()s#32
Open
daminetreg wants to merge 1 commit intomainfrom
Open
toolchain_overridable_option() : user + toolchain overridable project options()s#32daminetreg wants to merge 1 commit intomainfrom
daminetreg wants to merge 1 commit intomainfrom
Conversation
…ption()s
This provides project options that can be overriden in cmake toolchain
files, or can be marked as NON_OVERRIDABLE in toolchains files to error
out if an user tries to override settings that should not be overriden
from toolchain files.
It is meant to replace option() in project with a reliable and constant
behaviour even when CMP077 is off.
It behaves with the following priority :
1. -DOPTION passed by user always overrides or results in an error
when an option is marked NON_OVERRIDABLE
2. CMAKE_TOOLCHAIN_FILE options (marked with TOOLCHAIN_DEFAULT)
always override project options values ( unless overriden by user ).
The tracking of the default option allows user to get a warning
whenever the previous default of an user-overriden option changes.
This module exists to permit :
* overridable toolchain options
* configurable toolchains options
* reliable project options
Rationale
=========
Before CMake 3.13 if set() was used without CACHE the value would not
be taken by option(), leading to a reconfiguration changing the toolchain
prescribed value on the first build.
Also this leads to using CACHE FORCE because otherwise any modification
of the value in the toolchain file would not be taken in an already
configured build tree, requiring full rebuilds to test a simple
toolchain value change.
Finally the new behaviour of option() since CMP0077 is for option() to
respect scope variables in priority. This makes essentially plain
option() set in a toolchain file non-overridable on the command line,
as the cmake -D command line sets CACHE variables.
Usage:
toolchain_overridable_option(
<variable_name>
"<cache comment string>"
<default value>
[TYPE [BOOL/PATH/FILEPATH/STRING]]
[NON_OVERRIDABLE]
[TOOLCHAIN_DEFAULT]
)
Change-Id: I4f1f00d71039288eb344b8a0969fa12ed1091224
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This provides project options that can be overriden in cmake toolchain files, or can be marked as NON_OVERRIDABLE in toolchains files to error out if an user tries to override settings that should not be overriden from toolchain files.
It is meant to replace option() in project with a reliable and constant behaviour even when CMP077 is off.
It behaves with the following priority :
The tracking of the default option allows user to get a warning whenever the previous default of an user-overriden option changes.
This module exists to permit :
Rationale
Before CMake 3.13 if set() was used without CACHE the value would not be taken by option(), leading to a reconfiguration changing the toolchain prescribed value on the first build.
Also this leads to using CACHE FORCE because otherwise any modification of the value in the toolchain file would not be taken in an already configured build tree, requiring full rebuilds to test a simple toolchain value change.
Finally the new behaviour of option() since CMP0077 is for option() to respect scope variables in priority. This makes essentially plain option() set in a toolchain file non-overridable on the command line, as the cmake -D command line sets CACHE variables.
Usage:
Change-Id: I4f1f00d71039288eb344b8a0969fa12ed1091224