1# Copyright 2020 Google LLC 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15# Forked from IREE's iree_add_all_subdirs.cmake. 16 17# add_all_subidrs 18# 19# CMake function to add all subdirectories of the current directory that contain 20# a CMakeLists.txt file 21# 22# Takes no arguments. 23function(ruy_add_all_subdirs) 24 FILE(GLOB _CHILDREN RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*) 25 SET(_DIRLIST "") 26 foreach(_CHILD ${_CHILDREN}) 27 if((NOT(subdir MATCHES third_party)) AND 28 (IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_CHILD}) AND 29 (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_CHILD}/CMakeLists.txt)) 30 LIST(APPEND _DIRLIST ${_CHILD}) 31 endif() 32 endforeach() 33 34 foreach(subdir ${_DIRLIST}) 35 add_subdirectory(${subdir}) 36 endforeach() 37endfunction() 38