This is an archive of the discontinued LLVM Phabricator instance.

[CMAKE] Plumb include_directories() into tablegen()
ClosedPublic

Authored by stephenneuendorffer on Mar 31 2020, 11:55 AM.

Details

Summary

Previously, the tablegen() cmake command, which defines custom
commands for running tablegen, included several hardcoded paths. This
becomes unwieldy as there are more users for which these paths are
insufficient. For most targets, cmake uses include_directories() and
the INCLUDE_DIRECTORIES directory property to specify include paths.
This change picks up the INCLUDE_DIRECTORIES property and adds it
to the include path used when running tablegen. As a side effect, this
allows us to remove several hard coded paths to tablegen that are redundant
with specified include_directories().

I haven't removed the hardcoded path to CMAKE_CURRENT_SOURCE_DIR, which
seems generically useful. There are several users in clang which apparently
don't have the current directory as an include_directories(). This could
be considered separately.

The new version of this path uses list APPEND rather than list TRANSFORM,
in order to be compatible with cmake 3.4.3. If we update to cmake 3.12 then
we can use list TRANSFORM instead.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMar 31 2020, 11:55 AM
mehdi_amini accepted this revision.Apr 1 2020, 10:56 PM
This revision is now accepted and ready to land.Apr 1 2020, 10:56 PM
This revision was automatically updated to reflect the committed changes.
stephenneuendorffer edited the summary of this revision. (Show Details)
beanz added a subscriber: beanz.Apr 20 2020, 11:37 AM

I'm not sure this is actually the right approach. Adding the directory's INCLUDE_DIRECTORIES option also adds any path added with include_directories, which includes system paths and other locations that shouldn't ever have tablegen files.