aboutsummaryrefslogtreecommitdiff
path: root/cmake/AddCompilerFlag.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/AddCompilerFlag.cmake')
-rw-r--r--cmake/AddCompilerFlag.cmake12
1 files changed, 12 insertions, 0 deletions
diff --git a/cmake/AddCompilerFlag.cmake b/cmake/AddCompilerFlag.cmake
new file mode 100644
index 00000000000..5310b5982bc
--- /dev/null
+++ b/cmake/AddCompilerFlag.cmake
@@ -0,0 +1,12 @@
+include (CheckCXXCompilerFlag)
+macro(AddCompilerFlag _flag)
+ string(REGEX REPLACE "[/:= ]" "_" _flag_esc "${_flag}")
+ check_cxx_compiler_flag("${_flag}" check_compiler_flag_${_flag_esc})
+ if(check_compiler_flag_${_flag_esc})
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_flag}")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_flag}")
+ endif(check_compiler_flag_${_flag_esc})
+ if(${ARGC} EQUAL 2)
+ set(${ARGV1} "${check_compiler_flag_${_flag_esc}}")
+ endif(${ARGC} EQUAL 2)
+endmacro(AddCompilerFlag)