TriBITSPub / TriBITS

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

Add tribits_invalid_value() function for else statements for enums #572

Open bartlettroscoe opened 1 year ago

bartlettroscoe commented 1 year ago

Description

There is a lot of code in TriBITS that passed strings as enums like:

if (<varName> STREQUAL "<valueA>")
  ...
elseif (<varName> STREQUAL "<valueB>")
  ...
elseif (<varName> STREQUAL "<valueC>")
  ...
else()
  message(FATAL_ERROR "Error, the value of <varName>='${<varName>}' is not in the allowed list ...")
endif()

It may help to replace this with a function like:

else()
  tribits_invalid_value(<varName> [<listOfValidValues>])
endif()

where the list of valid values var name <listOfValidValues> could be empty.

NOTE: Something like this was suggested by @KyleFromKitware in https://github.com/TriBITSPub/TriBITS/pull/560#pullrequestreview-1312218533.