+if(mcsc MATCHES "no" AND pthread MATCHES "no")
+ CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
+ if(HAVE_WINDOWS_H)
+ set(windows_context "yes")
+ set(IS_WINDOWS 1)
+ elseif(HAVE_WINDOWS_H)
+ message("no appropriate backend found")
+ endif(HAVE_WINDOWS_H)
+endif(mcsc MATCHES "no" AND pthread MATCHES "no")
+
+if(NOT disable_context AND with_context MATCHES "ucontext" AND mcsc MATCHES "no")
+ message(FATAL_ERROR "-Dwith-context=ucontext specified but ucontext unusable.")
+endif(NOT disable_context AND with_context MATCHES "ucontext" AND mcsc MATCHES "no")
+
+if(NOT disable_context)
+ set(with_context_ok 0)
+ if(with_context MATCHES "windows")
+ set(with_context_ok 1)
+ endif(with_context MATCHES "windows")
+
+ if(with_context MATCHES "pthreads")
+ set(with_context_ok 1)
+ set(with_context "pthread")
+ endif(with_context MATCHES "pthreads")
+
+ if(with_context MATCHES "auto")
+ set(with_context_ok 1)
+ set(with_context "ucontext")
+ message("with_context auto change to ucontext")
+ endif(with_context MATCHES "auto")
+
+ if(with_context MATCHES "ucontext")
+ set(with_context_ok 1)
+ if(mcsc MATCHES "yes")
+ set(CONTEXT_UCONTEXT 1)
+ CHECK_INCLUDE_FILE(valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H)
+ else(mcsc MATCHES "yes")
+ if(windows_context MATCHES "yes")
+ set(with_context "windows")
+ else(windows_context MATCHES "yes")
+ set(with_context "pthread")
+ endif(windows_context MATCHES "yes")
+ endif(mcsc MATCHES "yes")
+ endif(with_context MATCHES "ucontext")
+
+ if(with_context MATCHES "pthread")
+ set(with_context_ok 1)
+ if(pthread MATCHES "no")
+ message(FATAL_ERROR "Cannot find pthreads (try -Dwith_context=ucontext if you haven't already tried).")
+ endif(pthread MATCHES "no")
+ SET(CONTEXT_THREADS 1)
+ endif(with_context MATCHES "pthread")
+
+ if(with_context MATCHES "ucontext")
+ SET(CONTEXT_THREADS 0)
+ endif(with_context MATCHES "ucontext")
+
+ if(NOT with_context_ok)
+ message(FATAL_ERROR "-Dwith-context must be either ucontext or pthread")
+ endif(NOT with_context_ok)
+endif(NOT disable_context)
+