diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt --- a/llvm/runtimes/CMakeLists.txt +++ b/llvm/runtimes/CMakeLists.txt @@ -361,12 +361,11 @@ # together in a single CMake invocation. set(extra_deps "") if("openmp" IN_LIST LLVM_ENABLE_RUNTIMES) - if(TARGET opt) - list(APPEND extra_deps opt) - endif() - if(TARGET llvm-link) - list(APPEND extra_deps llvm-link) - endif() + foreach(dep opt llvm-link llvm-extract clang clang-offload-packager) + if(TARGET ${dep} AND OPENMP_ENABLE_LIBOMPTARGET) + list(APPEND extra_deps ${dep}) + endif() + endforeach() endif() if("libc" IN_LIST LLVM_ENABLE_RUNTIMES AND (LLVM_LIBC_FULL_BUILD OR LIBC_GPU_BUILD OR LIBC_GPU_ARCHITECTURES))