2013-01-19 00:05:21 +08:00
|
|
|
# Because compiler-rt spends a lot of time setting up custom compile flags,
|
|
|
|
# define a handy helper function for it. The compile flags setting in CMake
|
|
|
|
# has serious issues that make its syntax challenging at best.
|
|
|
|
function(set_target_compile_flags target)
|
|
|
|
foreach(arg ${ARGN})
|
|
|
|
set(argstring "${argstring} ${arg}")
|
|
|
|
endforeach()
|
|
|
|
set_property(TARGET ${target} PROPERTY COMPILE_FLAGS "${argstring}")
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(set_target_link_flags target)
|
|
|
|
foreach(arg ${ARGN})
|
|
|
|
set(argstring "${argstring} ${arg}")
|
|
|
|
endforeach()
|
|
|
|
set_property(TARGET ${target} PROPERTY LINK_FLAGS "${argstring}")
|
|
|
|
endfunction()
|
|
|
|
|
2013-02-08 15:39:25 +08:00
|
|
|
# Check if a given flag is present in a space-separated flag_string.
|
|
|
|
# Store the result in out_var.
|
|
|
|
function(find_flag_in_string flag_string flag out_var)
|
2014-02-19 15:49:16 +08:00
|
|
|
string(REPLACE " " ";" flag_list "${flag_string}")
|
2013-02-08 15:39:25 +08:00
|
|
|
list(FIND flag_list ${flag} flag_pos)
|
|
|
|
if(NOT flag_pos EQUAL -1)
|
|
|
|
set(${out_var} TRUE PARENT_SCOPE)
|
|
|
|
else()
|
|
|
|
set(${out_var} FALSE PARENT_SCOPE)
|
|
|
|
endif()
|
|
|
|
endfunction()
|
2013-10-26 07:03:34 +08:00
|
|
|
|
|
|
|
# Set the variable var_PYBOOL to True if var holds a true-ish string,
|
|
|
|
# otherwise set it to False.
|
|
|
|
macro(pythonize_bool var)
|
|
|
|
if (${var})
|
|
|
|
set(${var}_PYBOOL True)
|
|
|
|
else()
|
|
|
|
set(${var}_PYBOOL False)
|
|
|
|
endif()
|
|
|
|
endmacro()
|
2014-02-18 15:52:40 +08:00
|
|
|
|
2014-03-13 17:31:36 +08:00
|
|
|
# Appends value to all lists in ARGN, if the condition is true.
|
|
|
|
macro(append_if condition value)
|
|
|
|
if(${condition})
|
|
|
|
foreach(list ${ARGN})
|
|
|
|
list(APPEND ${list} ${value})
|
|
|
|
endforeach()
|
2014-02-18 15:52:40 +08:00
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2014-03-13 19:31:10 +08:00
|
|
|
# Appends value to all strings in ARGN, if the condition is true.
|
|
|
|
macro(append_string_if condition value)
|
|
|
|
if(${condition})
|
|
|
|
foreach(str ${ARGN})
|
|
|
|
set(${str} "${${str}} ${value}")
|
|
|
|
endforeach()
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
2014-02-18 15:52:40 +08:00
|
|
|
macro(append_no_rtti_flag list)
|
2014-03-13 17:31:36 +08:00
|
|
|
append_if(COMPILER_RT_HAS_FNO_RTTI_FLAG -fno-rtti ${list})
|
|
|
|
append_if(COMPILER_RT_HAS_GR_FLAG /GR- ${list})
|
2014-02-18 15:52:40 +08:00
|
|
|
endmacro()
|