Fix message about incorrect usage of dihedral type 9
[alexxy/gromacs.git] / cmake / CheckCXXCompilerFlag.cmake
1 #
2 # This file is part of the GROMACS molecular simulation package.
3 #
4 # Copyright (c) 2012,2013, by the GROMACS development team, led by
5 # David van der Spoel, Berk Hess, Erik Lindahl, and including many
6 # others, as listed in the AUTHORS file in the top-level source
7 # 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 # - Check whether the CXX compiler supports a given flag.
36 # CHECK_CXX_COMPILER_FLAG(<flag> <var>)
37 #  <flag> - the compiler flag
38 #  <var>  - variable to store the result
39 # This internally calls the check_cxx_source_compiles macro.  See help
40 # for CheckCXXSourceCompiles for a listing of variables that can
41 # modify the build.
42
43 #=============================================================================
44 # Copyright 2006-2010 Kitware, Inc.
45 # Copyright 2006 Alexander Neundorf <neundorf@kde.org>
46 # Copyright 2011 Matthias Kretz <kretz@kde.org>
47 #
48 # ORIGINAL Copyright notice (from Copyright.txt):
49 #
50 # CMake - Cross Platform Makefile Generator
51 # Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
52 # All rights reserved.
53
54 # Redistribution and use in source and binary forms, with or without
55 # modification, are permitted provided that the following conditions
56 # are met:
57
58 # * Redistributions of source code must retain the above copyright
59 #   notice, this list of conditions and the following disclaimer.
60
61 # * Redistributions in binary form must reproduce the above copyright
62 #   notice, this list of conditions and the following disclaimer in the
63 #   documentation and/or other materials provided with the distribution.
64 #
65 # * Neither the names of Kitware, Inc., the Insight Software Consortium,
66 #   nor the names of their contributors may be used to endorse or promote
67 #   products derived from this software without specific prior written
68 #   permission.
69
70 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
71 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
72 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
73 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
74 # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
75 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
76 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
77 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
78 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
79 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
80 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
81 #=============================================================================
82
83 INCLUDE(CheckCXXSourceCompiles)
84
85 MACRO (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT)
86    SET(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
87    SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
88    CHECK_CXX_SOURCE_COMPILES("int main() { return 0;}" ${_RESULT}
89      # Some compilers do not fail with a bad flag
90      FAIL_REGEX "command line option .* is valid for .* but not for C\\\\+\\\\+" # GNU
91      FAIL_REGEX "unrecognized .*option"                     # GNU
92      FAIL_REGEX "unknown .*option"                          # Clang
93      FAIL_REGEX "ignoring unknown option"                   # MSVC
94      FAIL_REGEX "warning D9002"                             # MSVC, any lang
95      FAIL_REGEX "option.*not supported"                     # Intel
96      FAIL_REGEX "invalid argument .*option"                 # Intel
97      FAIL_REGEX "ignoring option .*argument required"       # Intel
98      FAIL_REGEX "[Uu]nknown option"                         # HP
99      FAIL_REGEX "[Ww]arning: [Oo]ption"                     # SunPro
100      FAIL_REGEX "command option .* is not recognized"       # XL
101      FAIL_REGEX "not supported in this configuration; ignored"       # AIX
102      FAIL_REGEX "File with unknown suffix passed to linker" # PGI
103      FAIL_REGEX "WARNING: unknown flag:"                    # Open64
104      )
105    SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
106 ENDMACRO (CHECK_CXX_COMPILER_FLAG)
107