Add a helper for the common pattern of: args_to_use = [] foreach arg : candidate_args if cc.has_argument(arg) args_to_use += arg endif endforeach Replaced with: args_to_use = cc.get_supported_arguments(candidate_args)