forked from OSchip/llvm-project
[docs] [CMake] Change recommendations for how to use LLVM_DEFINITIONS
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. Differential Revision: https://reviews.llvm.org/D103044
This commit is contained in:
parent
6a2869cf1e
commit
a2a65a5bae
|
@ -770,7 +770,8 @@ and uses them to build a simple application ``simple-tool``.
|
|||
# for your compiler.
|
||||
|
||||
include_directories(${LLVM_INCLUDE_DIRS})
|
||||
add_definitions(${LLVM_DEFINITIONS})
|
||||
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
|
||||
add_definitions(${LLVM_DEFINITIONS_LIST})
|
||||
|
||||
# Now build our tools
|
||||
add_executable(simple-tool tool.cpp)
|
||||
|
@ -870,7 +871,8 @@ Contents of ``<project dir>/CMakeLists.txt``:
|
|||
|
||||
find_package(LLVM REQUIRED CONFIG)
|
||||
|
||||
add_definitions(${LLVM_DEFINITIONS})
|
||||
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
|
||||
add_definitions(${LLVM_DEFINITIONS_LIST})
|
||||
include_directories(${LLVM_INCLUDE_DIRS})
|
||||
|
||||
add_subdirectory(<pass name>)
|
||||
|
|
Loading…
Reference in New Issue