[llvm] r357701 - [llvm] [cmake] Add additional headers only if they exist

Michal Gorny via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 4 07:21:38 PDT 2019


Author: mgorny
Date: Thu Apr  4 07:21:38 2019
New Revision: 357701

URL: http://llvm.org/viewvc/llvm-project?rev=357701&view=rev
Log:
[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

Modified:
    llvm/trunk/cmake/modules/LLVMProcessSources.cmake

Modified: llvm/trunk/cmake/modules/LLVMProcessSources.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMProcessSources.cmake?rev=357701&r1=357700&r2=357701&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/LLVMProcessSources.cmake (original)
+++ llvm/trunk/cmake/modules/LLVMProcessSources.cmake Thu Apr  4 07:21:38 2019
@@ -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)




More information about the llvm-commits mailing list