[Openmp-commits] [openmp] [OpenMP] Use "standalone" include path if clang is not being built (PR #143405)

Ross Brunton via Openmp-commits openmp-commits at lists.llvm.org
Mon Jun 9 08:46:41 PDT 2025


https://github.com/RossBrunton created https://github.com/llvm/llvm-project/pull/143405

If clang is not being built as part of this build, install headers into
`include` rather than `lib/clang/21/include` (the latter, in clangless
builds, will not be automatically included in search paths).

This, combined with #143390 , allows builds that include OpenMP but not
clang to build successfully.


>From 5ca376c53fe5b5756dd5c010ad9863831a6ec51f Mon Sep 17 00:00:00 2001
From: Ross Brunton <ross at codeplay.com>
Date: Mon, 9 Jun 2025 16:41:39 +0100
Subject: [PATCH] [OpenMP] Use "standalone" include path if clang is not being
 built

If clang is not being built as part of this build, install headers into
`include` rather than `lib/clang/21/include` (the latter, in clangless
builds, will not be automatically included in search paths).

This, combined with #143390 , allows builds that include OpenMP but not
clang to build successfully.
---
 openmp/CMakeLists.txt             | 2 +-
 openmp/runtime/src/CMakeLists.txt | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt
index c206386fa6b61..8ef5f98c612d2 100644
--- a/openmp/CMakeLists.txt
+++ b/openmp/CMakeLists.txt
@@ -115,7 +115,7 @@ option(OPENMP_ENABLE_LIBOMPTARGET "Enable building libomptarget for offloading."
 option(OPENMP_ENABLE_LIBOMP_PROFILING "Enable time profiling for libomp." OFF)
 
 # Header install location
-if(${OPENMP_STANDALONE_BUILD})
+if("${OPENMP_STANDALONE_BUILD}" OR NOT Clang_DIR)
   set(LIBOMP_HEADERS_INSTALL_PATH "${CMAKE_INSTALL_INCLUDEDIR}")
 else()
   include(GetClangResourceDir)
diff --git a/openmp/runtime/src/CMakeLists.txt b/openmp/runtime/src/CMakeLists.txt
index 698e185d9c4dd..3daab37f2d92a 100644
--- a/openmp/runtime/src/CMakeLists.txt
+++ b/openmp/runtime/src/CMakeLists.txt
@@ -11,7 +11,7 @@
 include(ExtendPath)
 
 # The generated headers will be placed in clang's resource directory if present.
-if(OPENMP_STANDALONE_BUILD OR NOT LLVM_RUNTIMES_BUILD)
+if(OPENMP_STANDALONE_BUILD OR NOT LLVM_RUNTIMES_BUILD OR NOT Clang_DIR)
   set(LIBOMP_HEADERS_INTDIR ${CMAKE_CURRENT_BINARY_DIR})
 else()
   set(LIBOMP_HEADERS_INTDIR ${LLVM_BINARY_DIR}/${LIBOMP_HEADERS_INSTALL_PATH})



More information about the Openmp-commits mailing list