Skip to content

Commit 052580c

Browse files
committed
[CMake] respect LLVMConfig.cmake's LLVM_DEFINITIONS
In llvm#138329, _GNU_SOURCE was added for Cygwin, but when building Clang standalone against an installed LLVM this definition was not picked up, resulting in undefined strnlen. Follow the documentation in https://llvm.org/docs/CMake.html#developing-llvm-passes-out-of-source and add the LLVM_DEFINITIONS in standalone projects' cmakes.
1 parent 864f0ff commit 052580c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

clang/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ if(CLANG_BUILT_STANDALONE)
6868
option(CLANG_ENABLE_BOOTSTRAP "Generate the clang bootstrap target" OFF)
6969
option(LLVM_ENABLE_LIBXML2 "Use libxml2 if available." ON)
7070

71+
separate_arguments(LLVM_DEFINITIONS_LIST NATIVE_COMMAND ${LLVM_DEFINITIONS})
72+
add_definitions(${LLVM_DEFINITIONS_LIST})
73+
list(APPEND CMAKE_REQUIRED_DEFINITIONS ${LLVM_DEFINITIONS_LIST})
74+
7175
include(AddLLVM)
7276
include(TableGen)
7377
include(HandleLLVMOptions)

0 commit comments

Comments
 (0)