xref: /aosp_15_r20/external/pytorch/cmake/Allowlist.cmake (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1
2if(__caffe2_allowlist_included)
3  return()
4endif()
5
6set(__caffe2_allowlist_included TRUE)
7
8set(CAFFE2_ALLOWLISTED_FILES)
9if(NOT CAFFE2_ALLOWLIST)
10  return()
11endif()
12
13# First read the allowlist file and break it by line.
14file(READ "${CAFFE2_ALLOWLIST}" allowlist_content)
15# Convert file contents into a CMake list
16string(REGEX REPLACE "\n" ";" allowlist_content ${allowlist_content})
17
18foreach(item ${allowlist_content})
19  file(GLOB_RECURSE tmp ${item})
20  set(CAFFE2_ALLOWLISTED_FILES ${CAFFE2_ALLOWLISTED_FILES} ${tmp})
21endforeach()
22
23macro(caffe2_do_allowlist output allowlist)
24  set(_tmp)
25  foreach(item ${${output}})
26    list(FIND ${allowlist} ${item} _index)
27    if(${_index} GREATER -1)
28      set(_tmp ${_tmp} ${item})
29    endif()
30  endforeach()
31  set(${output} ${_tmp})
32endmacro()
33