summaryrefslogtreecommitdiff
path: root/cmake/Modules/CompilerRTUtils.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/Modules/CompilerRTUtils.cmake')
-rw-r--r--cmake/Modules/CompilerRTUtils.cmake37
1 files changed, 25 insertions, 12 deletions
diff --git a/cmake/Modules/CompilerRTUtils.cmake b/cmake/Modules/CompilerRTUtils.cmake
index fce37e3eb49a7..ae59732928a1c 100644
--- a/cmake/Modules/CompilerRTUtils.cmake
+++ b/cmake/Modules/CompilerRTUtils.cmake
@@ -2,6 +2,7 @@
# 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)
+ set(argstring "")
foreach(arg ${ARGN})
set(argstring "${argstring} ${arg}")
endforeach()
@@ -9,24 +10,13 @@ function(set_target_compile_flags target)
endfunction()
function(set_target_link_flags target)
+ set(argstring "")
foreach(arg ${ARGN})
set(argstring "${argstring} ${arg}")
endforeach()
set_property(TARGET ${target} PROPERTY LINK_FLAGS "${argstring}")
endfunction()
-# 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)
- string(REPLACE " " ";" flag_list ${flag_string})
- 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()
-
# Set the variable var_PYBOOL to True if var holds a true-ish string,
# otherwise set it to False.
macro(pythonize_bool var)
@@ -36,3 +26,26 @@ macro(pythonize_bool var)
set(${var}_PYBOOL False)
endif()
endmacro()
+
+# Appends value to all lists in ARGN, if the condition is true.
+macro(append_list_if condition value)
+ if(${condition})
+ foreach(list ${ARGN})
+ list(APPEND ${list} ${value})
+ endforeach()
+ endif()
+endmacro()
+
+# 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()
+
+macro(append_no_rtti_flag list)
+ append_list_if(COMPILER_RT_HAS_FNO_RTTI_FLAG -fno-rtti ${list})
+ append_list_if(COMPILER_RT_HAS_GR_FLAG /GR- ${list})
+endmacro()