TriBITS icon indicating copy to clipboard operation
TriBITS copied to clipboard

Implement and use tribits_[advanced_]set_with_default_override()

Open bartlettroscoe opened this issue 2 years ago • 2 comments

Description

A common idiom used with TriBITS is to define a cache var with the framework that allows the project to define an override as a non-cache var. The idiom looks like this:

if (NOT "${<varName>_DEFAULT}" STREQUAL "")
  set(<varName>_DEFAULT <defaultVal>)
endif()
advanced_set(<varName> "${<varName>_DEFAULT}" CACHE <type> "<docString>")

The set of TriBITS framework-level vars that have project-level default overrides are listed here.

The function that would be added for this is:

tribits_advanced_set_with_default_override(<varName> <defaultVal> CACHE <type> "<docString>")

(where advanced_set() is deprecated and used properly namespaced tribits_advanced_set()).

And there could also be a function of a non-advanced cache var with:

tribits_set_with_default_override(<varName> <defaultVal> CACHE <type> "<docString>")

This would cut down on a lot of boilerplate code and provide some more uniformity.

NOTE: This was suggested by @KyleFromKitware in https://github.com/TriBITSPub/TriBITS/pull/560#discussion_r1124670680.

bartlettroscoe avatar Mar 29 '23 13:03 bartlettroscoe

This has been started in PR #591.

bartlettroscoe avatar Sep 19 '23 19:09 bartlettroscoe