This is an archive of the discontinued LLVM Phabricator instance.

[llvm] [cmake] Add additional headers only if they exist
ClosedPublic

Authored by mgorny on Mar 20 2019, 11:18 PM.

Details

Summary

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.

Diff Detail

Event Timeline

mgorny created this revision.Mar 20 2019, 11:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 20 2019, 11:18 PM
smeenai added a subscriber: smeenai.Apr 3 2019, 9:40 AM
smeenai added inline comments.
llvm/cmake/modules/LLVMProcessSources.cmake
35

I'd add a comment explaining this is for broken symlinks, otherwise I'd be wondering why you were checking for the existence of a file you just globbed...

Actually, is EXISTS resolving symlinks documented anywhere? It's unclear if it would return the existence of the symlink itself or the target of the symlink.

mgorny marked an inline comment as done.Apr 3 2019, 10:05 AM
mgorny added inline comments.
llvm/cmake/modules/LLVMProcessSources.cmake
35

I'd add a comment explaining this is for broken symlinks, otherwise I'd be wondering why you were checking for the existence of a file you just globbed...

Good idea.

Actually, is EXISTS resolving symlinks documented anywhere? It's unclear if it would return the existence of the symlink itself or the target of the symlink.

To be honest, I don't see it in CMake docs. I think I presumed that behavior from shell's -f operator but there's indeed some potential ambiguity here.

smeenai accepted this revision.Apr 3 2019, 5:06 PM

LGTM with the comment added.

llvm/cmake/modules/LLVMProcessSources.cmake
35

Looks like it just calls access, which should resolve symlinks.

This revision is now accepted and ready to land.Apr 3 2019, 5:06 PM
smeenai added inline comments.Apr 3 2019, 5:29 PM
llvm/cmake/modules/LLVMProcessSources.cmake
35
mgorny marked an inline comment as done.Apr 3 2019, 11:28 PM
mgorny added inline comments.
llvm/cmake/modules/LLVMProcessSources.cmake
35

Thank you. I'll add the comment later today and push it.

This revision was automatically updated to reflect the committed changes.