brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.5 KiB · 16aed02 Raw
113 lines · plain
1# HandleLibcxxFlags - A set of macros used to setup the flags used to compile2# and link libc++abi. These macros add flags to the following CMake variables.3# - LIBCXXABI_COMPILE_FLAGS: flags used to compile libc++abi4# - LIBCXXABI_LINK_FLAGS: flags used to link libc++abi5# - LIBCXXABI_LIBRARIES: libraries to link libc++abi to.6 7include(CheckCXXCompilerFlag)8include(HandleFlags)9 10unset(add_flag_if_supported)11 12# Add a specified list of flags to both 'LIBCXXABI_COMPILE_FLAGS' and13# 'LIBCXXABI_LINK_FLAGS'.14macro(add_flags)15  foreach(value ${ARGN})16    list(APPEND LIBCXXABI_COMPILE_FLAGS ${value})17    list(APPEND LIBCXXABI_LINK_FLAGS ${value})18  endforeach()19endmacro()20 21# If the specified 'condition' is true then add a list of flags to both22# 'LIBCXXABI_COMPILE_FLAGS' and 'LIBCXXABI_LINK_FLAGS'.23macro(add_flags_if condition)24  if (${condition})25    add_flags(${ARGN})26  endif()27endmacro()28 29# Add each flag in the list to LIBCXXABI_COMPILE_FLAGS and LIBCXXABI_LINK_FLAGS30# if that flag is supported by the current compiler.31macro(add_flags_if_supported)32  foreach(flag ${ARGN})33      mangle_name("${flag}" flagname)34      check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")35      add_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})36  endforeach()37endmacro()38 39# Add a list of flags to 'LIBCXXABI_COMPILE_FLAGS'.40macro(add_compile_flags)41  foreach(f ${ARGN})42    list(APPEND LIBCXXABI_COMPILE_FLAGS ${f})43  endforeach()44endmacro()45 46# If 'condition' is true then add the specified list of flags to47# 'LIBCXXABI_COMPILE_FLAGS'48macro(add_compile_flags_if condition)49  if (${condition})50    add_compile_flags(${ARGN})51  endif()52endmacro()53 54# For each specified flag, add that flag to 'LIBCXXABI_COMPILE_FLAGS' if the55# flag is supported by the C++ compiler.56macro(add_compile_flags_if_supported)57  foreach(flag ${ARGN})58      mangle_name("${flag}" flagname)59      check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")60      add_compile_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})61  endforeach()62endmacro()63 64# For each specified flag, add that flag to 'LIBCXXABI_COMPILE_FLAGS' if the65# flag is supported by the C compiler.66macro(add_c_compile_flags_if_supported)67  foreach(flag ${ARGN})68      mangle_name("${flag}" flagname)69      check_c_compiler_flag("${flag}" "C_SUPPORTS_${flagname}_FLAG")70      add_compile_flags_if(C_SUPPORTS_${flagname}_FLAG ${flag})71  endforeach()72endmacro()73 74# Add a list of flags to 'LIBCXXABI_LINK_FLAGS'.75macro(add_link_flags)76  foreach(f ${ARGN})77    list(APPEND LIBCXXABI_LINK_FLAGS ${f})78  endforeach()79endmacro()80 81# If 'condition' is true then add the specified list of flags to82# 'LIBCXXABI_LINK_FLAGS'83macro(add_link_flags_if condition)84  if (${condition})85    add_link_flags(${ARGN})86  endif()87endmacro()88 89# For each specified flag, add that flag to 'LIBCXXABI_LINK_FLAGS' if the90# flag is supported by the C++ compiler.91macro(add_link_flags_if_supported)92  foreach(flag ${ARGN})93    mangle_name("${flag}" flagname)94    check_cxx_compiler_flag("${flag}" "CXX_SUPPORTS_${flagname}_FLAG")95    add_link_flags_if(CXX_SUPPORTS_${flagname}_FLAG ${flag})96  endforeach()97endmacro()98 99# Add a list of libraries or link flags to 'LIBCXXABI_LIBRARIES'.100macro(add_library_flags)101  foreach(lib ${ARGN})102    list(APPEND LIBCXXABI_LIBRARIES ${lib})103  endforeach()104endmacro()105 106# if 'condition' is true then add the specified list of libraries and flags107# to 'LIBCXXABI_LIBRARIES'.108macro(add_library_flags_if condition)109  if(${condition})110    add_library_flags(${ARGN})111  endif()112endmacro()113