Skip to content

Commit 5a35e9f

Browse files
mstorsjotkrasnukha
authored andcommitted
[CMake] Split LLVM_DEFINITIONS before adding them
add_definitions is meant to take multiple definitions in the form of a parameter that is a list. LLVM_DEFINITIONS is a string variable though. In practice, passing a string variable to add_definitions mostly works, except for the case when it starts with not only a plain -DFOO, but a define with a value, i.e. -DFOO=42. In the case of LLVM_DEFINITIONS starting with `-DFOO=42 -DBAR`, cmake ends up passing `-DFOO="42 -DBAR"` to the compiler, which isn't what was intended. See https://gitlab.kitware.com/cmake/cmake/-/issues/22162 for discussions on the matter. This matches the recently updated docs for how users of LLVM are supposed to use LLVM_DEFINITIONS in CMake, see llvm/llvm-project@a2a65a5.
1 parent 87e3901 commit 5a35e9f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ if(LLVM_BUILD_MAIN_SRC_DIR)
2727
include_directories(${LLVM_BUILD_BINARY_DIR}/tools/lldb/include)
2828
endif()
2929

30-
add_definitions(${LLVM_DEFINITIONS})
30+
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
31+
add_definitions(${LLVM_DEFINITIONS_LIST})
3132

3233
if (NOT LLVM_ENABLE_EH)
3334
if(LLVM_COMPILER_IS_GCC_COMPATIBLE)

0 commit comments

Comments
 (0)