function(ValidateOptions ValidOptions ChoiceName DefaultChoice Choice RetVal) if(Choice) if(Choice MATCHES "ALL") set(${RetVal} ${ValidOptions} PARENT_SCOPE) message(STATUS "ALL ${ChoiceName} option set, configuring ${ValidOptions}.") else() foreach(x IN LISTS Choice) if(x IN_LIST ValidOptions) message(STATUS "Configuring for ${x}.") else() message(FATAL_ERROR "${x} not supported. The supported ${ChoiceName} are: ${ValidOptions}.") endif() set(${RetVal} ${Choice} PARENT_SCOPE) endforeach() endif() else() set(${RetVal} ${DefaultChoice} PARENT_SCOPE) message(STATUS "No -D${ChoiceName}= parameter, configuring ${DefaultChoice} by default.") endif() endfunction()