TriBITSPub / TriBITS

TriBITS: Tribal Build, Integrate, and Test System,
http://tribits.org
Other
36 stars 46 forks source link

Implement and use tribits_[advanced_]set_with_default_override() #570

Open bartlettroscoe opened 1 year ago

bartlettroscoe commented 1 year ago

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 commented 1 year ago

This has been started in PR #591.