================
@@ -1,67 +1,68 @@
-# Converts a list of relative source paths to absolute paths and exports
-# it to the parent scope.
-macro(libclc_configure_source_list variable path)
- set(${variable} ${ARGN})
- list(TRANSFORM ${variable} PREPEND "${path}/")
- set(${variable} ${${variable}} PARENT_SCOPE)
-endmacro()
-
-# Appends a compile option to the given source files. Paths are relative
-# to `path` and the property is set in the top-level libclc directory scope.
-macro(libclc_configure_source_options path option)
- set(_option_srcs ${ARGN})
- list(TRANSFORM _option_srcs PREPEND "${path}/")
- set_property(SOURCE ${_option_srcs}
- DIRECTORY ${LIBCLC_SOURCE_DIR}
- APPEND PROPERTY COMPILE_OPTIONS ${option}
- )
-endmacro()
-
-# Merges OpenCL C source file lists with priority deduplication.
-#
-# All arguments after the output variable name are treated as source file
-# paths. When multiple files share the same basename, the last occurrence
-# wins. This allows target-specific files to automatically override generic
-# ones.
-function(libclc_merge_sources output)
- set(all_sources ${ARGN})
- set(result)
- set(seen_names)
-
- list(REVERSE all_sources)
- foreach(f ${all_sources})
- get_filename_component(name "${f}" NAME)
- if(NOT name IN_LIST seen_names)
- list(APPEND seen_names "${name}")
- list(PREPEND result "${f}")
+# Adds source files to a libclc builtin library target with deduplication. If a
+# source with the same basename already exists in the target's SOURCES
property,
+# the new file is skipped.
+function(libclc_add_sources target)
+ cmake_parse_arguments(ARG "" "BASE_DIR" "" ${ARGN})
+ if(NOT ARG_BASE_DIR)
+ set(ARG_BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+ endif()
+
+ get_target_property(existing ${target} SOURCES)
+ if(NOT existing)
+ set(existing "")
+ endif()
+
+ set(seen)
+ foreach(file ${existing})
----------------
wenju-he wrote:
foreach(file IN LISTS existing), then no need to check if existing is not valid
at line 11
https://github.com/llvm/llvm-project/pull/197034
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits