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

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 10 02:15:17 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)
----------------
arsenm wrote:

I'd rather avoid adding it in the first place. I'm not a fan of adding an include to the parent instead of the parent adding the include directory to the list 

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


More information about the cfe-commits mailing list