This is an archive of the discontinued LLVM Phabricator instance.

[docs] [CMake] Change recommendations for how to use LLVM_DEFINITIONS
ClosedPublic

Authored by mstorsjo on May 24 2021, 1:28 PM.

Details

Summary

LLVM_DEFINITIONS is a string variable containing a list of arguments
to pass to the compiler. When CMake's add_definitions is passed a
string variable, this is interpreted as one argument. To make it
behave properly, the string variable needs to be split into a list.

Despite the fact that add_definitions isn't supposed to be used like
the LLVM docs recommended, it worked fine in practice in many cases.
If the first argument in LLVM_DEFINITIONS is of the form -DFOO=42
instead of plain -DFOO, the rest of the string is treated as value
to this define. I.e. if LLVM_DEFINITIONS consists of -DFOO=42 -DBAR,
CMake ended up passing -DFOO="42 -DBAR" to the compiler.

See https://gitlab.kitware.com/cmake/cmakissues/22162
for discussion on the matter.

Changing LLVM_DEFINITIONS to be a list variable would possibly be
more disruptive; instead keep the variable defined as before but
change the recommendation for how to use it. Then projects using it
can gradually be updated to follow the new recommendation.

Diff Detail

Event Timeline

mstorsjo created this revision.May 24 2021, 1:28 PM
mstorsjo requested review of this revision.May 24 2021, 1:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2021, 1:28 PM
phosek accepted this revision.May 24 2021, 4:07 PM

LGTM

This revision is now accepted and ready to land.May 24 2021, 4:07 PM
This revision was landed with ongoing or failed builds.May 25 2021, 1:04 PM
This revision was automatically updated to reflect the committed changes.