2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2009,2010,2011,2012,2013 by the GROMACS development team.
5 # Copyright (c) 2014,2015,2016,2017,2018 by the GROMACS development team.
6 # Copyright (c) 2019,2020, by the GROMACS development team, led by
7 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8 # and including many others, as listed in the AUTHORS file in the
9 # top-level source directory and at http://www.gromacs.org.
11 # GROMACS is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU Lesser General Public License
13 # as published by the Free Software Foundation; either version 2.1
14 # of the License, or (at your option) any later version.
16 # GROMACS is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 # Lesser General Public License for more details.
21 # You should have received a copy of the GNU Lesser General Public
22 # License along with GROMACS; if not, see
23 # http://www.gnu.org/licenses, or write to the Free Software Foundation,
24 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 # If you want to redistribute modifications to GROMACS, please
27 # consider that scientific software is very special. Version
28 # control is crucial - bugs must be traceable. We will be happy to
29 # consider code for inclusion in the official distribution, but
30 # derived work must not be called official GROMACS. Details are found
31 # in the README & COPYING files - if they are missing, get the
32 # official version at http://www.gromacs.org.
34 # To help us fund GROMACS development, we humbly ask that you cite
35 # the research papers on the package. Check out http://www.gromacs.org.
37 # Test C flags FLAGS, and set VARIABLE to true if the work. Also add the
39 MACRO(GMX_TEST_CFLAG VARIABLE FLAGS CFLAGSVAR)
40 IF(NOT DEFINED ${VARIABLE})
41 CHECK_C_COMPILER_FLAG("${FLAGS}" ${VARIABLE})
44 list(APPEND ${CFLAGSVAR} "${FLAGS}")
46 ENDMACRO(GMX_TEST_CFLAG VARIABLE FLAGS CFLAGSVAR)
48 # Test C++ flags FLAGS, and set VARIABLE to true if the work. Also add the
49 # flags to CXXFLAGSVAR.
50 MACRO(GMX_TEST_CXXFLAG VARIABLE FLAGS CXXFLAGSVAR)
51 IF(NOT DEFINED ${VARIABLE})
52 CHECK_CXX_COMPILER_FLAG("${FLAGS}" ${VARIABLE})
55 list(APPEND ${CXXFLAGSVAR} "${FLAGS}")
57 ENDMACRO(GMX_TEST_CXXFLAG VARIABLE FLAGS CXXFLAGSVAR)
59 # Prepare some local variables so CUDA and non-CUDA code in targets
61 function(gmx_target_compile_options_inner)
62 set (CFLAGS "${SIMD_C_FLAGS};${MPI_COMPILE_FLAGS};${EXTRA_C_FLAGS};${GMXC_CFLAGS}" PARENT_SCOPE)
63 set (CXXFLAGS "${SIMD_CXX_FLAGS};${MPI_COMPILE_FLAGS};${EXTRA_CXX_FLAGS};${GMXC_CXXFLAGS}" PARENT_SCOPE)
66 # Implementation function to add compiler flags expected for all
67 # GROMACS build configurations, and those expected for the current
68 # CMake build type (e.g. Release) to TARGET. Other GROMACS CMake code
69 # is expected to use either gmx_target_compile_options(name_of_target)
70 # or gmx_cuda_target_compile_options(name_of_variable) because CUDA
71 # compilation has special requirements.
73 # Most targets (ie. libraries, executables) need compiler flags that
74 # are characteristic of the build configuration. This function
75 # provides a central point for adding such flags. This approach is
76 # more flexible than e.g. setting CMAKE_CXX_FLAGS globally, because
77 # that setting will apply globally, which means it applies also to
78 # "external" code that the build of GROMACS might also build.
79 function(gmx_target_compile_options TARGET)
80 if (GMX_SKIP_DEFAULT_CFLAGS)
84 # Prepare the generic compiler options
85 gmx_target_compile_options_inner()
86 target_compile_options(${TARGET}
88 $<$<COMPILE_LANGUAGE:C>:${CFLAGS}>
89 $<$<COMPILE_LANGUAGE:CXX>:${CXXFLAGS}>
91 # Add compiler options for the build types
92 foreach(build_type ${build_types_with_explicit_flags})
93 target_compile_options(${TARGET}
95 $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:${build_type}>>:${GMXC_CFLAGS_${build_type}}>
96 $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:${build_type}>>:${GMXC_CXXFLAGS_${build_type}}>
99 # Add the release-configuration compiler options to build
100 # configurations that derive from it.
101 foreach(build_type RELWITHDEBINFO RELWITHASSERT MINSIZEREL PROFILE)
102 target_compile_options(${TARGET}
104 $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:${build_type}>>:${GMXC_CFLAGS_RELEASE}>
105 $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:${build_type}>>:${GMXC_CXXFLAGS_RELEASE}>
108 # Add those flags that we only want in the proper release build
110 target_compile_options(${TARGET}
112 $<$<AND:$<COMPILE_LANGUAGE:C>,$<CONFIG:RELEASE>>:${GMXC_CFLAGS_RELEASE_ONLY}>
113 $<$<AND:$<COMPILE_LANGUAGE:CXX>,$<CONFIG:RELEASE>>:${GMXC_CXXFLAGS_RELEASE_ONLY}>
117 # The approach taken by FindCUDA.cmake is to require that the compiler
118 # flags are known and present in a variable before creating the target
119 # for the library. (Those get embedded in files that are generated at
120 # the point of calling cuda_add_library, which does not create a
121 # target that one could later call target_compile_options upon.) So,
122 # this function instead returns appropriate content in
123 # ${VARIABLE_NAME}, along with other such variables that are
124 # specialized for the various build_types. Hopefully this will improve
125 # when we use native CUDA language support in our CMake.
126 function(gmx_cuda_target_compile_options VARIABLE_NAME)
127 if (GMX_SKIP_DEFAULT_CFLAGS)
130 # Prepare the generic compiler options
131 gmx_target_compile_options_inner()
132 # CUDA headers issue lots of warnings when compiled with
133 # -Wundef because they use old-style #ifdef a lot. We'd prefer
134 # to have FindCUDA.cmake treat CUDA internal headers with
135 # -isystem so that these warnings are naturally suppressed,
136 # but there's no way to do that without bundling a modified
137 # form of FindCUDA.cmake. That creates its own problems,
138 # because people either don't know we do that, or don't
139 # remember that we don't do that in user tarballs.
141 # We have make check-source ensuring that we have included
142 # config.h any time we use such symbols in commits in a merge
143 # request. Local development could run that too. So, we can
144 # tolerate any remaining risk from accidentally using
145 # e.g. #ifdef GMX_MPI rather than #if GMX_MPI in CUDA source
148 # So we disable -Wundef by the simple hack of appending
149 # -Wno-undef after it. That's more maintainable than having
150 # logic to avoid adding -Wundef to GMXC_CXXFLAGS, given the
151 # current approach to adding them. Hopefully this will improve
152 # if/when we have more CMake object libraries, and/or native
154 GMX_TEST_CXXFLAG(CXXFLAGS_WARN_NOUNDEF "-Wno-undef" CXXFLAGS)
157 # Only C++ compilation is supported with CUDA code in GROMACS
158 set(${VARIABLE_NAME} ${CXXFLAGS} PARENT_SCOPE)
160 # Now organize the flags for different build
161 # configurations. First, the debug configuration.
162 set(${VARIABLE_NAME}_DEBUG "${GMXC_CXXFLAGS_DEBUG}" PARENT_SCOPE)
163 # Add those flags that we only want in the proper release build
165 set(${VARIABLE_NAME}_RELEASE "${GMXC_CXXFLAGS_RELEASE};${GMXC_CXXFLAGS_RELEASE_ONLY}" PARENT_SCOPE)
166 # Add the release flags to build configurations that derive from it
167 foreach(build_type RELWITHDEBINFO RELWITHASSERT MINSIZEREL PROFILE)
168 set(${VARIABLE_NAME}_${build_type} "${GMXC_CXXFLAGS_RELEASE};${GMXC_CXXFLAGS_${build_type}}" PARENT_SCOPE)
172 # Add the WARNING_FLAG to the compile options for TARGET if the
173 # compiler supports that flag. VARNAME is used to cache the result of
174 # the check whether the compiler supports that flag, as multiple
175 # targets may use the same suppression.
177 # This is generally used to suppress warnings judged not worth fixing
178 # in code external to, or generated by, GROMACS, or code that is
179 # more efficient to work around and later replace, rather than fix.
180 function(gmx_target_warning_suppression TARGET WARNING_FLAG VARNAME)
181 check_cxx_compiler_flag(${WARNING_FLAG} ${VARNAME})
183 target_compile_options(${TARGET} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${WARNING_FLAG}>)
187 # Add the WARNING_FLAG to the compile flags for SOURCE_FILE if the
188 # compiler supports that flag. VARNAME is used to cache the result of
189 # the check whether the compiler supports that flag, as multiple
190 # targets may use the same suppression.
192 # This is generally used to suppress warnings judged not worth fixing
193 # in code external to, or generated by, GROMACS, or code that is
194 # more efficient to work around and later replace, rather than fix.
195 function(gmx_source_file_warning_suppression SOURCE_FILE WARNING_FLAG VARNAME)
196 check_cxx_compiler_flag(${WARNING_FLAG} ${VARNAME})
198 set_source_files_properties(${SOURCE_FILE} PROPERTIES COMPILE_FLAGS ${WARNING_FLAG})
202 # This is the actual exported function to be called
205 include(CheckCCompilerFlag)
206 include(CheckCXXCompilerFlag)
209 if(CMAKE_COMPILER_IS_GNUCC)
210 #flags are added in reverse order and -Wno* need to appear after -Wall
212 GMX_TEST_CFLAG(CFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CFLAGS)
214 if (GMX_COMPILER_WARNINGS)
215 GMX_TEST_CFLAG(CFLAGS_WARN "-Wall;-Wno-unused;-Wunused-value;-Wunused-parameter" GMXC_CFLAGS)
216 GMX_TEST_CFLAG(CFLAGS_WARN_EXTRA "-Wextra;-Wno-sign-compare;-Wpointer-arith" GMXC_CFLAGS)
217 GMX_TEST_CFLAG(CFLAGS_WARN_UNDEF "-Wundef" GMXC_CFLAGS)
218 GMX_TEST_CFLAG(CFLAGS_WARN_REL "-Wno-array-bounds" GMXC_CFLAGS_RELEASE_ONLY)
220 GMX_TEST_CFLAG(CFLAGS_WARN_SUBSCRIPT "-Wno-char-subscripts" GMXC_CFLAGS)
222 GMX_TEST_CFLAG(CFLAGS_STRINGOP_TRUNCATION "-Werror=stringop-truncation" GMXC_CFLAGS)
224 GMX_TEST_CFLAG(CFLAGS_WARN_NO_MISSING_FIELD_INITIALIZERS "-Wno-missing-field-initializers" GMXC_CFLAGS)
226 GMX_TEST_CFLAG(CFLAGS_EXCESS_PREC "-fexcess-precision=fast" GMXC_CFLAGS_RELEASE)
227 GMX_TEST_CFLAG(CFLAGS_COPT "-funroll-all-loops"
229 GMX_TEST_CFLAG(CFLAGS_NOINLINE "-fno-inline" GMXC_CFLAGS_DEBUG)
232 if(CMAKE_COMPILER_IS_GNUCXX)
234 GMX_TEST_CXXFLAG(CXXFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CXXFLAGS)
236 if (GMX_COMPILER_WARNINGS)
237 GMX_TEST_CXXFLAG(CXXFLAGS_WARN "-Wall" GMXC_CXXFLAGS)
238 # Problematic with CUDA
239 # GMX_TEST_CXXFLAG(CXXFLAGS_WARN_EFFCXX "-Wnon-virtual-dtor" GMXC_CXXFLAGS)
240 GMX_TEST_CXXFLAG(CXXFLAGS_WARN_EXTRA "-Wextra;-Wpointer-arith;-Wmissing-declarations" GMXC_CXXFLAGS)
241 GMX_TEST_CXXFLAG(CXXFLAGS_WARN_UNDEF "-Wundef" GMXC_CXXFLAGS)
242 GMX_TEST_CFLAG(CXXFLAGS_WARN_REL "-Wno-array-bounds" GMXC_CXXFLAGS_RELEASE_ONLY)
243 GMX_TEST_CXXFLAG(CXXFLAGS_STRINGOP_TRUNCATION "-Wstringop-truncation" GMXC_CXXFLAGS)
244 if (CXXFLAGS_STRINGOP_TRUNCATION)
245 set(CXXFLAGS_NO_STRINGOP_TRUNCATION "-Wno-stringop-truncation")
248 GMX_TEST_CXXFLAG(CXXFLAGS_WARN_NO_MISSING_FIELD_INITIALIZERS "-Wno-missing-field-initializers" GMXC_CXXFLAGS)
250 GMX_TEST_CXXFLAG(CXXFLAGS_EXCESS_PREC "-fexcess-precision=fast" GMXC_CXXFLAGS_RELEASE)
251 GMX_TEST_CXXFLAG(CXXFLAGS_COPT "-funroll-all-loops"
252 GMXC_CXXFLAGS_RELEASE)
253 GMX_TEST_CXXFLAG(CXXFLAGS_NOINLINE "-fno-inline" GMXC_CXXFLAGS_DEBUG)
257 if (CMAKE_C_COMPILER_ID MATCHES "Intel")
260 # 3180: unrecognized OpenMP #pragma
261 GMX_TEST_CFLAG(CFLAGS_PRAGMA "-wd3180" GMXC_CFLAGS)
263 if (GMX_COMPILER_WARNINGS)
264 # -w3 enables a lot of useful diagnostics but we don't care about all. -wd disables some selectively.
265 # 177: function/variable ".." was declared but never referenced
266 # 280: selector expression is constant
267 # 411: class defines no constructor to initialize the following (incorrect for struct, initializer list works)
268 # 593: variable ".." was set but never used
269 # 981: operands are evaluated in unspecified order
270 #1418: external function definition with no prior declaration
271 #1419: external declaration in primary source file
272 #1572: floating-point equality and inequality comparisons are unreliable
273 #1599: declaration hides variable ".."
274 #2259: non-pointer conversion from ".." to ".." may lose significant bits
275 #2415: variable ".." of static storage duration was declared but never referenced
276 #2547: ".." was specified as both a system and non-system include directory
277 #2557: comparison between signed and unsigned operands
278 #3280: declaration hides member ".."
279 #11074: Inlining inhibited by limit max-size(/max-total-size)
280 #11076: To get full report use -opt-report=3 -opt-report-phase ipo (shown for previous remark)
281 GMX_TEST_CFLAG(CFLAGS_WARN "-w3;-wd177;-wd280;-wd411;-wd593;-wd981;-wd1418;-wd1419;-wd1572;-wd1599;-wd2259;-wd2415;-wd2547;-wd2557;-wd3280;-wd11074;-wd11076" GMXC_CFLAGS)
283 GMX_TEST_CFLAG(CFLAGS_STDGNU "-std=gnu99" GMXC_CFLAGS)
284 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)
285 GMX_TEST_CFLAG(CFLAGS_DEBUG "-O0" GMXC_CFLAGS_DEBUG) #icc defaults to -O2 even with -g
286 # The "except" fp-model requires something other than the
287 # default "fast" model, so we test and use it with
289 GMX_TEST_CFLAG(CFLAGS_FP_MODEL_RELASSERT "-fp-model=except;-fp-model=precise" GMXC_CFLAGS_RELWITHASSERT)
292 GMX_TEST_CFLAG(CFLAGS_PRAGMA "/wd3180" GMXC_CFLAGS)
294 if (GMX_COMPILER_WARNINGS)
296 #161: unrecognized pragma
297 #1786 function was declared deprecated (is issued for stdlib function such as strncpy which have a _s version)
298 GMX_TEST_CFLAG(CFLAGS_WARN "/W3;/wd161;/wd177;/wd411;/wd593;/wd981;/wd1418;/wd1419;/wd1572;/wd1599;/wd1786;/wd2259;/wd2415;/wd2547;/wd2557;/wd3280" GMXC_CFLAGS)
300 GMX_TEST_CFLAG(CFLAGS_OPT "/Qip" GMXC_CFLAGS_RELEASE)
304 if (CMAKE_CXX_COMPILER_ID MATCHES "Intel")
307 GMX_TEST_CXXFLAG(CXXFLAGS_PRAGMA "-wd3180" GMXC_CXXFLAGS)
309 if (GMX_COMPILER_WARNINGS)
310 #All but the following warnings are identical for the C-compiler (see above)
311 # 304: access control not specified
312 # 383: value copied to temporary, reference to temporary used
313 # 444: destructor for base class ".." is not virtual
314 # 869: was never referenced (false positives)
315 #2282: unrecognized GCC pragma
316 GMX_TEST_CXXFLAG(CXXFLAGS_WARN "-w3;-wd177;-wd280;-wd304;-wd383;-wd411;-wd444;-wd869;-wd981;-wd1418;-wd1572;-wd1599;-wd2259;-wd2547;-wd3280;-wd11074;-wd11076;-wd2282" GMXC_CXXFLAGS)
318 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)
319 GMX_TEST_CXXFLAG(CXXFLAGS_DEBUG "-O0" GMXC_CXXFLAGS_DEBUG)
320 # The "except" fp-model requires something other than the
321 # default "fast" model, so we test and use it with
323 GMX_TEST_CXXFLAG(CXXFLAGS_FP_MODEL_RELASSERT "-fp-model=except;-fp-model=precise" GMXC_CXXFLAGS_RELWITHASSERT)
326 GMX_TEST_CXXFLAG(CXXFLAGS_PRAGMA "/wd3180" GMXC_CFLAGS)
328 if (GMX_COMPILER_WARNINGS)
329 #161: unrecognized pragma
330 #809: exception specification for virtual function X is incompatible with that of overridden function
331 GMX_TEST_CXXFLAG(CXXFLAGS_WARN "/W3;/wd161;/wd177;/wd280;/wd304;/wd383;/wd411;/wd444;/wd809;/wd869;/wd981;/wd1418;/wd1572;/wd1599;/wd1786;/wd2259;/wd2547;/wd3280;/wd11074;/wd11076;/wd2282" GMXC_CXXFLAGS)
333 GMX_TEST_CXXFLAG(CXXFLAGS_OPT "/Qip" GMXC_CXXFLAGS_RELEASE)
338 # Inter-procedural analysis causes pgcc/pgc++ to crash when linking the library with PGI release 15.7.
339 if (CMAKE_C_COMPILER_ID MATCHES "PGI")
340 GMX_TEST_CFLAG(CFLAGS_OPT "-Mnoipa" GMXC_CFLAGS_RELEASE)
342 if (CMAKE_CXX_COMPILER_ID MATCHES "PGI")
343 # Using ipa exposes internal PGI-15.7 compiler bugs at compile time
344 GMX_TEST_CXXFLAG(CXXFLAGS_OPT "-Mnoipa" GMXC_CXXFLAGS_RELEASE)
345 # PGI identifies itself as GCC, but does not understand the GCC
346 # pragmas that occur in parser.cpp. Since that file is generated
347 # we cannot add a define there, but supress the warning instead.
348 GMX_TEST_CXXFLAG(CXXFLAGS_WARN "--diag_suppress=1675" GMXC_CXXFLAGS)
352 if (CMAKE_C_COMPILER_ID MATCHES "PathScale")
354 GMX_TEST_CFLAG(CFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CFLAGS)
356 if (GMX_COMPILER_WARNINGS)
357 GMX_TEST_CFLAG(CFLAGS_WARN "-Wall;-Wno-unused;-Wunused-value" GMXC_CFLAGS)
359 GMX_TEST_CFLAG(CFLAGS_OPT "-OPT:Ofast;-fno-math-errno;-ffast-math"
361 GMX_TEST_CFLAG(CFLAGS_LANG "-std=gnu99" GMXC_CFLAGS)
363 if (CMAKE_CXX_COMPILER_ID MATCHES "PathScale")
365 GMX_TEST_CXXFLAG(CXXFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CXXFLAGS)
367 if (GMX_COMPILER_WARNINGS)
368 GMX_TEST_CXXFLAG(CXXFLAGS_WARN "-Wall;-Wno-unused;-Wunused-value" GMXC_CXXFLAGS)
370 GMX_TEST_CXXFLAG(CXXFLAGS_OPT "-OPT:Ofast;-fno-math-errno;-ffast-math"
371 GMXC_CXXFLAGS_RELEASE)
375 # The suppressions below stop
376 # 1500-036: (I) about -O3 causing non-strict IEEE compliance that changes the semantics of the program (duh)
377 # 1500-010: (W) about correct PBC-related use of maximum array indices of DIM-sized C arrays
378 # 1500-030: (I) Additional optimization may be attained by recompiling and specifying MAXMEM option with a value greater than 8192.
379 if (CMAKE_C_COMPILER_ID MATCHES "XL")
380 GMX_TEST_CFLAG(CFLAGS_ARCH "-qarch=auto;-qtune=auto" GMXC_CFLAGS)
381 GMX_TEST_CFLAG(CFLAGS_OPT "-O3" GMXC_CFLAGS_RELEASE)
382 GMX_TEST_CFLAG(CFLAGS_LANG "-qlanglvl=extc99" GMXC_CFLAGS)
383 GMX_TEST_CFLAG(CFLAGS_LANG "-qsuppress=1500-036;-qsuppress=1500-010;-qsuppress=1500-030" GMXC_CFLAGS)
385 if (CMAKE_CXX_COMPILER_ID MATCHES "XL")
386 GMX_TEST_CXXFLAG(CXXFLAGS_ARCH "-qarch=auto;-qtune=auto" GMXC_CXXFLAGS)
387 GMX_TEST_CXXFLAG(CXXFLAGS_OPT "-O3" GMXC_CXXFLAGS_RELEASE)
388 GMX_TEST_CXXFLAG(CXXFLAGS_LANG "-qsuppress=1500-036;-qsuppress=1500-010;-qsuppress=1500-030" GMXC_CXXFLAGS)
393 # disable warnings for:
394 # forcing value to bool
395 # "this" in initializer list
396 # deprecated (posix, secure) functions
397 # C4305: truncation (double -> float)
398 # C4244: conversion from '.*' to '.*', possible loss of data
399 # unreferenced local variable (only C)
400 # C4267: conversion from 'size_t' to 'int', possible loss of data
401 # conversion from 'const char*' to 'void*', different 'const' qualifiers (only C)
402 # unknown pragma (4068)
403 # remark #280: selector expression is constant
404 if(NOT CMAKE_CONFIGURATION_TYPES)
405 GMX_TEST_CFLAG(CFLAGS_WARN "/wd4800;/wd4355;/wd4996;/wd4305;/wd4244;/wd4101;/wd4267;/wd4090;/wd4068;" GMXC_CFLAGS)
406 GMX_TEST_CXXFLAG(CXXFLAGS_WARN "/wd4800;/wd4355;/wd4996;/wd4305;/wd4244;/wd4267;/wd4068;" GMXC_CXXFLAGS)
407 else() # MSVC projects only use the C++ flags
408 GMX_TEST_CXXFLAG(CXXFLAGS_WARN "/wd4800;/wd4355;/wd4996;/wd4305;/wd4244;/wd4101;/wd4267;/wd4090;/wd4068;" GMXC_CXXFLAGS)
412 if (CMAKE_C_COMPILER_ID MATCHES "Clang")
414 GMX_TEST_CFLAG(CFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CFLAGS)
416 if (GMX_COMPILER_WARNINGS)
417 GMX_TEST_CFLAG(CFLAGS_WARN "-Wall;-Wno-unused;-Wunused-value;-Wunused-parameter" GMXC_CFLAGS)
418 GMX_TEST_CFLAG(CFLAGS_WARN_EXTRA "-Wpointer-arith" GMXC_CFLAGS_EXTRA)
420 GMX_TEST_CFLAG(CFLAGS_WARN_NO_MISSING_FIELD_INITIALIZERS "-Wno-missing-field-initializers" GMXC_CFLAGS)
423 if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
424 if (GMX_COMPILER_WARNINGS)
425 # If used, -Wall should precede other options that silence warnings it enables
426 GMX_TEST_CXXFLAG(CXXFLAGS_WARN "-Wall" GMXC_CXXFLAGS)
427 if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0") #LLVM BUG #21629
428 GMX_TEST_CXXFLAG(CXXFLAGS_WARN_NO_BRACES "-Wno-missing-braces" GMXC_CXXFLAGS)
430 GMX_TEST_CXXFLAG(CXXFLAGS_WARN_EXTRA "-Wextra;-Wpointer-arith;-Wmissing-prototypes" GMXC_CXXFLAGS)
431 GMX_TEST_CXXFLAG(CXXFLAGS_DEPRECATED "-Wdeprecated" GMXC_CXXFLAGS)
432 # Functions placed in headers for inlining are not always
433 # used in every translation unit that includes the files,
434 # so we must disable the warning that there are such
435 # functions that are unused.
436 GMX_TEST_CXXFLAG(CXXFLAGS_NO_UNUSED_FUNCTION "-Wno-unused-function" GMXC_CXXFLAGS)
439 GMX_TEST_CXXFLAG(CXXFLAGS_PRAGMA "-Wno-unknown-pragmas" GMXC_CXXFLAGS)
442 # CUDA header cuda_runtime_api.h in at least CUDA 10.1
443 # uses 0 where nullptr would be preferable, and this is
444 # the simplest way to avoid seeing it when it can't be
446 GMX_TEST_CXXFLAG(CXXFLAGS_PRAGMA "-Wno-zero-as-null-pointer-constant" GMXC_CXXFLAGS)
448 GMX_TEST_CXXFLAG(CXXFLAGS_WARN_NO_MISSING_FIELD_INITIALIZERS "-Wno-missing-field-initializers" GMXC_CXXFLAGS)
451 # Apple bastardized version of Clang
452 if(${CMAKE_C_COMPILER_ID} MATCHES "AppleClang")
453 if(${CMAKE_C_COMPILER_VERSION} VERSION_GREATER 11.0)
454 # Mac OS Catalina ships with a horribly broken compiler (version 11.0.0.11000033)
455 # that checks stack alignment by default, but their own C library
456 # does not align the stack properly. Embarrassing, Apple...
457 GMX_TEST_CFLAG(CFLAG_NO_STACK_CHECK "-fno-stack-check" GMXC_CFLAGS)
461 if(${CMAKE_CXX_COMPILER_ID} MATCHES "AppleClang")
462 if(${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 11.0)
463 # Mac OS Catalina ships with a horribly broken compiler (version 11.0.0.11000033)
464 # that checks stack alignment by default, but their own C library
465 # does not align the stack properly. Embarrassing, Apple...
466 GMX_TEST_CXXFLAG(CXXFLAG_NO_STACK_CHECK "-fno-stack-check" GMXC_CXXFLAGS)
470 # Apple bastardized version of Clang
471 if(${CMAKE_C_COMPILER_ID} MATCHES "AppleClang")
472 if(${CMAKE_C_COMPILER_VERSION} VERSION_GREATER 11.0)
473 # Mac OS Catalina ships with a horribly broken compiler (version 11.0.0.11000033)
474 # that checks stack alignment by default, but their own C library
475 # does not align the stack properly. Embarrassing, Apple...
476 GMX_TEST_CFLAG(CFLAG_NO_STACK_CHECK "-fno-stack-check" GMXC_CFLAGS)
480 if(${CMAKE_CXX_COMPILER_ID} MATCHES "AppleClang")
481 if(${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER 11.0)
482 # Mac OS Catalina ships with a horribly broken compiler (version 11.0.0.11000033)
483 # that checks stack alignment by default, but their own C library
484 # does not align the stack properly. Embarrassing, Apple...
485 GMX_TEST_CXXFLAG(CXXFLAG_NO_STACK_CHECK "-fno-stack-check" GMXC_CXXFLAGS)
489 # Fujitsu compilers on PrimeHPC/Sparc64
490 if(${CMAKE_C_COMPILER_ID} MATCHES Fujitsu OR
491 (${CMAKE_C_COMPILER_ID} MATCHES unknown AND ${CMAKE_C_COMPILER} MATCHES ^fcc))
492 GMX_TEST_CFLAG(CFLAG_GNUCOMPAT "-Xg;-w" GMXC_CFLAGS)
493 GMX_TEST_CFLAG(CFLAG_OPT "-Kfast,reduction,swp,simd=2,uxsimd,fsimple;-x100" GMXC_CFLAGS)
496 if(${CMAKE_CXX_COMPILER_ID} MATCHES Fujitsu OR
497 (${CMAKE_CXX_COMPILER_ID} MATCHES unknown AND ${CMAKE_CXX_COMPILER} MATCHES ^FCC))
498 GMX_TEST_CXXFLAG(CXXFLAG_GNUCOMPAT "-Xg;-w" GMXC_CXXFLAGS)
499 GMX_TEST_CXXFLAG(CXXFLAG_OPT "-Kfast,reduction,swp,simd=2,uxsimd,fsimple;-x100" GMXC_CXXFLAGS)