[CMake] Detect information about test compiler

Perform a nested CMake invocation to avoid writing our own parser
for compiler versions when we are not testing the in-tree compiler.
Use the extracted information to mark a test as unsupported that
hangs with Clang prior to version 4.0.1 and restrict tests for
libomptarget to Clang version 6.0.0 and later.

Differential Revision: https://reviews.llvm.org/D40083

llvm-svn: 319448
diff --git a/openmp/cmake/DetectTestCompiler/CMakeLists.txt b/openmp/cmake/DetectTestCompiler/CMakeLists.txt
new file mode 100644
index 0000000..82d287b
--- /dev/null
+++ b/openmp/cmake/DetectTestCompiler/CMakeLists.txt
@@ -0,0 +1,19 @@
+cmake_minimum_required(VERSION 2.8)
+project(DetectTestCompiler C CXX)
+
+function(write_compiler_information lang)
+  set(information "${CMAKE_${lang}_COMPILER}")
+  set(information "${information}\\;${CMAKE_${lang}_COMPILER_ID}")
+  set(information "${information}\\;${CMAKE_${lang}_COMPILER_VERSION}")
+  set(information "${information}\\;${OpenMP_${lang}_FLAGS}")
+  file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${lang}CompilerInformation.txt ${information})
+endfunction(write_compiler_information)
+
+find_package(OpenMP)
+if (NOT OpenMP_Found)
+  set(OpenMP_C_FLAGS "-fopenmp")
+  set(OpenMP_CXX_FLAGS "-fopenmp")
+endif()
+
+write_compiler_information(C)
+write_compiler_information(CXX)