]> git.uio.no Git - u/mrichter/AliRoot.git/blob - Vc/cmake/CheckCCompilerFlag.cmake
The default cuts are now for PbPb (Maximiliano)
[u/mrichter/AliRoot.git] / Vc / cmake / CheckCCompilerFlag.cmake
1 # - Check whether the C compiler supports a given flag.
2 # CHECK_C_COMPILER_FLAG(<flag> <var>)
3 #  <flag> - the compiler flag
4 #  <var>  - variable to store the result
5 # This internally calls the check_c_source_compiles macro.
6 # See help for CheckCSourceCompiles for a listing of variables
7 # that can modify the build.
8
9 #=============================================================================
10 # Copyright 2006-2009 Kitware, Inc.
11 # Copyright 2006 Alexander Neundorf <neundorf@kde.org>
12 # Copyright 2011-2013 Matthias Kretz <kretz@kde.org>
13 #
14 # Redistribution and use in source and binary forms, with or without
15 # modification, are permitted provided that the following conditions are
16 # met:
17 #
18 #  * Redistributions of source code must retain the above copyright notice,
19 #    this list of conditions and the following disclaimer.
20 #
21 #  * Redistributions in binary form must reproduce the above copyright notice,
22 #    this list of conditions and the following disclaimer in the documentation
23 #    and/or other materials provided with the distribution.
24 #
25 #  * The names of Kitware, Inc., the Insight Consortium, or the names of
26 #    any consortium members, or of any contributors, may not be used to
27 #    endorse or promote products derived from this software without
28 #    specific prior written permission.
29 #
30 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS''
31 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
34 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
36 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
37 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
38 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 #=============================================================================
41
42 INCLUDE(CheckCSourceCompiles)
43
44 MACRO (CHECK_C_COMPILER_FLAG _FLAG _RESULT)
45    SET(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
46    SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
47    if(${ARGC} GREATER 2)
48       SET(TEST_SOURCE "${ARGV2}")
49    else()
50       SET(TEST_SOURCE "int main() { return 0;}")
51    endif()
52    CHECK_C_SOURCE_COMPILES("${TEST_SOURCE}" ${_RESULT}
53      # Some compilers do not fail with a bad flag
54      FAIL_REGEX "error: bad value (.*) for .* switch"       # GNU
55      FAIL_REGEX "argument unused during compilation"        # clang
56      FAIL_REGEX "is valid for .* but not for C"             # GNU
57      FAIL_REGEX "unrecognized .*option"                     # GNU
58      FAIL_REGEX "ignored for target"                        # GNU
59      FAIL_REGEX "ignoring unknown option"                   # MSVC
60      FAIL_REGEX "[Uu]nknown option"                         # HP
61      FAIL_REGEX "[Ww]arning: [Oo]ption"                     # SunPro
62      FAIL_REGEX "command option .* is not recognized"       # XL
63      FAIL_REGEX "WARNING: unknown flag:"                    # Open64
64      FAIL_REGEX " #10159: "                                 # ICC
65      FAIL_REGEX " #10353: "                                 # ICC: option '-mfma' ignored, suggest using '-march=core-avx2'
66      )
67    SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
68 ENDMACRO (CHECK_C_COMPILER_FLAG)
69