diff --git a/CMakeLists.txt b/CMakeLists.txt index 942e71417e63..f082c185d05e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -449,7 +449,7 @@ enable_testing() # ---[ Build variables set within the cmake tree include(cmake/BuildVariables.cmake) -set(CAFFE2_WHITELIST "" CACHE STRING "A whitelist file of files that one should build.") +set(CAFFE2_ALLOWLIST "" CACHE STRING "A allowlist file of files that one should build.") # Set default build type if(NOT CMAKE_BUILD_TYPE) @@ -499,8 +499,8 @@ if(USE_VULKAN_SHADERC_RUNTIME) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_VULKAN_SHADERC_RUNTIME") endif() -# ---[ Whitelist file if whitelist is specified -include(cmake/Whitelist.cmake) +# ---[ Allowlist file if allowlist is specified +include(cmake/Allowlist.cmake) # ---[ Set link flag, handle additional deps for gcc 4.8 and above if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.8.0 AND NOT ANDROID) diff --git a/caffe2/CMakeLists.txt b/caffe2/CMakeLists.txt index aaa5cd4ec2d8..051100922c9c 100644 --- a/caffe2/CMakeLists.txt +++ b/caffe2/CMakeLists.txt @@ -142,12 +142,12 @@ if(NOT INTERN_BUILD_MOBILE OR BUILD_CAFFE2_MOBILE) add_subdirectory(transforms) endif() -# Advanced: if we have white list specified, we will do intersections for all +# Advanced: if we have allow list specified, we will do intersections for all # main lib srcs. -if(CAFFE2_WHITELISTED_FILES) - caffe2_do_whitelist(Caffe2_CPU_SRCS CAFFE2_WHITELISTED_FILES) - caffe2_do_whitelist(Caffe2_GPU_SRCS CAFFE2_WHITELISTED_FILES) - caffe2_do_whitelist(Caffe2_HIP_SRCS CAFFE2_WHITELISTED_FILES) +if(CAFFE2_ALLOWLISTED_FILES) + caffe2_do_allowlist(Caffe2_CPU_SRCS CAFFE2_ALLOWLISTED_FILES) + caffe2_do_allowlist(Caffe2_GPU_SRCS CAFFE2_ALLOWLISTED_FILES) + caffe2_do_allowlist(Caffe2_HIP_SRCS CAFFE2_ALLOWLISTED_FILES) endif() # Debug messages - if you want to get a list of source files, enable the diff --git a/cmake/Allowlist.cmake b/cmake/Allowlist.cmake new file mode 100644 index 000000000000..bcee889ad53a --- /dev/null +++ b/cmake/Allowlist.cmake @@ -0,0 +1,32 @@ + +if(__caffe2_allowlist_included) + return() +endif() + +set(__caffe2_allowlist_included TRUE) + +set(CAFFE2_ALLOWLISTED_FILES) +if(NOT CAFFE2_ALLOWLIST) + return() +endif() + +# First read the allowlist file and break it by line. +file(READ "${CAFFE2_ALLOWLIST}" allowlist_content) +# Convert file contents into a CMake list +string(REGEX REPLACE "\n" ";" allowlist_content ${allowlist_content}) + +foreach(item ${allowlist_content}) + file(GLOB_RECURSE tmp ${item}) + set(CAFFE2_ALLOWLISTED_FILES ${CAFFE2_ALLOWLISTED_FILES} ${tmp}) +endforeach() + +macro(caffe2_do_allowlist output allowlist) + set(_tmp) + foreach(item ${${output}}) + list(FIND ${allowlist} ${item} _index) + if(${_index} GREATER -1) + set(_tmp ${_tmp} ${item}) + endif() + endforeach() + set(${output} ${_tmp}) +endmacro() diff --git a/cmake/Whitelist.cmake b/cmake/Whitelist.cmake deleted file mode 100644 index cb00c6d4b980..000000000000 --- a/cmake/Whitelist.cmake +++ /dev/null @@ -1,32 +0,0 @@ - -if(__caffe2_whitelist_included) - return() -endif() - -set(__caffe2_whitelist_included TRUE) - -set(CAFFE2_WHITELISTED_FILES) -if(NOT CAFFE2_WHITELIST) - return() -endif() - -# First read the whitelist file and break it by line. -file(READ "${CAFFE2_WHITELIST}" whitelist_content) -# Convert file contents into a CMake list -string(REGEX REPLACE "\n" ";" whitelist_content ${whitelist_content}) - -foreach(item ${whitelist_content}) - file(GLOB_RECURSE tmp ${item}) - set(CAFFE2_WHITELISTED_FILES ${CAFFE2_WHITELISTED_FILES} ${tmp}) -endforeach() - -macro(caffe2_do_whitelist output whitelist) - set(_tmp) - foreach(item ${${output}}) - list(FIND ${whitelist} ${item} _index) - if(${_index} GREATER -1) - set(_tmp ${_tmp} ${item}) - endif() - endforeach() - set(${output} ${_tmp}) -endmacro()