This is an archive of the discontinued LLVM Phabricator instance.

[cmake] Use source-groups in Polly
ClosedPublic

Authored by ctetreau on Jan 2 2020, 3:56 PM.

Details

Summary
  • Configure CMake to setup source-groups for Polly. Source groups

describe how source files should be organized in IDEs. By default, all
headers are dumped into one folder under PollyCore and all source files
into another. On disk, these files are organized into folders, but this
isn't reflected in the IDE. This change uses CMake source groups to have
the IDE reflect the on disk layout. This will make it easier to visualize
the project structure for users of Visual Studio and XCode

Change-Id: Ifc8f0cc79850df3d88b7ed165a8554715a3a2753

Event Timeline

ctetreau created this revision.Jan 2 2020, 3:56 PM
Herald added a project: Restricted Project. · View Herald Transcript
grosser accepted this revision.Jan 3 2020, 1:35 AM

This looks reasonable from my side.

This revision is now accepted and ready to land.Jan 3 2020, 1:35 AM
Meinersbur added inline comments.Jan 3 2020, 2:46 AM
polly/cmake/polly_macros.cmake
102

Why not using GLOB_RECURSE such that setup_polly_source_groups_helper does not need to call itself?

ctetreau marked an inline comment as done.Jan 3 2020, 11:11 AM
ctetreau added inline comments.
polly/cmake/polly_macros.cmake
102

Suppose we have this directory structure:

root
|-------outer
|       |-------inner
|-a.cpp |-c.cpp |-e.cpp
|-b.cpp |-d.cpp |-f.cpp

file with GLOB_RECURSE would return a list similar to this:

[ root\outer\inner\e.cpp, root\outer\inner\f.cpp, root\outer\c.cpp, root\outer\d.cpp, root\a.cpp, root\b.cpp ]

However, if we were to pass this list to source_group, we'd be in the same situation that we started in. What we need to do is to have three lists:

[ root\outer\inner\e.cpp, root\outer\inner\f.cpp ]
[ root\outer\c.cpp, root\outer\d.cpp ]
[ root\a.cpp, root\b.cpp ]

We also need three calls to source_group. If ${prefix} = "src", we need:

source_group("src\\outer\\inner" FILES root\outer\inner\e.cpp, root\outer\inner\f.cpp)
source_group("src\\outer" FIELS root\outer\c.cpp, root\outer\d.cpp)
source_group("src" FILES root\a.cpp, root\b.cpp)

Splitting the lists and computing the first argument to source group are the complicating factors. We could derive this information from the result of the recursive glob, that wouldn't be any simpler than just recursing and doing the non-recursive glob.

ctetreau marked an inline comment as done and an inline comment as not done.Jan 7 2020, 5:13 AM
Meinersbur accepted this revision.Jan 7 2020, 9:34 AM

Please add another comment for if you need someone else to do the commit.

polly/cmake/polly_macros.cmake
102

Thank you for the detailed explanation.

Thank you for doing code review. I do not have commit access, can somebody please merge this commit for me?

Thanks!

This revision was automatically updated to reflect the committed changes.

Thank you for the patch!