[Openmp-commits] [PATCH] D130926: [OpenMP][libomp] Copy OpenMP headers to clang build directory

Jonathan Peyton via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Aug 1 19:20:29 PDT 2022


jlpeyton updated this revision to Diff 449168.
jlpeyton retitled this revision from "[OpenMP][libomp] Detect if test compiler has omp.h" to "[OpenMP][libomp] Copy OpenMP headers to clang build directory".
jlpeyton edited the summary of this revision.
jlpeyton added a comment.

Updated patch to copy headers to clang build directory so it can find `omp.h` and `omp-tools.h` before install phase.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130926/new/

https://reviews.llvm.org/D130926

Files:
  openmp/runtime/src/CMakeLists.txt


Index: openmp/runtime/src/CMakeLists.txt
===================================================================
--- openmp/runtime/src/CMakeLists.txt
+++ openmp/runtime/src/CMakeLists.txt
@@ -216,6 +216,28 @@
     WORKING_DIRECTORY ${LIBOMP_LIBRARY_DIR}
   )
 endif()
+# Copy headers to clang build directory structure
+# so it can find & use them before install
+if (NOT OPENMP_STANDALONE_BUILD)
+  # Had to manually copy this since CLANG_VERSION may be empty
+  set(major "${LLVM_VERSION_MAJOR}")
+  set(minor "${LLVM_VERSION_MINOR}")
+  set(patch "${LLVM_VERSION_PATCH}")
+  set(output_dir ${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${major}.${minor}.${patch}/include)
+  function(copy_header_to_output_dir src_dir file)
+    set(src ${src_dir}/${file})
+    set(dst ${output_dir}/${file})
+    add_custom_command(TARGET omp POST_BUILD
+      DEPENDS ${src}
+      COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
+      COMMENT "Copying OpenMP header ${file}...")
+  endfunction(copy_header_to_output_dir)
+  copy_header_to_output_dir(${CMAKE_CURRENT_BINARY_DIR} omp.h)
+  if(LIBOMP_OMPT_SUPPORT)
+    copy_header_to_output_dir(${CMAKE_CURRENT_BINARY_DIR} omp-tools.h)
+  endif()
+endif()
+
 set(LIBOMP_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE)
 
 # Create *.inc before compiling any sources


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130926.449168.patch
Type: text/x-patch
Size: 1309 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220802/a2ec9171/attachment.bin>


More information about the Openmp-commits mailing list