Skip to content

Commit 01c2f12

Browse files
committed
Update docs
1 parent 043a6fd commit 01c2f12

File tree

1 file changed

+33
-23
lines changed

1 file changed

+33
-23
lines changed

docs/cmake/modules/PHP/Set.md

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ See: [Set.cmake](https://github.com/petk/php-build-system/tree/master/cmake/cmak
44

55
Set a CACHE variable that depends on a set of conditions.
66

7-
In CMake there are 3 main ways to create non-internal cache variables that can
8-
be also customized using the `-D` command-line option, through CMake presets, or
9-
similar:
7+
At the time of writing, there are 3 main ways in CMake to create non-internal
8+
cache variables that can be also customized from the outside using the `-D`
9+
command-line option, through CMake presets, or similar:
1010
* `option()`
1111
* `set(<variable> <value> CACHE <type> <docstring>)`
1212
* `cmake_dependent_option()`
@@ -25,31 +25,41 @@ This module exposes the following function:
2525
```cmake
2626
php_set(
2727
<variable>
28-
<default>
29-
CACHE <type>
30-
[STRINGS <string>...]
31-
[DOC <docstring>...]
32-
IF <condition>
33-
FORCED <forced>
28+
TYPE <type>
29+
[CHOICES <string>...]
30+
[IF <condition> VALUE <value> [ELSE_VALUE <default>]] | [VALUE <value>]
31+
DOC <docstring>...
3432
)
3533
```
3634

37-
It sets the given CACHE `<variable>` of `<type>` to a `<value>` if `<condition>`
38-
is met. Otherwise it sets the `<variable>` to `<default>` value and hides it in
39-
the GUI.
35+
It sets a CACHE `<variable>` of `<type>` to a `<value>`.
4036

41-
* The `CACHE` `<type>` can be `BOOL`, `FILEPATH`, `PATH`, or `STRING`.
37+
* `TYPE` can be `BOOL`, `FILEPATH`, `PATH`, or `STRING`.
4238

43-
* `STRINGS` is an optional list of items when `CACHE` `STRING` is used to create
44-
a list of supported options to pick in the GUI.
39+
* `CHOICES` is an optional list of items when `STRING` type is used to create
40+
a list of supported options to pick in the GUI. Under the hood, it sets the
41+
`STRINGS` CACHE variable property.
4542

46-
* `DOC` is a short variable help text visible in the GUIs. Multiple strings are
47-
joined together.
43+
* `VALUE` is the default variable value. There are two ways to set default
44+
value.
45+
46+
* When using the `IF <condition>` argument, it sets the variable to `<value>`
47+
if `<condition>` is met. Otherwise it sets the `<variable>` to `ELSE_VALUE`
48+
`<default>` and hides it in the GUI, if `ELSE_VALUE` is given. Under the
49+
hood `ELSE_VALUE` will set `INTERNAL` cache variable if `<condition>` is not
50+
met. If `ELSE_VALUE` is not provided, the `INTERNAL` cache variable is not
51+
set (it is undefined).
52+
53+
`IF` behaves the same as the `<depends>` argument in the
54+
`cmake_dependent_option()`. This supports both full condition sytanx and
55+
semicolon-separated list of conditions.
4856

49-
* `IF` behaves the same as the `<depends>` argument in
50-
`cmake_dependent_option()`. If conditions `<condition>` are met, the variable
51-
is set to `<default>` value. Otherwise, it is set to `<forced>` value and
52-
hidden in the GUIs. This supports both full condition sytanx and
53-
semicolon-separated list of conditions.
57+
* When using only `VALUE` signature, it sets the cache variable to `<value>`.
58+
It is the same as writing:
5459

55-
* `FORCED` is a value that is set when `IF <conditions>` are not met.
60+
```cmake
61+
set(<variable> <value> CACHE <type> <docstring>)
62+
```
63+
64+
* `DOC` is a short variable help text visible in the GUIs. Multiple strings are
65+
joined together.

0 commit comments

Comments
 (0)