Merge branch release-2019
[alexxy/gromacs.git] / cmake / gmxCFlags.cmake
1 #
2 # This file is part of the GROMACS molecular simulation package.
3 #
4 # Copyright (c) 2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
5 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 # and including many others, as listed in the AUTHORS file in the
7 # top-level source directory and at http://www.gromacs.org.
8 #
9 # GROMACS is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public License
11 # as published by the Free Software Foundation; either version 2.1
12 # of the License, or (at your option) any later version.
13 #
14 # GROMACS is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 # Lesser General Public License for more details.
18 #
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with GROMACS; if not, see
21 # http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
23 #
24 # If you want to redistribute modifications to GROMACS, please
25 # consider that scientific software is very special. Version
26 # control is crucial - bugs must be traceable. We will be happy to
27 # consider code for inclusion in the official distribution, but
28 # derived work must not be called official GROMACS. Details are found
29 # in the README & COPYING files - if they are missing, get the
30 # official version at http://www.gromacs.org.
31 #
32 # To help us fund GROMACS development, we humbly ask that you cite
33 # the research papers on the package. Check out http://www.gromacs.org.
34
35 # Test C flags FLAGS, and set VARIABLE to true if the work. Also add the
36 # flags to CFLAGSVAR.
37 MACRO(GMX_TEST_CFLAG VARIABLE FLAGS CFLAGSVAR)
38     IF(NOT DEFINED ${VARIABLE})
39         CHECK_C_COMPILER_FLAG("${FLAGS}" ${VARIABLE})
40     ENDIF()
41     IF (${VARIABLE})
42         list(APPEND ${CFLAGSVAR} "${FLAGS}")
43     ENDIF ()
44 ENDMACRO(GMX_TEST_CFLAG VARIABLE FLAGS CFLAGSVAR)
45
46 # Test C++ flags FLAGS, and set VARIABLE to true if the work. Also add the
47 # flags to CXXFLAGSVAR.
48 MACRO(GMX_TEST_CXXFLAG VARIABLE FLAGS CXXFLAGSVAR)
49     IF(NOT DEFINED ${VARIABLE})
50         CHECK_CXX_COMPILER_FLAG("${FLAGS}" ${VARIABLE})
51     ENDIF()
52     IF (${VARIABLE})
53         list(APPEND ${CXXFLAGSVAR} "${FLAGS}")
54     ENDIF ()
55 ENDMACRO(GMX_TEST_CXXFLAG VARIABLE FLAGS CXXFLAGSVAR)
56
57 # Set the real CMake variables for compiler flags. This should be a function
58 # so we can have proper local variables while avoiding duplicating code.
59 function(gmx_set_cmake_compiler_flags)
60     foreach(language C CXX)
61         # Copy the flags for the release build type to the build types
62         # that are modified forms of it. Ideally, the list of build
63         # types that are modifications of the Release build type would
64         # be set up elsewhere and passed to this function, but it is
65         # inconvenient in CMake to pass more than one list, and such a
66         # list is only used here.
67         foreach(build_type RELWITHDEBINFO RELWITHASSERT MINSIZEREL PROFILE)
68             set(GMXC_${language}FLAGS_${build_type} "${GMXC_${language}FLAGS_RELEASE}" "${GMXC_${language}FLAGS_${build_type}}")
69         endforeach()
70         # Copy the flags that are only used by the real Release build
71         # type. Used for, e.g., -Wno-array-bounds in Release to work around
72         # gcc-4.8 being a little too vocal about some perfectly good code,
73         # while using RelWithAssert (ie. without that suppression) in Jenkins.
74         #
75         # TODO check the behaviour of more recent gcc on the improved code
76         set(GMXC_${language}FLAGS_RELEASE "${GMXC_${language}FLAGS_RELEASE}" "${GMXC_${language}FLAGS_RELEASE_ONLY}")
77     endforeach()
78 endfunction()
79
80 # Add compiler flags expected for all GROMACS build configurations,
81 # and those expected for the current CMake build type (e.g. Release)
82 # to TARGET.
83 #
84 # Most targets (ie. libraries, executables) need compiler flags that
85 # are characteristic of the build configuration. This function
86 # provides a central point for adding such flags. This approach is
87 # more flexible than e.g. setting CMAKE_CXX_FLAGS globally, because
88 # that setting will apply globally, which means it applies also to
89 # "external" code that the build of GROMACS might also build.
90 function(gmx_target_compile_options TARGET)
91     if (NOT GMX_SKIP_DEFAULT_CFLAGS)
92         target_compile_options(${TARGET}
93             PRIVATE
94             $<$<COMPILE_LANGUAGE:C>:${SIMD_C_FLAGS};${MPI_COMPILE_FLAGS};${EXTRA_C_FLAGS};${GMXC_CFLAGS}>
95             $<$<COMPILE_LANGUAGE:CXX>:${SIMD_CXX_FLAGS};${MPI_COMPILE_FLAGS};${EXTRA_CXX_FLAGS};${GMXC_CXXFLAGS}>
96             )
97         foreach(build_type ${build_types_with_explicit_flags})
98             target_compile_options(${TARGET}
99                 BEFORE PRIVATE
100                 $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:${build_type}>>:${GMXC_CFLAGS_${build_type}}>
101                 $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:${build_type}>>:${GMXC_CXXFLAGS_${build_type}}>
102                 )
103         endforeach()
104     endif()
105 endfunction()
106
107 # Add the WARNING_FLAG to the compile options for TARGET if the
108 # compiler supports that flag. VARNAME is used to cache the result of
109 # the check whether the compiler supports that flag, as multiple
110 # targets may use the same suppression.
111 #
112 # This is generally used to suppress warnings judged not worth fixing
113 # in code external to, or generated by, GROMACS, or code that is
114 # more efficient to work around and later replace, rather than fix.
115 function(gmx_target_warning_suppression TARGET WARNING_FLAG VARNAME)
116     check_cxx_compiler_flag(${WARNING_FLAG} ${VARNAME})
117     if(${VARNAME})
118         target_compile_options(${TARGET} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${WARNING_FLAG}>)
119     endif()
120 endfunction()
121
122 # Add the WARNING_FLAG to the compile flags for SOURCE_FILE if the
123 # compiler supports that flag. VARNAME is used to cache the result of
124 # the check whether the compiler supports that flag, as multiple
125 # targets may use the same suppression.
126 #
127 # This is generally used to suppress warnings judged not worth fixing
128 # in code external to, or generated by, GROMACS, or code that is
129 # more efficient to work around and later replace, rather than fix.
130 function(gmx_source_file_warning_suppression SOURCE_FILE WARNING_FLAG VARNAME)
131     check_cxx_compiler_flag(${WARNING_FLAG} ${VARNAME})
132     if(${VARNAME})
133         set_source_files_properties(${SOURCE_FILE} PROPERTIES COMPILE_FLAGS ${WARNING_FLAG})
134     endif()
135 endfunction()
136
137 # This is the actual exported function to be called
138 macro (gmx_c_flags)
139
140     include(CheckCCompilerFlag)
141     include(CheckCXXCompilerFlag)
142
143     # gcc
144     if(CMAKE_COMPILER_IS_GNUCC)
145         #flags are added in reverse order and -Wno* need to appear after -Wall
146         if(NOT GMX_OPENMP)
147             GMX_TEST_CFLAG(CFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CFLAGS)
148         endif()
149         if (GMX_COMPILER_WARNINGS)
150             GMX_TEST_CFLAG(CFLAGS_WARN "-Wall;-Wno-unused;-Wunused-value;-Wunused-parameter" GMXC_CFLAGS)
151             GMX_TEST_CFLAG(CFLAGS_WARN_EXTRA "-Wextra;-Wno-missing-field-initializers;-Wno-sign-compare;-Wpointer-arith" GMXC_CFLAGS)
152             GMX_TEST_CFLAG(CFLAGS_WARN_UNDEF "-Wundef" GMXC_CFLAGS)
153             GMX_TEST_CFLAG(CFLAGS_WARN_REL "-Wno-array-bounds" GMXC_CFLAGS_RELEASE_ONLY)
154             if(CYGWIN)
155                 GMX_TEST_CFLAG(CFLAGS_WARN_SUBSCRIPT "-Wno-char-subscripts" GMXC_CFLAGS)
156             endif()
157             GMX_TEST_CFLAG(CFLAGS_STRINGOP_TRUNCATION "-Werror=stringop-truncation" GMXC_CFLAGS)
158         endif()
159         # new in gcc 4.5
160         GMX_TEST_CFLAG(CFLAGS_EXCESS_PREC "-fexcess-precision=fast" GMXC_CFLAGS_RELEASE)
161         GMX_TEST_CFLAG(CFLAGS_COPT "-funroll-all-loops"
162                        GMXC_CFLAGS_RELEASE)
163         GMX_TEST_CFLAG(CFLAGS_NOINLINE "-fno-inline" GMXC_CFLAGS_DEBUG)
164     endif()
165     # g++
166     if(CMAKE_COMPILER_IS_GNUCXX)
167         if(NOT GMX_OPENMP)
168             GMX_TEST_CXXFLAG(CXXFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CXXFLAGS)
169         endif()
170         if (GMX_COMPILER_WARNINGS)
171             GMX_TEST_CXXFLAG(CXXFLAGS_WARN "-Wall" GMXC_CXXFLAGS)
172             # Problematic with CUDA
173             # GMX_TEST_CXXFLAG(CXXFLAGS_WARN_EFFCXX "-Wnon-virtual-dtor" GMXC_CXXFLAGS)
174             GMX_TEST_CXXFLAG(CXXFLAGS_WARN_EXTRA "-Wextra;-Wno-missing-field-initializers;-Wpointer-arith;-Wmissing-declarations" GMXC_CXXFLAGS)
175             # CUDA versions prior to 7.5 come with a header (math_functions.h) which uses the _MSC_VER macro
176             # unconditionally, so we don't use -Wundef for earlier CUDA versions.
177             if(NOT(GMX_GPU AND CUDA_VERSION VERSION_LESS "7.5"))
178                 GMX_TEST_CXXFLAG(CXXFLAGS_WARN_UNDEF "-Wundef" GMXC_CXXFLAGS)
179             endif()
180             GMX_TEST_CFLAG(CXXFLAGS_WARN_REL "-Wno-array-bounds" GMXC_CXXFLAGS_RELEASE_ONLY)
181             GMX_TEST_CXXFLAG(CXXFLAGS_STRINGOP_TRUNCATION "-Wstringop-truncation" GMXC_CXXFLAGS)
182             if (CXXFLAGS_STRINGOP_TRUNCATION)
183                 set(CXXFLAGS_NO_STRINGOP_TRUNCATION "-Wno-stringop-truncation")
184             endif()
185         endif()
186         # new in gcc 4.5
187         GMX_TEST_CXXFLAG(CXXFLAGS_EXCESS_PREC "-fexcess-precision=fast" GMXC_CXXFLAGS_RELEASE)
188         GMX_TEST_CXXFLAG(CXXFLAGS_COPT "-funroll-all-loops"
189                          GMXC_CXXFLAGS_RELEASE)
190         GMX_TEST_CXXFLAG(CXXFLAGS_NOINLINE "-fno-inline" GMXC_CXXFLAGS_DEBUG)
191     endif()
192
193     # icc
194     if (CMAKE_C_COMPILER_ID MATCHES "Intel")
195         if (NOT WIN32)
196             if(NOT GMX_OPENMP)
197 # 3180: unrecognized OpenMP #pragma
198                 GMX_TEST_CFLAG(CFLAGS_PRAGMA "-wd3180" GMXC_CFLAGS)
199             endif()
200             if (GMX_COMPILER_WARNINGS)
201 # -w3 enables a lot of useful diagnostics but we don't care about all. -wd disables some selectively.
202 # 177: function/variable ".." was declared but never referenced
203 # 411: class defines no constructor to initialize the following (incorrect for struct, initializer list works)
204 # 593: variable ".." was set but never used
205 # 981: operands are evaluated in unspecified order
206 #1418: external function definition with no prior declaration
207 #1419: external declaration in primary source file
208 #1572: floating-point equality and inequality comparisons are unreliable
209 #1599: declaration hides variable ".."
210 #2259: non-pointer conversion from ".." to ".." may lose significant bits
211 #2415: variable ".." of static storage duration was declared but never referenced
212 #2547: ".." was specified as both a system and non-system include directory
213 #2557: comparison between signed and unsigned operands
214 #3280: declaration hides member ".."
215 #11074: Inlining inhibited by limit max-size(/max-total-size)
216 #11076: To get full report use -opt-report=3 -opt-report-phase ipo (shown for previous remark)
217                 GMX_TEST_CFLAG(CFLAGS_WARN "-w3;-wd177;-wd411;-wd593;-wd981;-wd1418;-wd1419;-wd1572;-wd1599;-wd2259;-wd2415;-wd2547;-wd2557;-wd3280;-wd11074;-wd11076" GMXC_CFLAGS)
218             endif()
219             GMX_TEST_CFLAG(CFLAGS_STDGNU "-std=gnu99" GMXC_CFLAGS)
220             GMX_TEST_CFLAG(CFLAGS_OPT "-ip;-funroll-all-loops;-alias-const;-ansi-alias;-no-prec-div;-fimf-domain-exclusion=14;-qoverride-limits" GMXC_CFLAGS_RELEASE)
221             GMX_TEST_CFLAG(CFLAGS_DEBUG "-O0" GMXC_CFLAGS_DEBUG) #icc defaults to -O2 even with -g
222             # The "except" fp-model requires something other than the
223             # default "fast" model, so we test and use it with
224             # "precise".
225             GMX_TEST_CFLAG(CFLAGS_FP_MODEL_RELASSERT "-fp-model=except;-fp-model=precise" GMXC_CFLAGS_RELWITHASSERT)
226         else()
227             if(NOT GMX_OPENMP)
228                 GMX_TEST_CFLAG(CFLAGS_PRAGMA "/wd3180" GMXC_CFLAGS)
229             endif()
230             if (GMX_COMPILER_WARNINGS)
231 #only on Windows
232 #161: unrecognized pragma
233 #1786 function was declared deprecated (is issued for stdlib function such as strncpy which have a _s version)
234 GMX_TEST_CFLAG(CFLAGS_WARN "/W3;/wd161;/wd177;/wd411;/wd593;/wd981;/wd1418;/wd1419;/wd1572;/wd1599;/wd1786;/wd2259;/wd2415;/wd2547;/wd2557;/wd3280" GMXC_CFLAGS)
235             endif()
236             GMX_TEST_CFLAG(CFLAGS_OPT "/Qip" GMXC_CFLAGS_RELEASE)
237         endif()
238     endif()
239
240     if (CMAKE_CXX_COMPILER_ID MATCHES "Intel")
241         if (NOT WIN32) 
242             if(NOT GMX_OPENMP)
243                 GMX_TEST_CXXFLAG(CXXFLAGS_PRAGMA "-wd3180" GMXC_CXXFLAGS)
244             endif()
245             if (GMX_COMPILER_WARNINGS)
246 #All but the following warnings are identical for the C-compiler (see above)
247 # 304: access control not specified
248 # 383: value copied to temporary, reference to temporary used
249 # 444: destructor for base class ".." is not virtual
250 # 869: was never referenced (false positives)
251 #2282: unrecognized GCC pragma
252                 GMX_TEST_CXXFLAG(CXXFLAGS_WARN "-w3;-wd177;-wd304;-wd383;-wd411;-wd444;-wd869;-wd981;-wd1418;-wd1572;-wd1599;-wd2259;-wd2547;-wd3280;-wd11074;-wd11076;-wd2282" GMXC_CXXFLAGS)
253             endif()
254             GMX_TEST_CXXFLAG(CXXFLAGS_OPT "-ip;-funroll-all-loops;-alias-const;-ansi-alias;-no-prec-div;-fimf-domain-exclusion=14;-qoverride-limits" GMXC_CXXFLAGS_RELEASE)
255             GMX_TEST_CXXFLAG(CXXFLAGS_DEBUG "-O0" GMXC_CXXFLAGS_DEBUG)
256             # The "except" fp-model requires something other than the
257             # default "fast" model, so we test and use it with
258             # "precise".
259             GMX_TEST_CXXFLAG(CXXFLAGS_FP_MODEL_RELASSERT "-fp-model=except;-fp-model=precise" GMXC_CXXFLAGS_RELWITHASSERT)
260         else()
261             if(NOT GMX_OPENMP)
262                 GMX_TEST_CXXFLAG(CXXFLAGS_PRAGMA "/wd3180" GMXC_CFLAGS)
263             endif()
264             if (GMX_COMPILER_WARNINGS)
265 #161: unrecognized pragma
266 #809: exception specification for virtual function X is incompatible with that of overridden function
267                 GMX_TEST_CXXFLAG(CXXFLAGS_WARN "/W3;/wd161;/wd177;/wd304;/wd383;/wd411;/wd444;/wd809;/wd869;/wd981;/wd1418;/wd1572;/wd1599;/wd1786;/wd2259;/wd2547;/wd3280;/wd11074;/wd11076;/wd2282" GMXC_CXXFLAGS)
268             endif()
269             GMX_TEST_CXXFLAG(CXXFLAGS_OPT "/Qip" GMXC_CXXFLAGS_RELEASE)
270         endif()
271     endif()
272
273     # PGI
274     # Inter-procedural analysis causes pgcc/pgc++ to crash when linking the library with PGI release 15.7.
275     if (CMAKE_C_COMPILER_ID MATCHES "PGI")
276         GMX_TEST_CFLAG(CFLAGS_OPT "-Mnoipa" GMXC_CFLAGS_RELEASE)
277     endif()
278     if (CMAKE_CXX_COMPILER_ID MATCHES "PGI")
279         # Using ipa exposes internal PGI-15.7 compiler bugs at compile time
280         GMX_TEST_CXXFLAG(CXXFLAGS_OPT "-Mnoipa" GMXC_CXXFLAGS_RELEASE)
281         # PGI identifies itself as GCC, but does not understand the GCC
282         # pragmas that occur in parser.cpp. Since that file is generated
283         # we cannot add a define there, but supress the warning instead.
284         GMX_TEST_CXXFLAG(CXXFLAGS_WARN "--diag_suppress=1675" GMXC_CXXFLAGS)
285     endif()
286
287     # Pathscale
288     if (CMAKE_C_COMPILER_ID MATCHES "PathScale")
289         if(NOT GMX_OPENMP)
290             GMX_TEST_CFLAG(CFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CFLAGS)
291         endif()
292         if (GMX_COMPILER_WARNINGS)
293             GMX_TEST_CFLAG(CFLAGS_WARN "-Wall;-Wno-unused;-Wunused-value" GMXC_CFLAGS)
294         endif()
295         GMX_TEST_CFLAG(CFLAGS_OPT "-OPT:Ofast;-fno-math-errno;-ffast-math"
296                          GMXC_CFLAGS_RELEASE)
297         GMX_TEST_CFLAG(CFLAGS_LANG "-std=gnu99" GMXC_CFLAGS)
298     endif()
299     if (CMAKE_CXX_COMPILER_ID MATCHES "PathScale")
300         if(NOT GMX_OPENMP)
301             GMX_TEST_CXXFLAG(CXXFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CXXFLAGS)
302         endif()
303         if (GMX_COMPILER_WARNINGS)
304             GMX_TEST_CXXFLAG(CXXFLAGS_WARN "-Wall;-Wno-unused;-Wunused-value" GMXC_CXXFLAGS)
305         endif()
306         GMX_TEST_CXXFLAG(CXXFLAGS_OPT "-OPT:Ofast;-fno-math-errno;-ffast-math"
307                          GMXC_CXXFLAGS_RELEASE)
308     endif()
309
310     # xlc
311     # The suppressions below stop
312     # 1500-036: (I) about -O3 causing non-strict IEEE compliance that changes the semantics of the program (duh)
313     # 1500-010: (W) about correct PBC-related use of maximum array indices of DIM-sized C arrays
314     # 1500-030: (I) Additional optimization may be attained by recompiling and specifying MAXMEM option with a value greater than 8192.
315     if (CMAKE_C_COMPILER_ID MATCHES "XL")
316         GMX_TEST_CFLAG(CFLAGS_ARCH "-qarch=auto;-qtune=auto" GMXC_CFLAGS)
317         GMX_TEST_CFLAG(CFLAGS_OPT  "-O3" GMXC_CFLAGS_RELEASE)
318         GMX_TEST_CFLAG(CFLAGS_LANG "-qlanglvl=extc99" GMXC_CFLAGS)
319         GMX_TEST_CFLAG(CFLAGS_LANG "-qsuppress=1500-036;-qsuppress=1500-010;-qsuppress=1500-030" GMXC_CFLAGS)
320     endif()
321     if (CMAKE_CXX_COMPILER_ID MATCHES "XL")
322         GMX_TEST_CXXFLAG(CXXFLAGS_ARCH "-qarch=auto;-qtune=auto" GMXC_CXXFLAGS)
323         GMX_TEST_CXXFLAG(CXXFLAGS_OPT "-O3" GMXC_CXXFLAGS_RELEASE)
324         GMX_TEST_CXXFLAG(CXXFLAGS_LANG "-qsuppress=1500-036;-qsuppress=1500-010;-qsuppress=1500-030" GMXC_CXXFLAGS)
325     endif()
326
327     # msvc
328     if (MSVC)
329         # disable warnings for: 
330         #      forcing value to bool
331         #      "this" in initializer list
332         #      deprecated (posix, secure) functions
333         #      C4305: truncation (double -> float)
334         #      C4244: conversion from 'double' to 'real', possible loss of data
335         #      unreferenced local variable (only C)
336         #      C4267: conversion from 'size_t' to 'int', possible loss of data
337         #      conversion from 'const char*' to 'void*', different 'const' qualifiers (only C)
338         #      unknown pragma (4068)
339         if(NOT CMAKE_CONFIGURATION_TYPES)
340             GMX_TEST_CFLAG(CFLAGS_WARN "/wd4800;/wd4355;/wd4996;/wd4305;/wd4244;/wd4101;/wd4267;/wd4090;/wd4068" GMXC_CFLAGS)
341             GMX_TEST_CXXFLAG(CXXFLAGS_WARN "/wd4800;/wd4355;/wd4996;/wd4305;/wd4244;/wd4267;/wd4068" GMXC_CXXFLAGS)
342         else() # MSVC projects only use the C++ flags
343             GMX_TEST_CXXFLAG(CXXFLAGS_WARN "/wd4800;/wd4355;/wd4996;/wd4305;/wd4244;/wd4101;/wd4267;/wd4090;/wd4068" GMXC_CXXFLAGS)
344         endif()
345     endif()
346
347     if (CMAKE_C_COMPILER_ID MATCHES "Clang")
348         if(NOT GMX_OPENMP)
349             GMX_TEST_CFLAG(CFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CFLAGS)
350         endif()
351         if (GMX_COMPILER_WARNINGS)
352             GMX_TEST_CFLAG(CFLAGS_WARN "-Wall;-Wno-unused;-Wunused-value;-Wunused-parameter" GMXC_CFLAGS)
353             GMX_TEST_CFLAG(CFLAGS_WARN_EXTRA "-Wpointer-arith" GMXC_CFLAGS_EXTRA)
354         endif()
355     endif()
356
357     if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
358         if (GMX_COMPILER_WARNINGS)
359             # If used, -Wall should precede other options that silence warnings it enables
360             GMX_TEST_CXXFLAG(CXXFLAGS_WARN "-Wall" GMXC_CXXFLAGS)
361             if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0") #LLVM BUG #21629
362                 GMX_TEST_CXXFLAG(CXXFLAGS_WARN_NO_BRACES "-Wno-missing-braces" GMXC_CXXFLAGS)
363             endif()
364             GMX_TEST_CXXFLAG(CXXFLAGS_WARN_EXTRA "-Wextra;-Wno-missing-field-initializers;-Wpointer-arith;-Wmissing-prototypes" GMXC_CXXFLAGS)
365             GMX_TEST_CXXFLAG(CXXFLAGS_DEPRECATED "-Wdeprecated" GMXC_CXXFLAGS)
366         endif()
367         if(NOT GMX_OPENMP)
368             GMX_TEST_CXXFLAG(CXXFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CXXFLAGS)
369         endif()
370     endif()
371
372     # Fujitsu compilers on PrimeHPC/Sparc64
373     if(${CMAKE_C_COMPILER_ID} MATCHES Fujitsu OR
374        (${CMAKE_C_COMPILER_ID} MATCHES unknown AND ${CMAKE_C_COMPILER} MATCHES ^fcc))
375         GMX_TEST_CFLAG(CFLAG_GNUCOMPAT "-Xg;-w" GMXC_CFLAGS)
376         GMX_TEST_CFLAG(CFLAG_OPT "-Kfast,reduction,swp,simd=2,uxsimd,fsimple;-x100" GMXC_CFLAGS)
377     endif()
378
379     if(${CMAKE_CXX_COMPILER_ID} MATCHES Fujitsu OR
380        (${CMAKE_CXX_COMPILER_ID} MATCHES unknown AND ${CMAKE_CXX_COMPILER} MATCHES ^FCC))
381         GMX_TEST_CXXFLAG(CXXFLAG_GNUCOMPAT "-Xg;-w" GMXC_CXXFLAGS)
382         GMX_TEST_CXXFLAG(CXXFLAG_OPT "-Kfast,reduction,swp,simd=2,uxsimd,fsimple;-x100" GMXC_CXXFLAGS)
383     endif()
384
385     # now actually set the flags:
386     if (NOT GMX_SKIP_DEFAULT_CFLAGS)
387         gmx_set_cmake_compiler_flags()
388     endif()
389
390 endmacro()