diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -5,12 +5,7 @@ include(DetermineGCCCompatible) function(llvm_update_compile_flags name) - get_property(sources TARGET ${name} PROPERTY SOURCES) - if("${sources}" MATCHES "\\.c(;|$)") - set(update_src_props ON) - endif() - - list(APPEND LLVM_COMPILE_CFLAGS " ${LLVM_COMPILE_FLAGS}") + target_compile_options(${name} PRIVATE ${LLVM_COMPILE_FLAGS}) # LLVM_REQUIRES_EH is an internal flag that individual targets can use to # force EH @@ -54,31 +49,8 @@ list(APPEND LLVM_COMPILE_FLAGS "/GR") endif() - # Assume that; - # - LLVM_COMPILE_FLAGS is list. - # - PROPERTY COMPILE_FLAGS is string. - string(REPLACE ";" " " target_compile_flags " ${LLVM_COMPILE_FLAGS}") - string(REPLACE ";" " " target_compile_cflags " ${LLVM_COMPILE_CFLAGS}") - - if(update_src_props) - foreach(fn ${sources}) - get_filename_component(suf ${fn} EXT) - if("${suf}" STREQUAL ".cpp") - set_property(SOURCE ${fn} APPEND_STRING PROPERTY - COMPILE_FLAGS "${target_compile_flags}") - endif() - if("${suf}" STREQUAL ".c") - set_property(SOURCE ${fn} APPEND_STRING PROPERTY - COMPILE_FLAGS "${target_compile_cflags}") - endif() - endforeach() - else() - # Update target props, since all sources are C++. - set_property(TARGET ${name} APPEND_STRING PROPERTY - COMPILE_FLAGS "${target_compile_flags}") - endif() - - set_property(TARGET ${name} APPEND PROPERTY COMPILE_DEFINITIONS ${LLVM_COMPILE_DEFINITIONS}) + target_compile_options(${name} PRIVATE $<$:${LLVM_COMPILE_FLAGS}>) + target_compile_definitions(${name} PRIVATE ${LLVM_COMPILE_DEFINITIONS}) endfunction() function(add_llvm_symbol_exports target_name export_file)