+# Build a list variable named FACTORIES_LIST with the given arguments, but:
+# - replace wildcard "*" with all known factories
+# - if the list begins with "^", take the complement
+# - finally remove unsupported factories
+#
+# Used by ADD_TESH_FACTORIES, and SET_TESH_PROPERTIES
+MACRO(SETUP_FACTORIES_LIST)
+ set(ALL_KNOWN_FACTORIES "thread;boost;raw;ucontext")
+
+ if("${ARGV}" STREQUAL "*") # take all known factories
+ SET(FACTORIES_LIST ${ALL_KNOWN_FACTORIES})
+ elseif("${ARGV}" MATCHES "^\\^") # exclude given factories
+ SET(FACTORIES_LIST ${ALL_KNOWN_FACTORIES})
+ STRING(SUBSTRING "${ARGV}" 1 -1 EXCLUDED)
+ LIST(REMOVE_ITEM FACTORIES_LIST ${EXCLUDED})
+ else() # take given factories
+ SET(FACTORIES_LIST "${ARGV}")
+ endif()
+
+ # Exclude unsupported factories. Threads are always available, thanks to C++11 threads.
+ if(NOT HAVE_BOOST_CONTEXTS)
+ LIST(REMOVE_ITEM FACTORIES_LIST "boost")
+ endif()
+ if(NOT HAVE_RAW_CONTEXTS)
+ LIST(REMOVE_ITEM FACTORIES_LIST "raw")
+ endif()
+ if(NOT HAVE_UCONTEXT_CONTEXTS)
+ LIST(REMOVE_ITEM FACTORIES_LIST "ucontext")
+ endif()
+
+ # Check that there is no unknown factory
+ FOREACH(FACTORY ${FACTORIES_LIST})
+ if(NOT FACTORY IN_LIST ALL_KNOWN_FACTORIES)
+ message(FATAL_ERROR "Unknown factory: ${FACTORY}")
+ endif()
+ ENDFOREACH()
+ENDMACRO()
+