diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -748,8 +748,12 @@ endif() # Turn on -gsplit-dwarf if requested -if(LLVM_USE_SPLIT_DWARF) - add_definitions("-gsplit-dwarf") +if (LLVM_USE_SPLIT_DWARF) + # Limit to clang and gcc so far. Add compilers supporting this option. + if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR + CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + add_compile_options($<$,$>:-gsplit-dwarf>) + endif() endif() add_definitions( -D__STDC_CONSTANT_MACROS )