@@ -881,7 +881,8 @@ jrl_legacy_option(
881881
882882### Description
883883 Migrate a legacy option value to a new option name and emit a deprecation warning.
884- If the old option is defined, its value is migrated to the new option.
884+ If the old option is defined, its value is migrated to the new option and the old cache
885+ entry is removed, so the migration happens only once.
885886 The NEW_OPTION must already exist in the cache (created via jrl_option or option()).
886887 The help text is automatically retrieved from the NEW_OPTION cache property.
887888
@@ -914,19 +915,27 @@ jrl_option(
914915
915916
916917### Description
917- Declare a cache BOOL option with optional conditional availability and legacy name migration.
918- When `CONDITION` evaluates to false, the option is forced to the `FALLBACK` value (default OFF) with FORCE and hidden.
918+ Declare a cache BOOL (all CMake options are booleans) option, with an optional condition and an optional legacy name.
919+ When `CONDITION` is false, the option is forced to the `FALLBACK` value and hidden.
920+ When `CONDITION` becomes true again on a reconfigure, the option is shown again and
921+ gets back the value the user asked for, or `<default_value>` if they never set one.
919922 When `LEGACY_NAME` is set, its value is migrated to `<name>` and a deprecation
920923 warning is emitted.
921924
925+ Like CMake `option()` with policy `CMP0077`, a normal variable of the same name takes
926+ precedence without creating a cache entry, allowing a parent project to set options
927+ before `add_subdirectory()` or `FetchContent`. If `CONDITION` evaluates to false, the
928+ fallback value is still enforced.
929+
922930
923931### Arguments
924932* `name`: The option name.
925933* `help_text`: The cache entry help string.
926934* `default_value`: The default value (ON/OFF).
927935* `CONDITION`: CMake condition string to evaluate (optional). If false, the option will be forced to FALLBACK value.
928- * `FALLBACK`: Value to force when CONDITION is false (optional).
929- * `LEGACY_NAME`: Deprecated option name to migrate (optional).
936+ A semicolon-separated list is also accepted, in which case every element must be true, as in `cmake_dependent_option()`.
937+ * `FALLBACK`: Value to force when CONDITION is false (required when CONDITION is given).
938+ * `LEGACY_NAME`: Deprecated option name to migrate (optional). It is an alias for `<name>`, so it goes through `CONDITION` as well.
930939
931940
932941### Example
@@ -941,6 +950,12 @@ jrl_option(
941950 LEGACY_NAME BUILD_PYTHON_BINDINGS
942951)
943952```
953+
954+ `BUILD_PYTHON` follows its condition from one configure to the next:
955+ ```bash
956+ cmake -B build -DBUILD_SHARED_LIBS=OFF # BUILD_PYTHON is forced to OFF and hidden
957+ cmake build -DBUILD_SHARED_LIBS=ON # BUILD_PYTHON is ON and visible again
958+ ```
944959# `jrl_generate_options_markdown_summary`
945960
946961```cpp
0 commit comments