Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: Some minor corrections to the new set utils #4281

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/cmake/set_utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ macro (set_from_env var)
endif ()
elseif (DEFINED _sfe_DEFAULT)
set (${var} ${_sfe_DEFAULT})
if (_sfe_VERBOSE OR VERBOSE)
message (VERBOSE "set ${_sfe_NAME} = ${_sfe_DEFAULT}")
endif ()
endif ()
endif ()
endmacro ()
Expand All @@ -50,7 +47,8 @@ endmacro ()
# Wrapper for CMake `set()` functionality with extensions:
# - If an env variable of the same name exists, it overrides the default
# value.
# - In verbose mode, print the value and whether it came from the env.
# - In verbose mode or if the optional VERBOSE argument is passed, print the
# value and whether it came from the env.
# - CACHE optional token makes it a cache variable.
# - ADVANCED optional token sets it as "mark_as_advanced" without the need
# for a separate call (only applies to cache variables.)
Expand All @@ -62,7 +60,7 @@ endmacro ()
macro (super_set name value)
cmake_parse_arguments(_sce # prefix
# noValueKeywords:
"FORCE;ADVANCED;FILEPATH;PATH;BOOL;STRING;CACHE"
"FORCE;ADVANCED;FILEPATH;PATH;BOOL;STRING;CACHE;VERBOSE"
# singleValueKeywords:
"DOC"
# multiValueKeywords:
Expand All @@ -85,11 +83,15 @@ macro (super_set name value)
set_if_not (_sce_DOC "empty")
set_from_env (_sce_val ENVVAR ${name} NAME ${name} DEFAULT ${value})
if (_sce_CACHE)
message (STATUS "set (${name} ${_sce_val} CACHE ${_sce_type} ${_sce_DOC} ${_sce_extra_args})")
set (${name} ${_sce_val} CACHE ${_sce_type} ${_sce_DOC} ${_sce_extra_args})
set (${name} ${_sce_val} CACHE ${_sce_type} "${_sce_DOC}" ${_sce_extra_args})
else ()
set (${name} ${_sce_val} ${_sce_extra_args})
endif ()
if (_sce_VERBOSE)
message (STATUS "${name} = ${${name}}")
else ()
message (VERBOSE "${name} = ${${name}}")
endif ()
if (_sce_ADVANCED)
mark_as_advanced (${name})
endif ()
Expand All @@ -101,7 +103,7 @@ endmacro ()

# `set(... CACHE ...)` workalike using super_set underneath.
macro (set_cache name value docstring)
super_set (${name} "${value}" DOC ${docstring} ${ARGN})
super_set (${name} "${value}" DOC ${docstring} CACHE ${ARGN})
endmacro ()


Expand Down
Loading