[cmake] Fix LLVM_USE_SPLIT_DWARF

Summary:
- Add `-gsplit-dwarf` as an option instead of a definition.
- Only add that option on compilers supporting dwarf splitting, such as clang
  and gcc.

Reviewers: echristo, pcc

Subscribers: mgorny, aprantl, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D75328
This commit is contained in:
Michael Liao 2020-02-28 00:01:08 -05:00
parent a1f3eb2085
commit 1a52d3d47b

View file

@ -746,9 +746,15 @@ if(LLVM_USE_SANITIZER)
endif()
endif()
# Turn on -gsplit-dwarf if requested
if(LLVM_USE_SPLIT_DWARF)
add_definitions("-gsplit-dwarf")
# Turn on -gsplit-dwarf if requested in debug builds.
if (LLVM_USE_SPLIT_DWARF AND
((uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") OR
(uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")))
# 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 )