From: Michal Gorny Date: Thu, 4 Apr 2019 14:21:38 +0000 (+0000) Subject: [llvm] [cmake] Add additional headers only if they exist X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e259a4d243d63b3159851f82b98663db69cf6adc;p=llvm [llvm] [cmake] Add additional headers only if they exist Modify the add_header_files_for_glob() function to only add files that do exist, rather than all matches of the glob. This fixes CMake error when one of the include directories (which happen to include /usr/include) contain broken symlinks. Differential Revision: https://reviews.llvm.org/D59632 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@357701 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/cmake/modules/LLVMProcessSources.cmake b/cmake/modules/LLVMProcessSources.cmake index 7cbd2863500..d0be0e8b3ba 100644 --- a/cmake/modules/LLVMProcessSources.cmake +++ b/cmake/modules/LLVMProcessSources.cmake @@ -30,7 +30,15 @@ endmacro(add_td_sources) function(add_header_files_for_glob hdrs_out glob) file(GLOB hds ${glob}) - set(${hdrs_out} ${hds} PARENT_SCOPE) + set(filtered) + foreach(file ${hds}) + # Explicit existence check is necessary to filter dangling symlinks + # out. See https://bugs.gentoo.org/674662. + if(EXISTS ${file}) + list(APPEND filtered ${file}) + endif() + endforeach() + set(${hdrs_out} ${filtered} PARENT_SCOPE) endfunction(add_header_files_for_glob) function(find_all_header_files hdrs_out additional_headerdirs)