0001-llvm-cmake-Add-additional-headers-only-if-they-exist.patch 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. From 1f68002cb725c6a8fb5ca8425c1c86495a053f4f Mon Sep 17 00:00:00 2001
  2. From: Michal Gorny <mgorny@gentoo.org>
  3. Date: Thu, 4 Apr 2019 14:21:38 +0000
  4. Subject: [PATCH] [llvm] [cmake] Add additional headers only if they exist
  5. Modify the add_header_files_for_glob() function to only add files
  6. that do exist, rather than all matches of the glob. This fixes CMake
  7. error when one of the include directories (which happen to include
  8. /usr/include) contain broken symlinks.
  9. Differential Revision: https://reviews.llvm.org/D59632
  10. llvm-svn: 357701
  11. ---
  12. llvm/cmake/modules/LLVMProcessSources.cmake | 10 +++++++++-
  13. 1 file changed, 9 insertions(+), 1 deletion(-)
  14. diff --git a/cmake/modules/LLVMProcessSources.cmake b/cmake/modules/LLVMProcessSources.cmake
  15. index 7cbd2863500..d0be0e8b3ba 100644
  16. --- a/src/llvm-project/llvm/cmake/modules/LLVMProcessSources.cmake
  17. +++ b/src/llvm-project/llvm/cmake/modules/LLVMProcessSources.cmake
  18. @@ -30,7 +30,15 @@ endmacro(add_td_sources)
  19. function(add_header_files_for_glob hdrs_out glob)
  20. file(GLOB hds ${glob})
  21. - set(${hdrs_out} ${hds} PARENT_SCOPE)
  22. + set(filtered)
  23. + foreach(file ${hds})
  24. + # Explicit existence check is necessary to filter dangling symlinks
  25. + # out. See https://bugs.gentoo.org/674662.
  26. + if(EXISTS ${file})
  27. + list(APPEND filtered ${file})
  28. + endif()
  29. + endforeach()
  30. + set(${hdrs_out} ${filtered} PARENT_SCOPE)
  31. endfunction(add_header_files_for_glob)
  32. function(find_all_header_files hdrs_out additional_headerdirs)
  33. --
  34. 2.21.0