mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-12 13:30:51 +00:00
Made llvm_replace_compiler_option more robust. Use it on
llvm_process_sources. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123232 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b9505f6bed
commit
927d8aee53
@ -1,15 +1,22 @@
|
||||
include(AddFileDependencies)
|
||||
|
||||
macro(llvm_replace_compiler_option var old new)
|
||||
function(llvm_replace_compiler_option var old new)
|
||||
# Replaces a compiler option or switch `old' in `var' by `new'.
|
||||
# If `old' is not in `var', appends `new' to `var'.
|
||||
# Example: llvm_replace_compiler_option(CMAKE_CXX_FLAGS_RELEASE "-O3" "-O2")
|
||||
if( "${${var}}" MATCHES "(^| )${old}($| )" )
|
||||
string( REGEX REPLACE "(^| )${old}($| )" " ${new} " ${var} "${${var}}" )
|
||||
# If the option already is on the variable, don't add it:
|
||||
if( "${${var}}" MATCHES "(^| )${new}($| )" )
|
||||
set(n "")
|
||||
else()
|
||||
set( ${var} "${${var}} ${new}" )
|
||||
set(n "${new}")
|
||||
endif()
|
||||
endmacro(llvm_replace_compiler_option)
|
||||
if( "${${var}}" MATCHES "(^| )${old}($| )" )
|
||||
string( REGEX REPLACE "(^| )${old}($| )" " ${n} " ${var} "${${var}}" )
|
||||
else()
|
||||
set( ${var} "${${var}} ${n}" )
|
||||
endif()
|
||||
set( ${var} "${${var}}" PARENT_SCOPE )
|
||||
endfunction(llvm_replace_compiler_option)
|
||||
|
||||
macro(add_td_sources srcs)
|
||||
file(GLOB tds *.td)
|
||||
@ -52,15 +59,15 @@ function(llvm_process_sources OUT_VAR)
|
||||
if( CMAKE_COMPILER_IS_GNUCXX )
|
||||
add_definitions( -fno-exceptions )
|
||||
elseif( MSVC )
|
||||
string( REGEX REPLACE "[ ^]/EHsc ?" " /EHs-c- " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
|
||||
llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/EHsc" "/EHs-c-")
|
||||
add_definitions( /D_HAS_EXCEPTIONS=0 )
|
||||
endif()
|
||||
endif()
|
||||
if( NOT LLVM_REQUIRES_RTTI )
|
||||
if( CMAKE_COMPILER_IS_GNUCXX )
|
||||
add_definitions( -fno-rtti )
|
||||
llvm_replace_compiler_option(CMAKE_CXX_FLAGS "-frtti" "-fno-rtti")
|
||||
elseif( MSVC )
|
||||
string( REGEX REPLACE "[ ^]/GR ?" " /GR- " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )
|
||||
llvm_replace_compiler_option(CMAKE_CXX_FLAGS "/GR" "/GR-")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user