# - Add a given compiler flag to flags variables. # AddCompilerFlag( []) # or # AddCompilerFlag( [C_FLAGS ] [CXX_FLAGS ] [C_RESULT ] # [CXX_RESULT ]) #============================================================================= # SPDX-FileCopyrightText: 2010-2015 Matthias Kretz # SPDX-FileCopyrightText: 2021 L. E. Segovia __m128 foo(__m128 x) { return _mm_fmadd_ps(x, x, x); } int main() { return 0; }") set(_cxx_code "${_c_code}") elseif("${_flag}" STREQUAL "-stdlib=libc++") # Compiling with libc++ not only requires a compiler that understands it, but also # the libc++ headers itself set(_cxx_code "#include #include int main() { return 0; }") else() set(_cxx_code "#include int main() { return 0; }") endif() if(DEFINED _c_result) check_c_compiler_flag("${_flag}" check_c_compiler_flag_${_flag_esc} "${_c_code}") set(${_c_result} ${check_c_compiler_flag_${_flag_esc}}) endif() if(DEFINED _cxx_result) check_cxx_compiler_flag("${_flag}" check_cxx_compiler_flag_${_flag_esc} "${_cxx_code}") set(${_cxx_result} ${check_cxx_compiler_flag_${_flag_esc}}) endif() macro(my_append _list _flag _special) if("x${_list}" STREQUAL "x${_special}") set(${_list} "${${_list}} ${_flag}") else() list(APPEND ${_list} "${_flag}") endif() endmacro() if(check_c_compiler_flag_${_flag_esc} AND DEFINED _c_flags) my_append(${_c_flags} "${_flag}" CMAKE_C_FLAGS) endif() if(check_cxx_compiler_flag_${_flag_esc} AND DEFINED _cxx_flags) my_append(${_cxx_flags} "${_flag}" CMAKE_CXX_FLAGS) endif() endmacro(AddCompilerFlag)