[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
Wed Aug 3 12:32:15 PDT 2022


jlpeyton updated this revision to Diff 449742.
jlpeyton added a comment.

Addressing comments


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
@@ -220,6 +220,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 AND (LLVM_TOOL_CLANG_BUILD OR LLVM_RUNTIMES_BUILD))
+  function(copy_header_to_output_dir src dst_name)
+    # 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)
+    set(dst ${output_dir}/${dst_name})
+    add_custom_command(TARGET omp POST_BUILD
+      DEPENDS ${src}
+      COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
+      COMMENT "Copying OpenMP header ${dst_name}...")
+  endfunction(copy_header_to_output_dir)
+  copy_header_to_output_dir(${CMAKE_CURRENT_BINARY_DIR}/omp.h omp.h)
+  if(LIBOMP_OMPT_SUPPORT)
+    copy_header_to_output_dir(${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h omp-tools.h)
+    copy_header_to_output_dir(${CMAKE_CURRENT_BINARY_DIR}/omp-tools.h ompt.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.449742.patch
Type: text/x-patch
Size: 1442 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220803/0437be7a/attachment-0001.bin>


More information about the Openmp-commits mailing list