2016-02-11 17:54:30 +01:00
|
|
|
# Convenience function that checks the availability
|
2016-02-16 14:57:05 +01:00
|
|
|
# of certain C or C++ compiler flags and appends valid ones.
|
2016-02-11 17:54:30 +01:00
|
|
|
|
|
|
|
include(CheckCCompilerFlag)
|
|
|
|
include(CheckCXXCompilerFlag)
|
|
|
|
|
|
|
|
function(extract_valid_c_flags varname)
|
|
|
|
foreach(flag IN LISTS ARGN)
|
2016-02-11 22:15:46 +01:00
|
|
|
string(REGEX REPLACE "[^a-zA-Z0-9_]+" "_" flag_var ${flag})
|
2016-02-11 17:54:30 +01:00
|
|
|
set(flag_var "C_FLAG_${flag_var}")
|
|
|
|
check_c_compiler_flag("${flag}" "${flag_var}")
|
|
|
|
if(${flag_var})
|
|
|
|
set(valid_flags "${valid_flags} ${flag}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
set(${varname} "${valid_flags}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(extract_valid_cxx_flags varname)
|
|
|
|
foreach(flag IN LISTS ARGN)
|
2016-02-11 22:15:46 +01:00
|
|
|
string(REGEX REPLACE "[^a-zA-Z0-9_]+" "_" flag_var ${flag})
|
2016-02-11 17:54:30 +01:00
|
|
|
set(flag_var "CXX_FLAG_${flag_var}")
|
|
|
|
check_cxx_compiler_flag("${flag}" "${flag_var}")
|
|
|
|
if(${flag_var})
|
|
|
|
set(valid_flags "${valid_flags} ${flag}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
set(${varname} "${valid_flags}" PARENT_SCOPE)
|
|
|
|
endfunction()
|