[libclc] [libclc][CMake] Use per-source include flags instead of target-level includes (PR #185598)

Wenju He via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 10 04:21:22 PDT 2026


================
@@ -50,17 +50,20 @@ function(add_libclc_builtin_library target_name)
     ${ARGN}
   )
 
-  set(_inc_dirs)
+  # Append each source's parent directory as an include path to COMPILE_OPTIONS.
   foreach(f ${ARG_SOURCES})
-    get_filename_component(dir ${f} DIRECTORY)
-    list(APPEND _inc_dirs ${dir})
+    cmake_path(GET f PARENT_PATH parent_dir)
+    get_property(_existing SOURCE "${f}" DIRECTORY ${LIBCLC_SOURCE_DIR} PROPERTY COMPILE_OPTIONS)
+    if(NOT "-I${parent_dir}" IN_LIST _existing)
----------------
wenju-he wrote:

it seems difficult to do it top down. The old code also does the same and include parent's folder: https://github.com/llvm/llvm-project/blob/732f66eccc24fc90c9fe9df65bfbe3ddedf220fc/libclc/cmake/modules/AddLibclc.cmake#L301

https://github.com/llvm/llvm-project/pull/185598


More information about the cfe-commits mailing list