Skip to content

Commit

Permalink
Fix non-sticky options (#1098)
Browse files Browse the repository at this point in the history
  • Loading branch information
sethrj committed Feb 5, 2024
1 parent 642bb2b commit 1f4b002
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions cmake/CeleritasUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -373,11 +373,14 @@ function(celeritas_define_options var doc)
endif()
mark_as_advanced(${var}_OPTIONS)

set(${var} "" CACHE STRING "${doc}")
set_property(CACHE ${var} PROPERTY STRINGS "${${var}_OPTIONS}")

# Current value and var name for previous value
set(_val "${${var}}")
set(_last_var _LAST_${var})

# Add variable to cache with current value if given (empty is default)
set(${var} "${_val}" CACHE STRING "${doc}")
set_property(CACHE ${var} PROPERTY STRINGS "${${var}_OPTIONS}")

if(_val STREQUAL "")
# Dynamic default option: set as core variable in parent scope
list(GET ${var}_OPTIONS 0 _default)
Expand Down

0 comments on commit 1f4b002

Please sign in to comment.