find_package(OpenMP)
if (OPENMP_FOUND)
  set(CMAKE_REQUIRED_FLAGS ${OpenMP_CXX_FLAGS})
  set(mybody "#include <omp.h>
int main() {
#pragma omp taskwait
return 0;
}")

  check_cxx_source_compiles("${mybody}" OpenMP3)
  set(CMAKE_REQUIRED_FLAGS )
  if ("${OpenMP3}" MATCHES "1")
    message(STATUS "OpenMP 3 is supported and will be used")
  else()
    message(STATUS "OpenMP 3 not supported - will not be used")
    set(OpenMP_CXX_FLAGS "" CACHE STRING "OpenMP flags" FORCE)
    set(OPENMP_FOUND FALSE)
  endif()
endif()

find_package(OpenMP)
if (OPENMP_FOUND)
  set(CMAKE_REQUIRED_FLAGS ${OpenMP_CXX_FLAGS})
  set(mybody "#include <omp.h>
int main() {
omp_sched_t kind;
int chunk_size;
omp_get_schedule(&kind, &chunk_size);
return chunk_size;
}")

  check_cxx_source_compiles("${mybody}" OpenMP3)
  set(CMAKE_REQUIRED_FLAGS )
  if ("${OpenMP3}" MATCHES "1")
    message(STATUS "OpenMP 3 is supported and will be used")
  else()
    message(STATUS "OpenMP 3 not supported - will not be used")
    set(OpenMP_CXX_FLAGS "" CACHE STRING "OpenMP flags" FORCE)
    set(OPENMP_FOUND FALSE)
  endif()
endif()

Add a better test for OpenMP 3
Add a better test for OpenMP 3

Our previous test for OpenMP 3 used a pragma
that was only present in OpenMP 3 (not 2).
However, this didn't work because most compilers
simply ignore unknown pragmas. Replace with a call
to a function that's only present in OpenMP 3, so
that compilation will decisively fail. This should
fix the Mac 10.6 build, which was including OpenMP
support even though the gcc version in OS X 10.6
only supports OpenMP 2.5.

As an aside, recent cmake versions extract the OpenMP
vesion number, which would simplify this test in the
future once we can require a new enough cmake.
