brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 4809520 Raw
64 lines · plain
1if (NOT COMMAND append_if)2  # From HandleLLVMOptions.cmake3  function(append_if condition value)4    if (${condition})5      foreach(variable ${ARGN})6        set(${variable} "${${variable}} ${value}" PARENT_SCOPE)7      endforeach(variable)8    endif()9  endfunction()10endif()11 12if (NOT COMMAND append)13  function(append value)14    foreach(variable ${ARGN})15      set(${variable} "${${variable}} ${value}" PARENT_SCOPE)16    endforeach(variable)17  endfunction()18endif()19 20# MSVC and clang-cl in compatibility mode map -Wall to -Weverything.21# TODO: LLVM adds /W4 instead, check if that works for the OpenMP runtimes.22if (NOT MSVC)23  append_if(OPENMP_HAVE_WALL_FLAG "-Wall" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)24endif()25if (OPENMP_ENABLE_WERROR)26  append_if(OPENMP_HAVE_WERROR_FLAG "-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)27endif()28 29append_if(OPENMP_HAVE_COLOR_DIAGNOSTICS "-fcolor-diagnostics" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)30 31# Additional warnings that are not enabled by -Wall.32append_if(OPENMP_HAVE_WCAST_QUAL_FLAG "-Wcast-qual" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)33append_if(OPENMP_HAVE_WFORMAT_PEDANTIC_FLAG "-Wformat-pedantic" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)34append_if(OPENMP_HAVE_WIMPLICIT_FALLTHROUGH_FLAG "-Wimplicit-fallthrough" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)35append_if(OPENMP_HAVE_WSIGN_COMPARE_FLAG "-Wsign-compare" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)36 37# Warnings that we want to disable because they are too verbose or fragile.38 39# GCC silently accepts any -Wno-<foo> option, but warns about those options40# being unrecognized only if the compilation triggers other warnings to be41# printed. Therefore, check for whether the compiler supports options in the42# form -W<foo>, and if supported, add the corresponding -Wno-<foo> option.43 44append_if(OPENMP_HAVE_WEXTRA_FLAG "-Wno-extra" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)45append_if(OPENMP_HAVE_WPEDANTIC_FLAG "-Wno-pedantic" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)46append_if(OPENMP_HAVE_WMAYBE_UNINITIALIZED_FLAG "-Wno-maybe-uninitialized" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)47 48if (NOT (WIN32 OR CYGWIN))49  # This flag is not relevant on Windows; the flag is accepted, but produces warnings50  # about argument unused during compilation.51  append_if(OPENMP_HAVE_NO_SEMANTIC_INTERPOSITION "-fno-semantic-interposition" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)52endif()53append_if(OPENMP_HAVE_FUNCTION_SECTIONS "-ffunction-section" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)54append_if(OPENMP_HAVE_DATA_SECTIONS "-fdata-sections" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)55 56if (MSVC)57  # Disable "warning C4201: nonstandard extension used: nameless struct/union"58  append("-wd4201" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)59  60  # Disable "warning C4190: '__kmpc_atomic_cmplx8_rd' has C-linkage specified, but returns61  # UDT '__kmp_cmplx64_t' which is incompatible with C"62  append("-wd4190" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)63endif()64