diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt --- a/openmp/runtime/src/CMakeLists.txt +++ b/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