After three iterations of community review, we believe that this new
CMAKE buld system should meet everyone's requirements.

Enhanced CMake Build System Commit 

* Supports Linux, Mac, Windows, and IntelĀ® Xeon Phi builds
* Supports building with gcc, icc, clang, and Visual Studio compilers
* Supports bulding "fat" libraries on OS/X with clang
* Details and documentation on how to use build system 
  are in Build_With_CMake.txt
* To use the old CMake build system (corresponds to 
  CMakeLists.txt.old), just rename CMakeLists.txt to
  CMakeLists.txt.other and rename CMakeLists.txt.old to
  CMakeLists.txt

llvm-svn: 214850
diff --git a/openmp/runtime/cmake/BuildPLRules.cmake b/openmp/runtime/cmake/BuildPLRules.cmake
new file mode 100644
index 0000000..8db0f2f
--- /dev/null
+++ b/openmp/runtime/cmake/BuildPLRules.cmake
@@ -0,0 +1,100 @@
+###############################################################################
+# This file contains additional build rules that correspond to build.pl's rules
+# Building libiomp5.dbg is linux only, Windows will build libiomp5md.dll.pdb
+#
+#                        ######### BUILD DEPENDENCIES ##########
+#
+#        exports/.../libiomp5.so                        exports/.../libiomp5.dbg
+#        [copy]  |                                                 | [copy]
+#                |                                                 |
+#           ./libiomp5.so                                     ./libiomp5.dbg
+#    [copy]    /  OR  \____________ [copy]                         | [copy]
+#             /                    \                               |
+#    ./unstripped/libiomp5.so   ./stripped/libiomp5.so   ./unstripped/libiomp5.dbg
+#           /                                \                /
+#          / [linking]                        \[strip]       /[strip and store]
+#         /                                    \            /
+#     ${objs} (maybe compiled with -g)     ./unstripped/libiomp5.so (library with debug info in it)
+#                                                    |
+#                                                    | [linking]
+#                                                    |
+#                                                 ${objs} (always compiled with -g)
+#
+# For icc Linux builds, we always include debugging information via -g and create libiomp5.dbg 
+# so that Intel(R) Parallel Amplifier can use the .dbg file.
+# For icc Windows builds, we always include debugging information via -Zi and create libiomp5.pdb
+# in a fashion similar to libiomp5.dbg
+# For icc Mac builds, we don't bother with the debug info.
+
+# We build library in unstripped directory
+file(MAKE_DIRECTORY ${build_dir}/unstripped)
+
+# Only build the .dbg file for Release builds
+# Debug and RelWithDebInfo builds should not create a .dbg file.  
+# The debug info should remain in the library file.
+if(${LINUX} AND ${RELEASE_BUILD})
+    set(dbg_file ${lib_item}.dbg)
+endif()
+
+################################
+# --- Create $(lib_file).dbg ---
+if(NOT "${dbg_file}" STREQUAL "")
+    # if a ${dbg_file} file is going to be created, then 
+    file(MAKE_DIRECTORY ${build_dir}/stripped)
+
+    # ./${lib_file} : stripped/${lib_file}
+    #     copy stripped/${lib_file} ./${lib_file}
+    simple_copy_recipe("${lib_file}"   "${build_dir}/stripped"   "${build_dir}")
+
+    # stripped/${lib_file} : unstripped/${lib_file} ./${dbg_file}
+    #     objcopy --strip-debug unstripped/${lib_file} stripped/${lib_file}.tmp
+    #     objcopy --add-gnu-debuglink=${dbg_file} stripped/${lib_file}.tmp stripped/${lib_file}
+    add_custom_command(
+        OUTPUT  ${build_dir}/stripped/${lib_file}
+        COMMAND ${CMAKE_OBJCOPY} --strip-debug ${build_dir}/unstripped/${lib_file} ${build_dir}/stripped/${lib_file}.tmp
+        COMMAND ${CMAKE_OBJCOPY} --add-gnu-debuglink=${dbg_file} ${build_dir}/stripped/${lib_file}.tmp ${build_dir}/stripped/${lib_file}
+        DEPENDS "${build_dir}/${dbg_file}"
+    )
+
+    # ./${dbg_file} : unstripped/${dbg_file}
+    #     copy unstripped/${dbg_file} ./${dbg_file}
+    simple_copy_recipe("${dbg_file}"   "${build_dir}/unstripped" "${build_dir}")
+
+    # unstripped/${dbg_file} : unstripped/${lib_file}
+    #     objcopy --only-keep-debug unstripped/${lib_file} unstripped/${dbg_file}
+    add_custom_command(
+        OUTPUT  ${build_dir}/unstripped/${dbg_file}
+        COMMAND ${CMAKE_OBJCOPY} --only-keep-debug ${build_dir}/unstripped/${lib_file} ${build_dir}/unstripped/${dbg_file} 
+        DEPENDS iomp5
+    )
+    
+else()
+
+    # ./${lib_file} : unstripped/${lib_file}
+    #      copy unstripped/${lib_file} ./${lib_file}
+    simple_copy_recipe("${lib_file}"   "${build_dir}/unstripped"  "${build_dir}")
+endif()
+
+# Windows specific command to move around debug info files post-build
+if(NOT "${pdb_file}" STREQUAL "" AND ${RELEASE_BUILD})
+    add_custom_command(TARGET iomp5 POST_BUILD
+        COMMAND ${CMAKE_COMMAND} -E rename ${pdb_file} ${pdb_file}.nonstripped
+        COMMAND ${CMAKE_COMMAND} -E rename ${pdb_file}.stripped ${pdb_file}
+    )
+endif()
+
+# Have icc build libiomp5 in unstripped directory
+set_target_properties(iomp5 PROPERTIES 
+    LIBRARY_OUTPUT_DIRECTORY "${build_dir}/unstripped" 
+    RUNTIME_OUTPUT_DIRECTORY "${build_dir}/unstripped"
+    ARCHIVE_OUTPUT_DIRECTORY "${build_dir}"
+)
+
+# Always use RelWithDebInfo flags for Release builds when using the build.pl's build rules (use -g -O2 instead of just -O3)
+# The debug info is then stripped out at the end of the build and put into libiomp5.dbg for Linux
+if(${RELEASE_BUILD} AND NOT ${MAC})
+    set(CMAKE_C_FLAGS_RELEASE   ${CMAKE_C_FLAGS_RELWITHDEBINFO}  )
+    set(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
+    set(CMAKE_ASM_FLAGS_RELEASE ${CMAKE_ASM_FLAGS_RELWITHDEBINFO})
+endif()
+
diff --git a/openmp/runtime/cmake/Clang/AsmFlags.cmake b/openmp/runtime/cmake/Clang/AsmFlags.cmake
new file mode 100644
index 0000000..b23e6b9
--- /dev/null
+++ b/openmp/runtime/cmake/Clang/AsmFlags.cmake
@@ -0,0 +1,16 @@
+# This file holds Clang (clang/clang++) specific compiler dependent flags
+# The flag types are:
+#   1) Assembly flags
+
+#########################################################
+# Assembly flags
+function(append_assembler_specific_asm_flags input_asm_flags)
+    set(local_asm_flags)
+    append_asm_flags("-x assembler-with-cpp") # Assembly file that needs to be preprocessed
+    if(${IA32})
+        append_asm_flags("-m32") # Generate 32 bit IA-32 architecture code 
+        append_asm_flags("-msse2") # Allow use of Streaming SIMD Instructions
+    endif()
+    set(${input_asm_flags} ${${input_asm_flags}} "${local_asm_flags}" PARENT_SCOPE)
+endfunction()
+
diff --git a/openmp/runtime/cmake/Clang/CFlags.cmake b/openmp/runtime/cmake/Clang/CFlags.cmake
new file mode 100644
index 0000000..54e1809
--- /dev/null
+++ b/openmp/runtime/cmake/Clang/CFlags.cmake
@@ -0,0 +1,38 @@
+# This file holds Clang (clang/clang++) specific compiler dependent flags
+# The flag types are:
+#   1) C/C++ Compiler flags
+#   2) Linker flags
+
+#########################################################
+# C/C++ Compiler flags
+function(append_compiler_specific_c_and_cxx_flags input_c_flags input_cxx_flags)
+    set(local_c_flags)
+    set(local_cxx_flags)
+    append_c_and_cxx_flags("-std=c++0x") # Enables support for many C++11 (formerly known as C++0x) features. The following are the most recently added features:
+    append_c_and_cxx_flags("-fno-exceptions") # Exception handling table generation is disabled.
+    append_c_and_cxx_flags("-x c++") # Compile C files as C++ files
+    if(${IA32})
+        append_c_and_cxx_flags("-m32") # Generate 32 bit IA-32 architecture code
+        append_c_and_cxx_flags("-msse2") # Allow use of Streaming SIMD Instructions
+    elseif(${ARM})
+        append_c_and_cxx_flags("-marm") # Target the ARM architecture
+    endif()
+    append_c_and_cxx_flags("-Wno-unused-value") # Don't warn about unused values
+    append_c_and_cxx_flags("-Wno-switch") # Don't warn about switch statements that don't cover entire range of values
+    set(${input_c_flags}   ${${input_c_flags}}   "${local_c_flags}" PARENT_SCOPE)
+    set(${input_cxx_flags} ${${input_cxx_flags}} "${local_cxx_flags}" PARENT_SCOPE)
+endfunction()
+
+#########################################################
+# Linker flags
+function(append_compiler_specific_linker_flags input_ld_flags input_ld_flags_libs)
+    set(local_ld_flags)
+    set(local_ld_flags_libs)
+    if(${IA32})
+        append_linker_flags("-m32")
+        append_linker_flags("-msse2")
+    endif()
+    set(${input_ld_flags}      ${${input_ld_flags}}      "${local_ld_flags}"       PARENT_SCOPE)
+    set(${input_ld_flags_libs} ${${input_ld_flags_libs}} "${local_ld_flags_libs}"  PARENT_SCOPE)
+endfunction()
+
diff --git a/openmp/runtime/cmake/CommonFlags.cmake b/openmp/runtime/cmake/CommonFlags.cmake
new file mode 100644
index 0000000..301a3c4
--- /dev/null
+++ b/openmp/runtime/cmake/CommonFlags.cmake
@@ -0,0 +1,133 @@
+# This file holds the common flags independent of compiler
+# The flag types are: 
+#   1) Assembly flags          (append_asm_flags_common)
+#   2) C/C++ Compiler flags    (append_c_and_cxx_flags_common)
+#   3) Fortran Compiler flags  (append_fort_flags_common)
+#   4) Linker flags            (append_linker_flags_common)
+#   5) Archiver flags          (append_archiver_flags_common)
+
+# These append_* macros all append to the corresponding list variable holding the flags.
+macro(append_c_flags new_flag)
+    list(APPEND local_c_flags    "${new_flag}")
+endmacro()
+
+macro(append_cxx_flags new_flag)
+    list(APPEND local_cxx_flags  "${new_flag}")
+endmacro()
+
+macro(append_c_and_cxx_flags new_flag)
+    append_c_flags("${new_flag}")
+    append_cxx_flags("${new_flag}")
+endmacro()
+
+macro(append_asm_flags new_flag)
+    list(APPEND local_asm_flags  "${new_flag}")
+endmacro()
+
+macro(append_fort_flags new_flag)
+    list(APPEND local_fort_flags "${new_flag}")
+endmacro()
+
+# The difference between linker_flags and linker_flags_libs is linker_flags_libs
+# is put at the end of the linker command where linking libraries should be done.
+macro(append_linker_flags new_flag)
+    list(APPEND local_ld_flags   "${new_flag}")
+endmacro()
+
+macro(append_linker_flags_library new_flag)
+    list(APPEND local_ld_flags_libs "${new_flag}")
+endmacro()
+
+macro(append_archiver_flags new_flag)
+    list(APPEND local_ar_flags   "${new_flag}")
+endmacro()
+
+#########################################################
+# Global Assembly flags
+function(append_asm_flags_common input_asm_flags)
+    set(local_asm_flags)
+    set(${input_asm_flags} "${${input_asm_flags}}" "${local_asm_flags}" "${USER_ASM_FLAGS}" PARENT_SCOPE)
+endfunction()
+
+#########################################################
+# Global C/C++ Compiler flags
+function(append_c_and_cxx_flags_common input_c_flags input_cxx_flags)
+    set(local_c_flags)
+    set(local_cxx_flags)
+    set(${input_c_flags}   "${${input_c_flags}}"   "${local_c_flags}"   "${USER_C_FLAGS}"   PARENT_SCOPE)
+    set(${input_cxx_flags} "${${input_cxx_flags}}" "${local_cxx_flags}" "${USER_CXX_FLAGS}" PARENT_SCOPE)
+endfunction()
+
+#########################################################
+# Global Fortran Compiler flags (for creating .mod files)
+function(append_fort_flags_common input_fort_flags)
+    set(local_fort_flags)
+    set(${input_fort_flags} "${${input_fort_flags}}" "${local_fort_flags}" "${USER_F_FLAGS}" PARENT_SCOPE)
+endfunction()
+
+#########################################################
+# Linker flags
+function(append_linker_flags_common input_ld_flags input_ld_flags_libs)
+    set(local_ld_flags)
+    set(local_ld_flags_libs)
+
+    #################################
+    # Windows linker flags
+    if(${WINDOWS}) 
+
+    ##################
+    # MAC linker flags
+    elseif(${MAC})
+        if(${USE_PREDEFINED_LINKER_FLAGS})
+            append_linker_flags("-single_module")
+            append_linker_flags("-current_version ${version}.0")
+            append_linker_flags("-compatibility_version ${version}.0")
+        endif()
+    #####################################################################################
+    # Intel(R) Many Integrated Core Architecture (Intel(R) MIC Architecture) linker flags
+    elseif(${MIC})
+        if(${USE_PREDEFINED_LINKER_FLAGS})
+            append_linker_flags("-Wl,-x")
+            append_linker_flags("-Wl,--warn-shared-textrel") #  Warn if the linker adds a DT_TEXTREL to a shared object.
+            append_linker_flags("-Wl,--as-needed")
+            append_linker_flags("-Wl,--version-script=${src_dir}/exports_so.txt") # Use exports_so.txt as version script to create versioned symbols for ELF libraries
+            if(NOT ${STUBS_LIBRARY})
+                append_linker_flags_library("-pthread") # link in pthread library
+                append_linker_flags_library("-ldl") # link in libdl (dynamic loader library)
+            endif()
+            if(${STATS_GATHERING})
+                append_linker_flags_library("-Wl,-lstdc++") # link in standard c++ library (stats-gathering needs it)
+            endif()
+        endif()
+    #########################
+    # Unix based linker flags
+    else()
+        # For now, always include --version-script flag on Unix systems.
+        append_linker_flags("-Wl,--version-script=${src_dir}/exports_so.txt") # Use exports_so.txt as version script to create versioned symbols for ELF libraries
+        if(${USE_PREDEFINED_LINKER_FLAGS})
+            append_linker_flags("-Wl,-z,noexecstack") #  Marks the object as not requiring executable stack.
+            append_linker_flags("-Wl,--as-needed")    #  Only adds library dependencies as they are needed. (if libiomp5 actually uses a function from the library, then add it)
+            if(NOT ${STUBS_LIBRARY})
+                append_linker_flags("-Wl,--warn-shared-textrel") #  Warn if the linker adds a DT_TEXTREL to a shared object.
+                append_linker_flags("-Wl,-fini=__kmp_internal_end_fini") # When creating an ELF executable or shared object, call NAME when the 
+                                                                         # executable or shared object is unloaded, by setting DT_FINI to the 
+                                                                         # address of the function.  By default, the linker uses "_fini" as the function to call.
+                append_linker_flags_library("-pthread") # link pthread library
+                if(NOT ${FREEBSD})
+                    append_linker_flags_library("-Wl,-ldl") # link in libdl (dynamic loader library)
+                endif()
+            endif()
+        endif() # if(${USE_PREDEFINED_LINKER_FLAGS})
+    endif() # if(${OPERATING_SYSTEM}) ...
+
+    set(${input_ld_flags}      "${${input_ld_flags}}"      "${local_ld_flags}"      "${USER_LD_FLAGS}"     PARENT_SCOPE)
+    set(${input_ld_flags_libs} "${${input_ld_flags_libs}}" "${local_ld_flags_libs}" "${USER_LD_LIB_FLAGS}" PARENT_SCOPE)
+endfunction()
+
+#########################################################
+# Archiver Flags
+function(append_archiver_flags_common input_ar_flags)
+    set(local_ar_flags)
+    set(${input_ar_flags} "${${input_ar_flags}}" "${local_ar_flags}" PARENT_SCOPE)
+endfunction()
+
diff --git a/openmp/runtime/cmake/Definitions.cmake b/openmp/runtime/cmake/Definitions.cmake
new file mode 100644
index 0000000..0d12d48
--- /dev/null
+++ b/openmp/runtime/cmake/Definitions.cmake
@@ -0,0 +1,131 @@
+#
+#//===----------------------------------------------------------------------===//
+#//
+#//                     The LLVM Compiler Infrastructure
+#//
+#// This file is dual licensed under the MIT and the University of Illinois Open
+#// Source Licenses. See LICENSE.txt for details.
+#//
+#//===----------------------------------------------------------------------===//
+#
+
+# void append_definitions(string new_flag);
+# - appends new_flag to cpp_flags list
+macro(append_definitions new_flag)
+    list(APPEND local_cpp_flags "${new_flag}")
+endmacro()
+
+function(append_cpp_flags input_cpp_flags)
+    set(local_cpp_flags)
+
+    append_definitions("-D USE_ITT_BUILD")
+    append_definitions("-D KMP_ARCH_STR=\"\\\\\"${legal_arch}\\\\\"\"")
+    append_definitions("-D BUILD_I8")
+    append_definitions("-D KMP_LIBRARY_FILE=\\\\\"${lib_file}\\\\\"") # yes... you need 5 backslashes...
+    append_definitions("-D KMP_VERSION_MAJOR=${version}")
+    append_definitions("-D CACHE_LINE=64")
+    append_definitions("-D KMP_ADJUST_BLOCKTIME=1")
+    append_definitions("-D BUILD_PARALLEL_ORDERED")
+    append_definitions("-D KMP_ASM_INTRINS")
+    if(${USE_ITT_NOTIFY})
+        append_definitions("-D USE_ITT_NOTIFY=1")
+    else()
+        append_definitions("-D USE_ITT_NOTIFY=0")
+        append_definitions("-D INTEL_NO_ITTNOTIFY_API")
+    endif()
+    append_definitions("-D INTEL_ITTNOTIFY_PREFIX=__kmp_itt_")
+
+    #####################
+    # Windows definitions
+    if(${WINDOWS})
+        append_definitions("-D _CRT_SECURE_NO_WARNINGS")
+        append_definitions("-D _CRT_SECURE_NO_DEPRECATE")
+        append_definitions("-D _WINDOWS")
+        append_definitions("-D _WINNT")
+        append_definitions("-D _WIN32_WINNT=0x0501")
+        append_definitions("-D KMP_WIN_CDECL")
+        append_definitions("-D _USRDLL")
+        if(${DEBUG_BUILD})
+            append_definitions("-D _ITERATOR_DEBUG_LEVEL=0")
+        endif()
+    else() # Other than windows... (Unix based systems, Intel(R) Many Integrated Core Architecture (Intel(R) MIC Architecture), and Mac)
+        append_definitions("-D _GNU_SOURCE")
+        append_definitions("-D _REENTRANT")
+        append_definitions("-D BUILD_TV")
+        append_definitions("-D USE_CBLKDATA")
+        if(NOT "${version}" STREQUAL "4")
+            append_definitions("-D KMP_GOMP_COMPAT")
+        endif()
+    endif()
+
+    #######################################
+    # Intel(R) MIC Architecture definitions
+    if(${MIC})
+        append_definitions("-D KMP_TDATA_GTID")
+    else() # Other than Intel(R) MIC Architecture...
+        append_definitions("-D USE_LOAD_BALANCE")
+    endif()
+
+    ##################
+    # Unix definitions
+    if(${LINUX})
+        append_definitions("-D KMP_TDATA_GTID")
+    endif()
+
+    ##################################
+    # Other conditional definitions
+    append_definitions("-D KMP_USE_ASSERT")
+    append_definitions("-D GUIDEDLL_EXPORTS") 
+    if(${STUBS_LIBRARY}) 
+        append_definitions("-D KMP_STUB") 
+    endif()
+    if(${DEBUG_BUILD} OR ${RELWITHDEBINFO_BUILD}) 
+        append_definitions("-D KMP_DEBUG") 
+    endif()
+    if(${DEBUG_BUILD})
+        append_definitions("-D _DEBUG")
+        append_definitions("-D BUILD_DEBUG")
+    endif()
+    if(${STATS_GATHERING})
+        append_definitions("-D KMP_STATS_ENABLED=1")
+    else()
+        append_definitions("-D KMP_STATS_ENABLED=0")
+    endif()
+
+    # OpenMP version flags
+    set(have_omp_50 0)
+    set(have_omp_41 0)
+    set(have_omp_40 0)
+    set(have_omp_30 0)
+    if(${omp_version} EQUAL 50 OR ${omp_version} GREATER 50)
+        set(have_omp_50 1)
+    endif()
+    if(${omp_version} EQUAL 41 OR ${omp_version} GREATER 41)
+        set(have_omp_41 1)
+    endif()
+    if(${omp_version} EQUAL 40 OR ${omp_version} GREATER 40)
+        set(have_omp_40 1)
+    endif()
+    if(${omp_version} EQUAL 30 OR ${omp_version} GREATER 30)
+        set(have_omp_30 1)
+    endif()
+    append_definitions("-D OMP_50_ENABLED=${have_omp_50}")
+    append_definitions("-D OMP_41_ENABLED=${have_omp_41}")
+    append_definitions("-D OMP_40_ENABLED=${have_omp_40}")
+    append_definitions("-D OMP_30_ENABLED=${have_omp_30}")
+
+    # Architectural definitions
+    if(${INTEL64} OR ${IA32})
+        if(${USE_ADAPTIVE_LOCKS})
+            append_definitions("-D KMP_USE_ADAPTIVE_LOCKS=1")
+        else()
+            append_definitions("-D KMP_USE_ADAPTIVE_LOCKS=0")
+        endif()
+        append_definitions("-D KMP_DEBUG_ADAPTIVE_LOCKS=0")
+    else()
+        append_definitions("-D KMP_USE_ADAPTIVE_LOCKS=0")
+        append_definitions("-D KMP_DEBUG_ADAPTIVE_LOCKS=0")
+    endif()
+    set(${input_cpp_flags} "${${input_cpp_flags}}" "${local_cpp_flags}" "${USER_CPP_FLAGS}" "$ENV{CPPFLAGS}" PARENT_SCOPE)
+endfunction()
+
diff --git a/openmp/runtime/cmake/GNU/AsmFlags.cmake b/openmp/runtime/cmake/GNU/AsmFlags.cmake
new file mode 100644
index 0000000..91fccb0
--- /dev/null
+++ b/openmp/runtime/cmake/GNU/AsmFlags.cmake
@@ -0,0 +1,16 @@
+# This file holds GNU (gcc/g++) specific compiler dependent flags
+# The flag types are:
+#   1) Assembly flags
+
+#########################################################
+# Assembly flags
+function(append_assembler_specific_asm_flags input_asm_flags)
+    set(local_asm_flags)
+    append_asm_flags("-x assembler-with-cpp") # Assembly file that needs to be preprocessed
+    if(${IA32})
+        append_asm_flags("-m32") # Generate 32 bit IA-32 architecture code 
+        append_asm_flags("-msse2") # Allow use of Streaming SIMD Instructions
+    endif()
+    set(${input_asm_flags} ${${input_asm_flags}} "${local_asm_flags}" PARENT_SCOPE)
+endfunction()
+
diff --git a/openmp/runtime/cmake/GNU/CFlags.cmake b/openmp/runtime/cmake/GNU/CFlags.cmake
new file mode 100644
index 0000000..88654cc
--- /dev/null
+++ b/openmp/runtime/cmake/GNU/CFlags.cmake
@@ -0,0 +1,45 @@
+# This file holds GNU (gcc/g++) specific compiler dependent flags
+# The flag types are:
+#   2) C/C++ Compiler flags
+#   4) Linker flags
+unset(COMPILER_SUPPORTS_QUAD_PRECISION CACHE)
+set(COMPILER_SUPPORTS_QUAD_PRECISION true CACHE BOOL "Does the compiler support a 128-bit floating point type?")
+set(COMPILER_QUAD_TYPE __float128)
+
+#########################################################
+# C/C++ Compiler flags
+function(append_compiler_specific_c_and_cxx_flags input_c_flags input_cxx_flags)
+    set(local_c_flags)
+    set(local_cxx_flags)
+    append_c_and_cxx_flags("-std=c++0x") # Enables support for many C++11 (formerly known as C++0x) features. The following are the most recently added features:
+    append_c_and_cxx_flags("-fno-exceptions") # Exception handling table generation is disabled.
+    append_c_and_cxx_flags("-x c++") # Compile C files as C++ files
+    if(${IA32})
+        append_c_and_cxx_flags("-m32") # Generate 32 bit IA-32 architecture code
+        append_c_and_cxx_flags("-msse2") # Allow use of Streaming SIMD Instructions
+    elseif(${ARM})
+        append_c_and_cxx_flags("-marm") # Target the ARM architecture
+    endif()
+    set(${input_c_flags} ${${input_c_flags}} "${local_c_flags}" PARENT_SCOPE)
+    set(${input_cxx_flags} ${${input_cxx_flags}} "${local_cxx_flags}" PARENT_SCOPE)
+endfunction()
+
+#########################################################
+# Linker flags
+function(append_compiler_specific_linker_flags input_ld_flags input_ld_flags_libs)
+    set(local_ld_flags)
+    set(local_ld_flags_libs)
+    if(${WINDOWS})
+    elseif(${MAC})
+    elseif(${MIC})
+    else()
+        append_linker_flags("-static-libgcc") # Causes libgcc to be linked in statically
+    endif()
+    if(${IA32})
+        append_linker_flags("-m32")
+        append_linker_flags("-msse2")
+    endif()
+    set(${input_ld_flags}      ${${input_ld_flags}}      "${local_ld_flags}"       PARENT_SCOPE)
+    set(${input_ld_flags_libs} ${${input_ld_flags_libs}} "${local_ld_flags_libs}"  PARENT_SCOPE)
+endfunction()
+
diff --git a/openmp/runtime/cmake/GNU/FortranFlags.cmake b/openmp/runtime/cmake/GNU/FortranFlags.cmake
new file mode 100644
index 0000000..2a479b2
--- /dev/null
+++ b/openmp/runtime/cmake/GNU/FortranFlags.cmake
@@ -0,0 +1,14 @@
+# This file holds GNU (gcc/g++) specific compiler dependent flags
+# The flag types are:
+#   1) Fortran Compiler flags
+
+#########################################################
+# Fortran Compiler flags (for creating .mod files)
+function(append_fortran_compiler_specific_fort_flags input_fort_flags)
+    set(local_fort_flags)
+    if(${IA32})
+        append_fort_flags("-m32")
+        append_fort_flags("-msse2")
+    endif()
+    set(${input_fort_flags} ${${input_fort_flags}} "${local_fort_flags}" PARENT_SCOPE)
+endfunction()
diff --git a/openmp/runtime/cmake/HelperFunctions.cmake b/openmp/runtime/cmake/HelperFunctions.cmake
new file mode 100644
index 0000000..9190248
--- /dev/null
+++ b/openmp/runtime/cmake/HelperFunctions.cmake
@@ -0,0 +1,254 @@
+#
+#//===----------------------------------------------------------------------===//
+#//
+#//                     The LLVM Compiler Infrastructure
+#//
+#// This file is dual licensed under the MIT and the University of Illinois Open
+#// Source Licenses. See LICENSE.txt for details.
+#//
+#//===----------------------------------------------------------------------===//
+#
+
+####################################### FUNCTIONS/MACROS ###########################################
+# It should be noted that in cmake, functions can only be used on a single line with the return value
+# stored in a parameter you send to the function.  There isn't a true return value.  So technically, 
+# all functions would have a C/C++ prototype of:
+# void function_name(parameter1, parameter2, ...);
+#  
+# If you want a return value, you have to use a parameter so the function prototype would be:
+# void function_name(input_parameter1, input_parameter2, ...,  return_value)
+# ##################
+
+# void say(string message_to_user);
+# - prints out message_to_user
+macro(say message_to_user)
+    message("${message_to_user}")
+endmacro()
+
+# void warning_say(string message_to_user);
+# - prints out message_to_user with a warning
+macro(warning_say message_to_user)
+    message(WARNING "${message_to_user}")
+endmacro()
+
+# void error_say(string message_to_user);
+# - prints out message_to_user with an error and exits cmake
+macro(error_say message_to_user)
+    message(FATAL_ERROR "${message_to_user}")
+endmacro()
+
+# void debug_say(string message_to_developer);
+# - prints out message when GLOBAL_DEBUG == 1 (for debugging cmake build)
+macro(debug_say message_to_developer)
+    if(${GLOBAL_DEBUG} STREQUAL "1")
+        say("DEBUG: ${message_to_developer}")
+    endif()
+endmacro()
+
+# void debug_say_var(variable var);
+# - prints the variable name and its value (for debugging cmake build)
+macro(debug_say_var var)
+    if(${GLOBAL_DEBUG} STREQUAL "1")
+        say("DEBUG: Variable: ${var} = ${${var}} ")
+    endif()
+endmacro()
+
+# void set_legal_arch(string* return_arch_string);
+# - returns (through return_arch_string) the formal architecture 
+#   string or warns user of unknown architecture
+function(set_legal_arch return_arch_string)
+    if(${IA32}) 
+        set(${return_arch_string} "IA-32" PARENT_SCOPE)
+    elseif(${INTEL64})
+        set(${return_arch_string} "Intel(R) 64" PARENT_SCOPE)
+    elseif(${MIC})
+        set(${return_arch_string} "Intel(R) Many Integrated Core Architecture" PARENT_SCOPE)
+    elseif(${arch} STREQUAL "l1")
+        set(${return_arch_string} "L1OM" PARENT_SCOPE)
+    elseif(${ARM})
+        set(${return_arch_string} "ARM" PARENT_SCOPE)
+    else()
+        warning_say("set_legal_arch(): Warning: Unknown architecture...")
+    endif()
+endfunction()
+
+# void check_variable(string var, string var_name, list<string>values_list);
+# - runs through values_list checking if ${var} == values_list[i] for any i.
+# - if the var is found, then just print it out
+# - if the var is not found, then warn user
+function(check_variable var values_list)
+    set(valid_flag 0)
+    foreach(value IN LISTS values_list)
+        if("${${var}}" STREQUAL "${value}")
+            set(valid_flag 1)
+            set(the_value "${value}")
+        endif()
+    endforeach()
+    if(${valid_flag} EQUAL 0)
+        error_say("check_variable(): ${var} = ${${var}} is unknown")
+    endif()
+endfunction()
+
+# void _export_lib_dir(string export_dir, string platform, string suffix, string* return_value);
+# - basically a special case for mac platforms where it adds '.thin' to the output lib directory
+function(_export_lib_dir pltfrm return_value)
+    if(${MAC})
+        set(${return_value} "${export_dir}/${pltfrm}${suffix}/lib.thin" PARENT_SCOPE)
+    else()
+        set(${return_value} "${export_dir}/${pltfrm}${suffix}/lib" PARENT_SCOPE)
+    endif()
+endfunction()
+
+# void _export_lib_fat_dir(string export_dir, string platform, string suffix, string* return_value);
+# - another mac specialty case for fat libraries.
+# - this sets export_lib_fat_dir in the MAIN part of CMakeLists.txt
+function(_export_lib_fat_dir pltfrm return_value)
+    set(${return_value} "${export_dir}/${pltfrm}${suffix}/lib" PARENT_SCOPE)
+endfunction()
+
+# void get_build_number(string src_dir, string* return_build_number);
+# - grab the eight digit build number (or 00000000) from kmp_version.c
+function(get_build_number src_dir return_build_number)
+    # sets file_lines_list to a list of all lines in kmp_version.c
+    file(STRINGS "${src_dir}/src/kmp_version.c" file_lines_list)
+
+    # runs through each line in kmp_version.c
+    foreach(line IN LISTS file_lines_list)
+        # if the line begins with "#define KMP_VERSION_BUILD" then we take not of the build number
+        string(REGEX MATCH "^[ \t]*#define[ \t]+KMP_VERSION_BUILD" valid "${line}")
+        if(NOT "${valid}" STREQUAL "") # if we matched "#define KMP_VERSION_BUILD", then grab the build number
+            string(REGEX REPLACE "^[ \t]*#define[ \t]+KMP_VERSION_BUILD[ \t]+([0-9]+)" "\\1"
+                   build_number "${line}"
+            )
+        endif()
+    endforeach()
+    set(${return_build_number} "${build_number}" PARENT_SCOPE) # return build number
+endfunction()
+
+# void set_legal_type(string* return_legal_type);
+# - set the legal type name Performance/Profiling/Stub
+function(set_legal_type return_legal_type)
+    if(${NORMAL_LIBRARY})
+        set(${return_legal_type} "Performance" PARENT_SCOPE)
+    elseif(${PROFILE_LIBRARY})
+        set(${return_legal_type} "Profiling" PARENT_SCOPE)
+    elseif(${STUBS_LIBRARY})
+        set(${return_legal_type} "Stub" PARENT_SCOPE)
+    endif()
+endfunction()
+
+# void set_mac_os_new(bool* return_mac_os_new);
+# - sets the return_mac_os_new variable to true or false based on macosx version
+# - no real "cmakey" way to do this.  Have to call execute_process()
+function(set_mac_os_new return_mac_os_new)
+    execute_process(COMMAND "sw_vers" "-productVersion" OUTPUT_VARIABLE mac_osx_version)
+    if("${mac_osx_version}" VERSION_GREATER "10.6")
+        set(${return_mac_os_new} TRUE PARENT_SCOPE)
+    else()
+        set(${return_mac_os_new} FALSE PARENT_SCOPE)
+    endif()
+endfunction()
+
+# void add_prefix(string prefix, list<string>* list_of_items);
+# - returns list_of_items with prefix prepended to all items
+# - original list is modified
+function(add_prefix prefix list_of_items)
+    set(local_list "")
+    foreach(item IN LISTS "${list_of_items}")
+        if(NOT "${item}" STREQUAL "")
+            list(APPEND local_list "${prefix}${item}")
+        endif()
+    endforeach()
+    set(${list_of_items} "${local_list}" PARENT_SCOPE)
+endfunction()
+
+# void add_suffix(string suffix, list<string>* list_of_items);
+# - returns list_of_items with suffix appended to all items
+# - original list is modified
+function(add_suffix suffix list_of_items)
+    set(local_list "")
+    foreach(item IN LISTS "${list_of_items}")
+        if(NOT "${item}" STREQUAL "")
+            list(APPEND local_list "${item}${suffix}")
+        endif()
+    endforeach()
+    set(${list_of_items} "${local_list}" PARENT_SCOPE)
+endfunction()
+
+# void strip_suffix(list<string> list_of_items, list<string>* return_list);
+# - returns a new list with suffix stripped (i.e., foo.c => foo)
+# - list_of_items is not modified, return_list is modified
+function(strip_suffix list_of_items return_list)
+    set(local_list "")
+    foreach(item IN LISTS "${list_of_items}")
+        if(NOT "${item}" STREQUAL "")
+            get_filename_component(filename "${item}" NAME_WE)
+            list(APPEND local_list "${filename}")
+        endif()
+    endforeach()
+    set(${return_list} "${local_list}" PARENT_SCOPE)
+endfunction()
+
+# void list_to_string(list<string> list_of_things, string* return_string);
+# - converts a list to a space separated string
+function(list_to_string list_of_things return_string)
+    string(REPLACE ";" " " output_variable "${list_of_things}")
+    set(${return_string} "${output_variable}" PARENT_SCOPE)
+endfunction()
+
+# void string_to_list(string str, list<string>* return_list);
+# - converts a string to a semicolon separated list
+# - what it really does is just string_replace all running whitespace to a semicolon
+# - in cmake, a list is strings separated by semicolons: i.e., list of four items, list = "item1;item2;item3;item4"
+function(string_to_list str return_list)
+    set(outstr)
+    string(REGEX REPLACE "[ \t]+" ";" outstr "${str}")
+    set(${return_list} "${outstr}" PARENT_SCOPE) 
+endfunction()
+
+# void get_date(string* return_date);
+# - returns the current date "yyyy-mm-dd hh:mm:ss UTC"
+# - this function alone causes the need for CMake v2.8.11 (TIMESTAMP)
+#function(get_date return_date)
+#    string(TIMESTAMP local_date "%Y-%m-%d %H:%M:%S UTC" UTC)
+#    set(${return_date} ${local_date} PARENT_SCOPE)
+#endfunction()
+
+# void find_a_program(string program_name, list<string> extra_paths, bool fail_on_not_found, string return_variable_name);
+# - returns the full path of a program_name
+# - first looks in the list of extra_paths
+# - if not found in extra_paths, then look through system path
+# - errors out if fail_on_not_found == true and cmake could not find program_name.
+function(find_a_program program_name extra_paths fail_on_not_found return_variable_name)
+    # first try to find the program in the extra_paths
+    find_program(${return_variable_name} "${program_name}" PATHS "${extra_paths}" DOC "Path to ${program_name}" NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_PATH NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
+    if("${${return_variable_name}}" MATCHES NOTFOUND)
+        # if no extra_paths, or couldn't find it, then look in system $PATH
+        find_program(${return_variable_name} "${program_name}" DOC "Path to ${program_name}")
+        if("${${return_variable_name}}" MATCHES NOTFOUND AND ${fail_on_not_found})
+            error_say("Error: Could not find program: ${program_name}")
+        endif()
+    endif()
+
+    if(NOT "${${return_variable_name}}" MATCHES NOTFOUND)
+        say("-- Found ${program_name}: ${${return_variable_name}}")
+    endif()
+
+    set(${return_variable_name} ${${return_variable_name}} PARENT_SCOPE)
+endfunction()
+
+# WINDOWS SPECIFIC 
+# void replace_md_with_mt(string flags_var)
+# - This macro replaces the /MD compiler flags (Windows specific) with /MT compiler flags
+# - This does nothing if no /MD flags were replaced.
+macro(replace_md_with_mt flags_var)
+    set(flags_var_name  ${flags_var}) # i.e., CMAKE_C_FLAGS_RELEASE
+    set(flags_var_value ${${flags_var}}) # i.e., "/MD /O2 ..."
+    string(REPLACE /MD /MT temp_out "${flags_var_value}")
+    string(COMPARE NOTEQUAL "${temp_out}" "${flags_var_value}" something_was_replaced)
+    if("${something_was_replaced}")
+        unset(${flags_var_name} CACHE)
+        set(${flags_var_name} ${temp_out} CACHE STRING "Replaced /MD with /MT compiler flags")
+    endif()
+endmacro()
+
diff --git a/openmp/runtime/cmake/Intel/AsmFlags.cmake b/openmp/runtime/cmake/Intel/AsmFlags.cmake
new file mode 100644
index 0000000..59d22d9
--- /dev/null
+++ b/openmp/runtime/cmake/Intel/AsmFlags.cmake
@@ -0,0 +1,31 @@
+# This file holds Intel(R) C Compiler / Intel(R) C++ Compiler / Intel(R) Fortran Compiler (icc/icpc/icl.exe/ifort) dependent flags
+# The flag types are:
+#   1) Assembly flags
+
+#########################################################
+# Assembly flags
+function(append_assembler_specific_asm_flags input_asm_flags)
+    set(local_asm_flags)
+    append_asm_flags("-x assembler-with-cpp") # Assembly file that needs to be preprocessed
+    if(${IA32})
+        append_asm_flags("-safeseh") # Registers exception handlers for safe exception handling.
+        append_asm_flags("-coff") # Generates common object file format (COFF) type of object module. 
+                                  # Generally required for Win32 assembly language development.
+        append_asm_flags("-D _M_IA32")
+    elseif(${INTEL64})
+        append_asm_flags("-D _M_AMD64")
+    endif()
+    if(${MIC})
+        append_asm_flags("-mmic") # Build Intel(R) MIC Architecture native code
+    endif()
+    if(${WINDOWS})
+        # CMake prefers the /MD flags when compiling Windows sources, but libiomp5 needs to use /MT instead
+        # So we replace these /MD instances with /MT within the CMAKE_*_FLAGS variables and put that out to the CACHE.
+        # replace_md_with_mt() is in HelperFunctions.cmake
+        replace_md_with_mt(CMAKE_ASM_MASM_FLAGS)
+        replace_md_with_mt(CMAKE_ASM_MASM_FLAGS_RELEASE)
+        replace_md_with_mt(CMAKE_ASM_MASM_FLAGS_RELWITHDEBINFO)
+        replace_md_with_mt(CMAKE_ASM_MASM_FLAGS_DEBUG)
+    endif()
+    set(${input_asm_flags} ${${input_asm_flags}} "${local_asm_flags}" PARENT_SCOPE)
+endfunction()
diff --git a/openmp/runtime/cmake/Intel/CFlags.cmake b/openmp/runtime/cmake/Intel/CFlags.cmake
new file mode 100644
index 0000000..2122e29
--- /dev/null
+++ b/openmp/runtime/cmake/Intel/CFlags.cmake
@@ -0,0 +1,148 @@
+# This file holds Intel(R) C Compiler / Intel(R) C++ Compiler / Intel(R) Fortran Compiler (icc/icpc/icl.exe/ifort) dependent flags
+# The flag types are:
+#   2) C/C++ Compiler flags
+#   4) Linker flags
+
+# icc has a 128-bit floating point type called _Quad.  Always compile with 128-bit floating point if it exists.
+unset(COMPILER_SUPPORTS_QUAD_PRECISION CACHE)
+set(COMPILER_SUPPORTS_QUAD_PRECISION true CACHE BOOL "Does the compiler support a 128-bit floating point type?")
+set(COMPILER_QUAD_TYPE _Quad)
+
+#########################################################
+# icc C/C++ Compiler flags
+function(append_compiler_specific_c_and_cxx_flags input_c_flags input_cxx_flags)
+    set(local_c_flags)
+    set(local_cxx_flags)
+    if(${WINDOWS})
+        
+        append_c_flags("-TP") # Tells the compiler to process a file as a C++ source file.
+        append_cxx_flags("-EHsc") # Enable C++ exception handling.
+        append_c_and_cxx_flags("-nologo") # Turn off tool banner.
+        append_c_and_cxx_flags("-W3") # Enables diagnostics for remarks, warnings, and errors. 
+                                      # Additional warnings are also enabled above level 2 warnings.
+        append_c_and_cxx_flags("-WX") # Change all Warnings to Errors
+        append_c_and_cxx_flags("-GS") # Lets you control the threshold at which the stack checking routine is called or not called.
+        append_c_and_cxx_flags("-Qoption,cpp,--extended_float_types") # Enabled _Quad type.
+        if(${IA32})
+           append_c_and_cxx_flags("-arch:ia32") # Tells the compiler which features it may target (ia32)
+           append_c_and_cxx_flags("-Oy-") # equivalent to -fno-omit-frame-pointer
+        endif()
+        append_c_and_cxx_flags("-Qlong_double") # enable long double
+        append_c_and_cxx_flags("-Qdiag-disable:177") # Disable warning: "... declared but never referenced"
+        if(${IA32})
+            append_c_and_cxx_flags("-Qsafeseh") # Registers exception handlers for safe exception handling.
+        endif()
+        if(${RELEASE_BUILD} OR ${RELWITHDEBINFO_BUILD})
+            append_c_and_cxx_flags("-Qinline-min-size=1") # Specifies the upper limit for the size of what the inliner considers to be a small routine.
+        else()
+            append_c_and_cxx_flags("-Od") # Disables all optimizations.
+            append_c_and_cxx_flags("-RTC1") # Enables run-time checks of the stack frame, and enables run-time checks for unintialized variables.
+            append_c_and_cxx_flags("-MTd") # Tells the linker to search for unresolved references in a multithreaded, static run-time library.
+        endif()
+    else()
+        append_c_and_cxx_flags("-Wsign-compare") # warn on sign comparisons
+        append_c_and_cxx_flags("-Werror") # Changes all warnings to errors.
+        append_c_and_cxx_flags("-Qoption,cpp,--extended_float_types") # Enabled _Quad type.
+        append_c_and_cxx_flags("-fno-exceptions") # Exception handling table generation is disabled.
+        append_c_and_cxx_flags("-x c++") # Compile C files as C++ files
+        if(${MIC})
+            append_c_and_cxx_flags("-mmic") # Build Intel(R) MIC Architecture native code
+            append_c_and_cxx_flags("-ftls-model=initial-exec") # Changes the thread local storage (TLS) model. Generates a restrictive, optimized TLS code. 
+                                                               # To use this setting, the thread-local variables accessed must be defined in one of the 
+                                                               # modules available to the program.
+            append_c_and_cxx_flags("-opt-streaming-stores never") # Disables generation of streaming stores for optimization.
+            append_c_and_cxx_flags("-sox") # Tells the compiler to save the compilation options and version number 
+                                           # in the executable file. It also lets you choose whether to include 
+                                           # lists of certain functions.
+        elseif(${LINUX})
+            append_c_and_cxx_flags("-Werror") # Changes all warnings to errors.
+            append_c_and_cxx_flags("-sox") 
+            if(${IA32})
+                append_c_and_cxx_flags("-falign-stack=maintain-16-byte") # Tells the compiler the stack alignment to use on entry to routines.
+                append_c_and_cxx_flags("-mia32")  # Tells the compiler which features it may target (ia32)
+            endif()
+        endif()
+    endif()
+    # CMake prefers the /MD flags when compiling Windows sources, but libiomp5 needs to use /MT instead
+    # So we replace these /MD instances with /MT within the CMAKE_*_FLAGS variables and put that out to the CACHE.
+    # replace_md_with_mt() is in HelperFunctions.cmake
+    if(${WINDOWS})
+        replace_md_with_mt(CMAKE_C_FLAGS)
+        replace_md_with_mt(CMAKE_C_FLAGS_RELEASE)
+        replace_md_with_mt(CMAKE_C_FLAGS_RELWITHDEBINFO)
+        replace_md_with_mt(CMAKE_C_FLAGS_DEBUG)
+        replace_md_with_mt(CMAKE_CXX_FLAGS)
+        replace_md_with_mt(CMAKE_CXX_FLAGS_RELEASE)
+        replace_md_with_mt(CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+        replace_md_with_mt(CMAKE_CXX_FLAGS_DEBUG)
+    endif()
+    set(${input_c_flags}   ${${input_c_flags}}   "${local_c_flags}" PARENT_SCOPE)
+    set(${input_cxx_flags} ${${input_cxx_flags}} "${local_cxx_flags}" PARENT_SCOPE)
+endfunction()
+
+#########################################################
+# icc Linker flags
+function(append_compiler_specific_linker_flags input_ld_flags input_ld_flags_libs)
+    set(local_ld_flags)
+    set(local_ld_flags_libs)
+    if(${WINDOWS})
+        # Have icc use link.exe directly when Windows
+        set(CMAKE_C_CREATE_SHARED_LIBRARY "link.exe /out:<TARGET> <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES>" PARENT_SCOPE)
+        set(CMAKE_SHARED_LINKER_FLAGS "$ENV{LDFLAGS}" CACHE STRING "Linker Flags" FORCE)
+        append_linker_flags("-nologo") # Turn off tool banner.
+        append_linker_flags("-dll") 
+        append_linker_flags("-WX:NO")
+        append_linker_flags("-incremental:no")
+        append_linker_flags("-version:${version}.0")
+        append_linker_flags("-NXCompat")
+        append_linker_flags("-DynamicBase") # This option modifies the header of an executable to indicate 
+                                               # whether the application should be randomly rebased at load time.
+        if(${IA32})
+            append_linker_flags("-machine:i386")
+            append_linker_flags("-safeseh")
+        elseif(${INTEL64})
+            append_linker_flags("-machine:amd64")
+        endif()
+        if(${DEBUG_BUILD} OR ${RELWITHDEBINFO_BUILD})
+            if(NOT "${pdb_file}" STREQUAL "")
+                append_linker_flags("-debug")
+                append_linker_flags("-pdb:${pdb_file}")
+            endif()
+        else()
+            if(NOT "${pdb_file}" STREQUAL "")
+                append_linker_flags("-debug")
+                append_linker_flags("-pdb:${pdb_file}")
+                append_linker_flags("-pdbstripped:${pdb_file}.stripped")
+            endif()
+        endif()
+        if(NOT "${imp_file}" STREQUAL "")
+            append_linker_flags("-implib:${lib_file}${lib}")
+        endif()
+        if(NOT "${def_file}" STREQUAL "")
+            append_linker_flags("-def:${def_file}")
+        endif()
+    elseif(${MAC})
+        append_linker_flags("-no-intel-extensions")
+        if(NOT ${STUBS_LIBRARY})
+            append_linker_flags_library("-pthread") # link in pthread library
+            append_linker_flags_library("-ldl") # link in libdl (dynamic loader library)
+        endif()
+        if(${STATS_GATHERING})
+            append_linker_flags_library("-Wl,-lstdc++") # link in standard c++ library (stats-gathering needs it)
+        endif()
+    elseif(${MIC})
+        append_linker_flags("-mmic") # enable MIC linking
+        append_linker_flags("-static-intel") # Causes Intel-provided libraries to be linked in statically. 
+        append_linker_flags("-no-intel-extensions") # Enables or disables all Intel C and Intel C++ language extensions.
+    else()
+        append_linker_flags("-static-intel") # Causes Intel-provided libraries to be linked in statically.
+        append_linker_flags("-Werror") # Warnings become errors
+        if(${IA32})
+            append_linker_flags_library("-lirc_pic") # link in libirc_pic
+        endif()
+    endif()
+
+    set(${input_ld_flags}      ${${input_ld_flags}}      "${local_ld_flags}"       PARENT_SCOPE)
+    set(${input_ld_flags_libs} ${${input_ld_flags_libs}} "${local_ld_flags_libs}"  PARENT_SCOPE)
+endfunction()
+
diff --git a/openmp/runtime/cmake/Intel/FortranFlags.cmake b/openmp/runtime/cmake/Intel/FortranFlags.cmake
new file mode 100644
index 0000000..9279a88
--- /dev/null
+++ b/openmp/runtime/cmake/Intel/FortranFlags.cmake
@@ -0,0 +1,29 @@
+# This file holds Intel(R) C Compiler / Intel(R) C++ Compiler / Intel(R) Fortran Compiler (icc/icpc/icl.exe/ifort) dependent flags
+# The flag types are:
+#   1) Fortran Compiler flags
+
+#########################################################
+# icc Fortran Compiler flags (for creating .mod files)
+function(append_fortran_compiler_specific_fort_flags input_fort_flags)
+    set(local_fort_flags)
+    #set(CMAKE_Fortran_FLAGS      "$ENV{FFLAGS}"   CACHE STRING "Fortran flags"  FORCE)
+    #set(CMAKE_Fortran_FLAGS_RELEASE          ""   CACHE STRING "Fortran flags"  FORCE)
+    #set(CMAKE_Fortran_FLAGS_DEBUG            ""   CACHE STRING "Fortran flags"  FORCE)
+    #set(CMAKE_Fortran_FLAGS_RELWITHDEBINFO   ""   CACHE STRING "Fortran flags"  FORCE)
+    if(${WINDOWS})
+        append_fort_flags("-Qdiag-disable:177,5082")
+        append_fort_flags("-Qsox")
+        append_fort_flags("-nologo")
+        append_fort_flags("-GS")
+        append_fort_flags("-DynamicBase")
+        append_fort_flags("-Zi")
+    else()
+        if(${MIC})
+            append_fort_flags("-mmic")
+        endif()
+        if(NOT ${MAC})
+            append_fort_flags("-sox")
+        endif()
+    endif()
+    set(${input_fort_flags} ${${input_fort_flags}} "${local_fort_flags}" PARENT_SCOPE)
+endfunction()
diff --git a/openmp/runtime/cmake/MSVC/AsmFlags.cmake b/openmp/runtime/cmake/MSVC/AsmFlags.cmake
new file mode 100644
index 0000000..dcc8302
--- /dev/null
+++ b/openmp/runtime/cmake/MSVC/AsmFlags.cmake
@@ -0,0 +1,26 @@
+# This file holds Microsoft Visual Studio dependent flags
+# The flag types are:
+#   1) Assembly flags
+
+#########################################################
+# Assembly flags
+function(append_assembler_specific_asm_flags input_asm_flags)
+    set(local_asm_flags)
+    append_asm_flags("-nologo") # Turn off tool banner.
+    if(${IA32})
+        append_asm_flags("-safeseh") # Registers exception handlers for safe exception handling.
+        append_asm_flags("-coff") # Generates common object file format (COFF) type of object module. 
+                                  # Generally required for Win32 assembly language development.
+        append_asm_flags("-D _M_IA32")
+    elseif(${INTEL64})
+        append_asm_flags("-D _M_AMD64")
+    endif()
+    # CMake prefers the /MD flags when compiling Windows sources, but libiomp5 needs to use /MT instead
+    # So we replace these /MD instances with /MT within the CMAKE_*_FLAGS variables and put that out to the CACHE.
+    # replace_md_with_mt() is in HelperFunctions.cmake
+    replace_md_with_mt(CMAKE_ASM_MASM_FLAGS)
+    replace_md_with_mt(CMAKE_ASM_MASM_FLAGS_RELEASE)
+    replace_md_with_mt(CMAKE_ASM_MASM_FLAGS_RELWITHDEBINFO)
+    replace_md_with_mt(CMAKE_ASM_MASM_FLAGS_DEBUG)
+    set(${input_asm_flags} ${${input_asm_flags}} "${local_asm_flags}" PARENT_SCOPE)
+endfunction()
diff --git a/openmp/runtime/cmake/MSVC/CFlags.cmake b/openmp/runtime/cmake/MSVC/CFlags.cmake
new file mode 100644
index 0000000..b76147a
--- /dev/null
+++ b/openmp/runtime/cmake/MSVC/CFlags.cmake
@@ -0,0 +1,64 @@
+# This file holds Microsoft Visual Studio dependent flags
+# The flag types are:
+#   1) C/C++ Compiler flags
+#   2) Fortran Compiler flags
+
+#########################################################
+# Visual Studio C/C++ Compiler flags
+function(append_compiler_specific_c_and_cxx_flags input_c_flags input_cxx_flags)
+    set(local_c_flags)
+    set(local_cxx_flags)
+    append_c_flags("-TP") # Tells the compiler to process a file as a C++ source file.
+    append_cxx_flags("-EHsc") # Enable C++ exception handling.
+    append_c_and_cxx_flags("-W3") # Enables diagnostics for remarks, warnings, and errors. 
+                                  # Additional warnings are also enabled above level 2 warnings.
+    append_c_and_cxx_flags("-GS") # Lets you control the threshold at which the stack checking routine is called or not called.
+    if(${IA32})
+        append_c_and_cxx_flags("-arch:ia32") # Tells the compiler which features it may target (ia32)
+        append_c_and_cxx_flags("-Oy-") # equivalent to -fno-omit-frame-pointer
+    endif()
+    # CMake prefers the /MD flags when compiling Windows sources, but libiomp5 needs to use /MT instead
+    # So we replace these /MD instances with /MT within the CMAKE_*_FLAGS variables and put that out to the CACHE.
+    # replace_md_with_mt() is in HelperFunctions.cmake
+    replace_md_with_mt(CMAKE_C_FLAGS)
+    replace_md_with_mt(CMAKE_C_FLAGS_RELEASE)
+    replace_md_with_mt(CMAKE_C_FLAGS_RELWITHDEBINFO)
+    replace_md_with_mt(CMAKE_C_FLAGS_DEBUG)
+    replace_md_with_mt(CMAKE_CXX_FLAGS)
+    replace_md_with_mt(CMAKE_CXX_FLAGS_RELEASE)
+    replace_md_with_mt(CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+    replace_md_with_mt(CMAKE_CXX_FLAGS_DEBUG)
+    replace_md_with_mt(CMAKE_ASM_MASM_FLAGS)
+    replace_md_with_mt(CMAKE_ASM_MASM_FLAGS_RELEASE)
+    replace_md_with_mt(CMAKE_ASM_MASM_FLAGS_RELWITHDEBINFO)
+    replace_md_with_mt(CMAKE_ASM_MASM_FLAGS_DEBUG)
+    set(${input_c_flags}   ${${input_c_flags}}   "${local_c_flags}" PARENT_SCOPE)
+    set(${input_cxx_flags} ${${input_cxx_flags}} "${local_cxx_flags}" PARENT_SCOPE)
+endfunction()
+
+#########################################################
+# Visual Studio Linker flags
+function(append_compiler_specific_linker_flags input_ld_flags input_ld_flags_libs)
+    set(local_ld_flags)
+    set(local_ld_flags_libs)
+    append_linker_flags("-WX:NO")
+    append_linker_flags("-version:${version}.0")
+    append_linker_flags("-NXCompat")
+    append_linker_flags("-DynamicBase") # This option modifies the header of an executable to indicate 
+                                           # whether the application should be randomly rebased at load time.
+    if(${IA32})
+        append_linker_flags("-machine:i386")
+        append_linker_flags("-safeseh")
+    elseif(${INTEL64})
+        append_linker_flags("-machine:amd64")
+    endif()
+    if(NOT "${def_file}" STREQUAL "")
+        append_linker_flags("-def:${def_file}")
+    endif()
+    # Have Visual Studio use link.exe directly
+    #set(CMAKE_C_CREATE_SHARED_LIBRARY "link.exe /out:<TARGET> <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES>" PARENT_SCOPE)
+    #set(CMAKE_SHARED_LINKER_FLAGS "$ENV{LDLFAGS}" CACHE STRING "Linker Flags" FORCE)
+    set(${input_ld_flags}      ${${input_ld_flags}}      "${local_ld_flags}"       PARENT_SCOPE)
+    set(${input_ld_flags_libs} ${${input_ld_flags_libs}} "${local_ld_flags_libs}"  PARENT_SCOPE)
+endfunction()
+
diff --git a/openmp/runtime/cmake/MicroTests.cmake b/openmp/runtime/cmake/MicroTests.cmake
new file mode 100644
index 0000000..50beb59
--- /dev/null
+++ b/openmp/runtime/cmake/MicroTests.cmake
@@ -0,0 +1,277 @@
+######################################################
+# MICRO TESTS
+# The following micro-tests are small tests to perform on 
+# the library just created in ${build_dir}/, there are currently
+# five micro-tests: 
+# (1) test-touch 
+#    - Compile and run a small program using newly created libiomp5 library
+#    - Fails if test-touch.c does not compile or if test-touch.c does not run after compilation
+#    - Program dependencies: gcc or g++, grep, bourne shell
+#    - Available for all Linux,Mac,Windows builds.  Not availble on Intel(R) MIC Architecture builds.
+# (2) test-relo
+#    - Tests dynamic libraries for position-dependent code (can not have any position dependent code)
+#    - Fails if TEXTREL is in output of readelf -d libiomp5.so command
+#    - Program dependencies: readelf, grep, bourne shell
+#    - Available for Linux, Intel(R) MIC Architecture dynamic library builds. Not available otherwise.
+# (3) test-execstack 
+#    - Tests if stack is executable
+#    - Fails if stack is executable. Should only be readable and writable. Not exectuable.
+#    - Program dependencies: perl, readelf
+#    - Available for Linux dynamic library builds. Not available otherwise.
+# (4) test-instr (Intel(R) MIC Architecutre only) 
+#    - Tests Intel(R) MIC Architecture libraries for valid instruction set
+#    - Fails if finds invalid instruction for Intel(R) MIC Architecture (wasn't compiled with correct flags)
+#    - Program dependencies: perl, objdump 
+#    - Available for Intel(R) MIC Architecture builds. Not available otherwise.
+# (5) test-deps      
+#    - Tests newly created libiomp5 for library dependencies
+#    - Fails if sees a dependence not listed in td_exp variable below
+#    - Program dependencies: perl, (linux)readelf, (mac)otool[64], (windows)link.exe
+#    - Available for Linux,Mac,Windows, Intel(R) MIC Architecture dynamic builds and Windows static builds. Not available otherwise.
+#
+# All tests can be turned off by including -Dtests=off when calling cmake
+# An individual test can be turned off by issuing something like -Dtest_touch=off when calling cmake
+
+# test-touch
+if(NOT ${MIC} AND ${test_touch} AND ${tests})
+    if(${WINDOWS})
+        set(do_test_touch_mt TRUE)
+        if(${do_test_touch_mt})
+            set(test_touch_items ${test_touch_items} test-touch-md test-touch-mt)
+        else()
+            set(test_touch_items ${test_touch_items} test-touch-md)
+        endif()
+    else()
+        set(test_touch_items ${test_touch_items} test-touch-rt)
+    endif()
+    set(regular_test_touch_items "${test_touch_items}")
+    add_suffix("/.success"  regular_test_touch_items)
+    # test-touch : ${test_touch_items}/.success
+    set(ldeps "${regular_test_touch_items}")
+    add_custom_target( test-touch DEPENDS ${ldeps})
+
+    if(${WINDOWS})
+        # pick test-touch compiler
+        set(tt-c cl)
+        # test-touch compilation flags
+        list(APPEND tt-c-flags -nologo)
+        if(${RELEASE_BUILD} OR ${RELWITHDEBINFO_BUILD})
+            list(APPEND tt-c-flags-mt -MT)
+            list(APPEND tt-c-flags-md -MD)
+        else()
+            list(APPEND tt-c-flags-mt -MTd)
+            list(APPEND tt-c-flags-md -MDd)
+        endif()
+        list(APPEND tt-libs ${build_dir}/${imp_file})
+        list(APPEND tt-ld-flags -link -nodefaultlib:oldnames)
+        if(${IA32})
+            list(APPEND tt-ld-flags -safeseh)
+        endif()
+        list(APPEND tt-ld-flags-v -verbose)
+    else() # (Unix based systems, Intel(R) MIC Architecture, and Mac)
+        # pick test-touch compiler
+        if(${STD_CPP_LIB})
+            set(tt-c ${CMAKE_CXX_COMPILER})
+        else()
+            set(tt-c ${CMAKE_C_COMPILER})
+        endif()
+        # test-touch compilation flags
+        if(${LINUX})
+            list(APPEND tt-c-flags -pthread)
+        endif()
+        if(${IA32})
+            list(APPEND tt-c-flags -m32)
+        elseif(${INTEL64})
+            list(APPEND tt-c-flags -m64)
+        endif()
+        list(APPEND tt-libs ${build_dir}/${lib_file})
+        if(${MAC})
+            list(APPEND tt-ld-flags-v -Wl,-t)
+            set(tt-env "DYLD_LIBRARY_PATH=.:$ENV{DYLD_LIBRARY_PATH}")
+        else()
+            list(APPEND tt-ld-flags-v -Wl,--verbose)
+            set(tt-env LD_LIBRARY_PATH=".:${build_dir}:$ENV{LD_LIBRARY_PATH}")
+        endif()
+    endif()
+    list(APPEND tt-c-flags "${tt-c-flags-rt}")
+    list(APPEND tt-env "KMP_VERSION=1")
+
+    macro(test_touch_recipe test_touch_dir)
+        file(MAKE_DIRECTORY ${build_dir}/${test_touch_dir})
+        set(ldeps ${src_dir}/test-touch.c ${build_dir}/${lib_file})
+        set(tt-exe-file ${test_touch_dir}/test-touch${exe})
+        if(${WINDOWS})
+            # ****** list(APPEND tt-c-flags -Fo$(dir $@)test-touch${obj} -Fe$(dir $@)test-touch${exe}) *******
+            set(tt-c-flags-out -Fo${test_touch_dir}/test-touch${obj} -Fe${test_touch_dir}/test-touch${exe})
+            list(APPEND ldeps ${build_dir}/${imp_file})
+        else()
+            # ****** list(APPEND tt-c-flags -o $(dir $@)test-touch${exe}) ********
+            set(tt-c-flags-out -o ${test_touch_dir}/test-touch${exe})
+        endif()
+        add_custom_command(
+            OUTPUT  ${test_touch_dir}/.success
+            COMMAND ${CMAKE_COMMAND} -E remove -f ${test_touch_dir}/*
+            COMMAND ${tt-c} ${tt-c-flags-out} ${tt-c-flags} ${src_dir}/test-touch.c ${tt-libs} ${tt-ld-flags}
+            COMMAND ${CMAKE_COMMAND} -E remove -f ${tt-exe-file}
+            COMMAND ${tt-c} ${tt-c-flags-out} ${tt-c-flags} ${src_dir}/test-touch.c ${tt-libs} ${tt-ld-flags} ${tt-ld-flags-v} > ${test_touch_dir}/build.log 2>&1
+            COMMAND ${tt-env} ${tt-exe-file}
+            #COMMAND grep -i -e \"[^_]libirc\" ${test_touch_dir}/build.log > ${test_touch_dir}/libirc.log \; [ $$? -eq 1 ]
+            COMMAND ${CMAKE_COMMAND} -E touch ${test_touch_dir}/.success
+            DEPENDS ${ldeps}
+        )
+    endmacro()
+    if(${WINDOWS})
+        test_touch_recipe(test-touch-mt)
+        test_touch_recipe(test-touch-md)
+    else()
+        test_touch_recipe(test-touch-rt)
+    endif()
+else()
+    add_custom_target(test-touch DEPENDS test-touch/.success)
+    macro(test_touch_recipe_skip test_touch_dir)
+        if(${tests} AND ${test_touch})
+            set(test_touch_message 'test-touch is not available for the Intel(R) MIC Architecture.  Will not perform it.')
+        else()
+            set(test_touch_message "test-touch is turned off.  Will not perform it.")
+        endif()
+        add_custom_command(
+            OUTPUT ${test_touch_dir}/.success
+            COMMAND ${CMAKE_COMMAND} -E echo ${test_touch_message}
+        )
+    endmacro()
+    test_touch_recipe_skip(test-touch-rt)
+    test_touch_recipe_skip(test-touch-mt)
+    test_touch_recipe_skip(test-touch-md)
+endif()
+
+# test-relo 
+add_custom_target(test-relo DEPENDS test-relo/.success)
+if((${LINUX} OR ${MIC}) AND ${test_relo} AND ${tests})
+    file(MAKE_DIRECTORY ${build_dir}/test-relo)
+    add_custom_command(
+        OUTPUT  test-relo/.success
+        COMMAND readelf -d ${build_dir}/${lib_file} > test-relo/readelf.log
+        COMMAND grep -e TEXTREL test-relo/readelf.log \; [ $$? -eq 1 ]
+        COMMAND ${CMAKE_COMMAND} -E touch test-relo/.success
+        DEPENDS ${build_dir}/${lib_file}
+    )
+else()
+    if(${tests} AND ${test_relo})
+        set(test_relo_message 'test-relo is only available for dynamic library on Linux or Intel(R) MIC Architecture.  Will not perform it.')
+    else()
+        set(test_relo_message "test-relo is turned off.  Will not perform it.")
+    endif()
+    add_custom_command(
+        OUTPUT  test-relo/.success
+        COMMAND ${CMAKE_COMMAND} -E echo ${test_relo_message}
+    )
+endif()
+
+# test-execstack
+add_custom_target(test-execstack DEPENDS test-execstack/.success)
+if(${LINUX} AND ${test_execstack} AND ${tests})
+    file(MAKE_DIRECTORY ${build_dir}/test-execstack)
+    add_custom_command(
+        OUTPUT  test-execstack/.success
+        COMMAND ${PERL_EXECUTABLE} ${tools_dir}/check-execstack.pl ${build_dir}/${lib_file}
+        COMMAND ${CMAKE_COMMAND} -E touch test-execstack/.success
+        DEPENDS ${build_dir}/${lib_file}
+    )
+else()
+    if(${tests} AND ${test_execstack})
+        set(test_execstack_message "test-execstack is only available for dynamic library on Linux.  Will not perform it.")
+    else()
+        set(test_execstack_message "test-execstack is turned off.  Will not perform it.")
+    endif()
+    add_custom_command(
+        OUTPUT  test-execstack/.success
+        COMMAND ${CMAKE_COMMAND} -E echo ${test_execstack_message}
+    )
+endif()
+
+# test-instr
+add_custom_target(test-instr DEPENDS test-instr/.success)
+if(${MIC} AND ${test_instr} AND ${tests})
+    file(MAKE_DIRECTORY ${build_dir}/test-instr)
+    add_custom_command(
+        OUTPUT  test-instr/.success
+        COMMAND ${PERL_EXECUTABLE} ${tools_dir}/check-instruction-set.pl ${oa_opts} --show --mic-arch=${mic_arch} --mic-os=${mic_os} ${build_dir}/${lib_file}
+        COMMAND ${CMAKE_COMMAND} -E touch test-instr/.success
+        DEPENDS ${build_dir}/${lib_file} ${tools_dir}/check-instruction-set.pl
+    )
+else()
+    if(${tests} AND ${test_instr})
+        set(test_instr_message 'test-instr is only available for Intel(R) MIC Architecture libraries.  Will not perform it.')
+    else()
+        set(test_instr_message "test-instr is turned off.  Will not perform it.")
+    endif()
+    add_custom_command(
+        OUTPUT  test-instr/.success
+        COMMAND ${CMAKE_COMMAND} -E echo ${test_instr_message}
+    )
+endif()
+
+# test-deps
+add_custom_target(test-deps DEPENDS test-deps/.success)
+if(${test_deps} AND ${tests})
+    set(td_exp)
+    if(${FREEBSD})
+        set(td_exp libc.so.7 libthr.so.3 libunwind.so.5)
+    elseif(${LINUX})
+        set(td_exp libdl.so.2,libgcc_s.so.1)
+        if(NOT ${IA32} AND NOT ${INTEL64})
+            set(td_exp ${td_exp},libffi.so.6,libffi.so.5)
+        endif()
+        if(${IA32})
+            set(td_exp ${td_exp},libc.so.6,ld-linux.so.2)  
+        elseif(${INTEL64})
+            set(td_exp ${td_exp},libc.so.6,ld-linux-x86-64.so.2)  
+        elseif(${ARM})
+            set(td_exp ${td_exp},libc.so.6,ld-linux-armhf.so.3)  
+        endif()
+        if(${STD_CPP_LIB})
+            set(td_exp ${td_exp},libstdc++.so.6)
+        endif()
+        if(NOT ${STUBS_LIBRARY})
+            set(td_exp ${td_exp},libpthread.so.0)
+        endif()
+    elseif(${MIC})
+        if("${mic_os}" STREQUAL "lin")
+            set(td_exp libc.so.6,libpthread.so.0,libdl.so.2)
+            if(${STD_CPP_LIB})
+                set(td_exp ${td_exp},libstdc++.so.6)
+            endif()
+            if("${mic_arch}" STREQUAL "knf")
+                set(td_exp ${td_exp},ld-linux-l1om.so.2,libgcc_s.so.1)
+            elseif("${mic_arch}" STREQUAL "knc")
+                set(td_exp ${td_exp},ld-linux-k1om.so.2)
+            endif()
+        elseif("${mic_os}" STREQUAL "bsd")
+            set(td_exp libc.so.7,libthr.so.3,libunwind.so.5)
+        endif()
+    elseif(${MAC})
+        set(td_exp /usr/lib/libSystem.B.dylib)
+    elseif(${WINDOWS})
+        set(td_exp kernel32.dll)
+    endif()
+
+    file(MAKE_DIRECTORY ${build_dir}/test-deps)
+    add_custom_command(
+        OUTPUT  test-deps/.success
+        COMMAND ${PERL_EXECUTABLE} ${tools_dir}/check-depends.pl ${oa_opts} --expected="${td_exp}" ${build_dir}/${lib_file}
+        COMMAND ${CMAKE_COMMAND} -E touch test-deps/.success
+        DEPENDS ${build_dir}/${lib_file} ${tools_dir}/check-depends.pl
+    )
+else()
+    if(${tests} AND ${test_deps})
+        set(test_deps_message 'test-deps is available for dynamic libraries on Linux, Mac, Intel(R) MIC Architecture, Windows and static libraries on Windows.  Will not perform it.')
+    else()
+        set(test_deps_message "test-deps is turned off.  Will not perform it.")
+    endif()
+    add_custom_command(
+        OUTPUT  test-deps/.success
+        COMMAND ${CMAKE_COMMAND} -E echo ${test_deps_message}
+    )
+endif()
+# END OF TESTS
+######################################################
diff --git a/openmp/runtime/cmake/PerlFlags.cmake b/openmp/runtime/cmake/PerlFlags.cmake
new file mode 100644
index 0000000..c34d29d
--- /dev/null
+++ b/openmp/runtime/cmake/PerlFlags.cmake
@@ -0,0 +1,90 @@
+#
+#//===----------------------------------------------------------------------===//
+#//
+#//                     The LLVM Compiler Infrastructure
+#//
+#// This file is dual licensed under the MIT and the University of Illinois Open
+#// Source Licenses. See LICENSE.txt for details.
+#//
+#//===----------------------------------------------------------------------===//
+#
+
+# void append_ev_flags(string new_flag);
+# - appends new_flag to ev_flags list
+macro(append_ev_flags new_flag)
+    list(APPEND local_ev_flags "${new_flag}")
+endmacro()
+
+# void append_gd_flags(string new_flag);
+# - appends new_flag to gd_flags list
+macro(append_gd_flags new_flag)
+    list(APPEND local_gd_flags "${new_flag}")
+endmacro()
+
+include(HelperFunctions) # for set_legal_type(), set_legal_arch()
+
+# Perl expand-vars.pl flags
+function(set_ev_flags input_ev_flags)
+    set(local_ev_flags)
+    set_legal_type("${lib_type}" legal_type)
+    set_legal_arch("${arch}" legal_arch)
+    # need -D Revision="\$Revision" to show up
+    append_ev_flags("-D Revision=\"\\\\$$Revision\"") 
+    append_ev_flags("-D Date=\"\\\\$$Date\"")
+    append_ev_flags("-D KMP_TYPE=\"${legal_type}\"")
+    append_ev_flags("-D KMP_ARCH=\"${legal_arch}\"")
+    append_ev_flags("-D KMP_VERSION_MAJOR=${version}")
+    append_ev_flags("-D KMP_VERSION_MINOR=0")
+    append_ev_flags("-D KMP_VERSION_BUILD=${build_number}")
+    append_ev_flags("-D KMP_BUILD_DATE=\"${date}\"")
+    append_ev_flags("-D KMP_TARGET_COMPILER=12")
+    if(${DEBUG_BUILD} OR ${RELWITHDEBINFO_BUILD})
+        append_ev_flags("-D KMP_DIAG=1")
+        append_ev_flags("-D KMP_DEBUG_INFO=1")
+    else()
+        append_ev_flags("-D KMP_DIAG=0")
+        append_ev_flags("-D KMP_DEBUG_INFO=0")
+    endif()
+    if(${omp_version} EQUAL 40)
+        append_ev_flags("-D OMP_VERSION=201307")
+    elseif(${omp_version} EQUAL 30)
+        append_ev_flags("-D OMP_VERSION=201107")
+    else()
+        append_ev_flags("-D OMP_VERSION=200505")
+    endif()
+    set(${input_ev_flags} "${local_ev_flags}" PARENT_SCOPE)
+endfunction()
+
+function(set_gd_flags input_gd_flags)
+    set(local_gd_flags)
+    if(${IA32})
+        append_gd_flags("-D arch_32")
+    elseif(${INTEL64})
+        append_gd_flags("-D arch_32e")
+    else()
+        append_gd_flags("-D arch_${arch}")
+    endif()
+    if(${NORMAL_LIBRARY})
+        append_gd_flags("-D norm")
+    elseif(${PROFILE_LIBRARY})
+        append_gd_flags("-D prof")
+    elseif(${STUBS_LIBRARY})
+        append_gd_flags("-D stub")
+    endif()
+    if(${omp_version} GREATER 40 OR ${omp_version} EQUAL 40)
+        append_gd_flags("-D OMP_40")
+    endif()
+    if(${omp_version} GREATER 30 OR ${omp_version} EQUAL 30)
+        append_gd_flags("-D OMP_30")
+    endif()
+    if(NOT "${version}" STREQUAL "4")
+        append_gd_flags("-D msvc_compat")
+    endif()
+    if(${DEBUG_BUILD} OR ${RELWITHDEBINFO_BUILD})
+        append_gd_flags("-D KMP_DEBUG")
+    endif()
+    if(${COMPILER_SUPPORTS_QUAD_PRECISION})
+        append_gd_flags("-D HAVE_QUAD")
+    endif()
+    set(${input_gd_flags} "${local_gd_flags}" PARENT_SCOPE)
+endfunction()
diff --git a/openmp/runtime/cmake/SourceFiles.cmake b/openmp/runtime/cmake/SourceFiles.cmake
new file mode 100644
index 0000000..a884fea
--- /dev/null
+++ b/openmp/runtime/cmake/SourceFiles.cmake
@@ -0,0 +1,110 @@
+#
+#//===----------------------------------------------------------------------===//
+#//
+#//                     The LLVM Compiler Infrastructure
+#//
+#// This file is dual licensed under the MIT and the University of Illinois Open
+#// Source Licenses. See LICENSE.txt for details.
+#//
+#//===----------------------------------------------------------------------===//
+#
+
+macro(append_c_source_file new_c_file)
+    list(APPEND local_c_source_files "${new_c_file}")
+endmacro()
+
+macro(append_cpp_source_file new_cpp_file)
+    list(APPEND local_cpp_source_files "${new_cpp_file}")
+endmacro()
+
+macro(append_asm_source_file new_asm_file)
+    list(APPEND local_asm_source_files "${new_asm_file}")
+endmacro()
+
+macro(append_imp_c_source_file new_import_c_file)
+    list(APPEND local_imp_c_files "${new_import_c_file}")
+endmacro()
+
+# files are relative to the src directory
+
+function(set_c_files input_c_source_files) 
+    set(local_c_source_files "")
+    append_c_source_file("kmp_ftn_cdecl.c")
+    append_c_source_file("kmp_ftn_extra.c")
+    append_c_source_file("kmp_version.c")
+    if(${STUBS_LIBRARY})
+        append_c_source_file("kmp_stub.c")
+    else()
+        append_c_source_file("kmp_alloc.c")
+        append_c_source_file("kmp_atomic.c")
+        append_c_source_file("kmp_csupport.c")
+        append_c_source_file("kmp_debug.c")
+        append_c_source_file("kmp_itt.c")
+        append_c_source_file("kmp_environment.c")
+        append_c_source_file("kmp_error.c")
+        append_c_source_file("kmp_global.c")
+        append_c_source_file("kmp_i18n.c")
+        append_c_source_file("kmp_io.c")
+        append_c_source_file("kmp_runtime.c")
+        append_c_source_file("kmp_settings.c")
+        append_c_source_file("kmp_str.c")
+        append_c_source_file("kmp_tasking.c")
+        append_c_source_file("kmp_taskq.c")
+        append_c_source_file("kmp_threadprivate.c")
+        append_c_source_file("kmp_utility.c")
+        if(${USE_ITT_NOTIFY})
+            append_c_source_file("thirdparty/ittnotify/ittnotify_static.c")
+        endif()
+        if(${WINDOWS})
+            append_c_source_file("z_Windows_NT_util.c")
+            append_c_source_file("z_Windows_NT-586_util.c")
+        else()
+            append_c_source_file("z_Linux_util.c")
+            append_c_source_file("kmp_gsupport.c")
+        endif()
+    endif()
+    set(${input_c_source_files} "${local_c_source_files}" PARENT_SCOPE)
+endfunction()
+
+function(set_cpp_files input_cpp_source_files) 
+    set(local_cpp_source_files "")
+    if(NOT ${STUBS_LIBRARY})
+        #append_cpp_source_file("kmp_barrier.cpp")
+        append_cpp_source_file("kmp_affinity.cpp")
+        append_cpp_source_file("kmp_dispatch.cpp")
+        append_cpp_source_file("kmp_lock.cpp")
+        append_cpp_source_file("kmp_sched.cpp")
+        if("${omp_version}" STREQUAL "40")
+            append_cpp_source_file("kmp_taskdeps.cpp")
+            append_cpp_source_file("kmp_cancel.cpp")
+        endif()
+        #if(${STATS_GATHERING})
+        #   append_cpp_source_file("kmp_stats.cpp")
+        #    append_cpp_source_file("kmp_stats_timing.cpp")
+        #endif()
+    endif()
+
+    set(${input_cpp_source_files} "${local_cpp_source_files}" PARENT_SCOPE)
+endfunction()
+
+
+function(set_asm_files input_asm_source_files) 
+    set(local_asm_source_files "")
+    if(NOT ${STUBS_LIBRARY})
+        if(${WINDOWS})
+            append_asm_source_file("z_Windows_NT-586_asm.asm")
+        else()
+            append_asm_source_file("z_Linux_asm.s")
+        endif()
+    endif()
+    set(${input_asm_source_files} "${local_asm_source_files}" PARENT_SCOPE)
+endfunction()
+
+
+function(set_imp_c_files input_imp_c_files)
+    set(local_imp_c_files "")
+    if(${WINDOWS})
+        append_imp_c_source_file("kmp_import.c")
+    endif()
+    set(${input_imp_c_files} "${local_imp_c_files}" PARENT_SCOPE)
+endfunction()