1 if (NOT COMMAND append_if)
2 # From HandleLLVMOptions.cmake
3 function(append_if condition value)
5 foreach(variable ${ARGN})
6 set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
12 if (NOT COMMAND append)
13 function(append value)
14 foreach(variable ${ARGN})
15 set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
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.
23 append_if(OPENMP_HAVE_WALL_FLAG "-Wall" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
25 if (OPENMP_ENABLE_WERROR)
26 append_if(OPENMP_HAVE_WERROR_FLAG "-Werror" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
29 append_if(OPENMP_HAVE_COLOR_DIAGNOSTICS "-fcolor-diagnostics" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
31 # Additional warnings that are not enabled by -Wall.
32 append_if(OPENMP_HAVE_WCAST_QUAL_FLAG "-Wcast-qual" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
33 append_if(OPENMP_HAVE_WFORMAT_PEDANTIC_FLAG "-Wformat-pedantic" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
34 append_if(OPENMP_HAVE_WIMPLICIT_FALLTHROUGH_FLAG "-Wimplicit-fallthrough" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
35 append_if(OPENMP_HAVE_WSIGN_COMPARE_FLAG "-Wsign-compare" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
37 # Warnings that we want to disable because they are too verbose or fragile.
39 # GCC silently accepts any -Wno-<foo> option, but warns about those options
40 # being unrecognized only if the compilation triggers other warnings to be
41 # printed. Therefore, check for whether the compiler supports options in the
42 # form -W<foo>, and if supported, add the corresponding -Wno-<foo> option.
44 append_if(OPENMP_HAVE_WEXTRA_FLAG "-Wno-extra" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
45 append_if(OPENMP_HAVE_WPEDANTIC_FLAG "-Wno-pedantic" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
46 append_if(OPENMP_HAVE_WMAYBE_UNINITIALIZED_FLAG "-Wno-maybe-uninitialized" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
48 if (NOT (WIN32 OR CYGWIN))
49 # This flag is not relevant on Windows; the flag is accepted, but produces warnings
50 # about argument unused during compilation.
51 append_if(OPENMP_HAVE_NO_SEMANTIC_INTERPOSITION "-fno-semantic-interposition" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
53 append_if(OPENMP_HAVE_FUNCTION_SECTIONS "-ffunction-section" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
54 append_if(OPENMP_HAVE_DATA_SECTIONS "-fdata-sections" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
57 # Disable "warning C4201: nonstandard extension used: nameless struct/union"
58 append("-wd4201" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
60 # Disable "warning C4190: '__kmpc_atomic_cmplx8_rd' has C-linkage specified, but returns
61 # UDT '__kmp_cmplx64_t' which is incompatible with C"
62 append("-wd4190" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)