]>
Commit | Line | Data |
---|---|---|
f22341db | 1 | # - Check whether the CXX compiler supports a given flag. |
2 | # CHECK_CXX_COMPILER_FLAG(<flag> <var>) | |
3 | # <flag> - the compiler flag | |
4 | # <var> - variable to store the result | |
5 | # This internally calls the check_cxx_source_compiles macro. See help | |
6 | # for CheckCXXSourceCompiles for a listing of variables that can | |
7 | # modify the build. | |
8 | ||
9 | #============================================================================= | |
10 | # Copyright 2006-2009 Kitware, Inc. | |
11 | # Copyright 2006 Alexander Neundorf <neundorf@kde.org> | |
12 | # Copyright 2011 Matthias Kretz <kretz@kde.org> | |
13 | # | |
14 | # Distributed under the OSI-approved BSD License (the "License"); | |
15 | # see accompanying file Copyright.txt for details. | |
16 | # | |
17 | # This software is distributed WITHOUT ANY WARRANTY; without even the | |
18 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
19 | # See the License for more information. | |
20 | #============================================================================= | |
21 | # (To distributed this file outside of CMake, substitute the full | |
22 | # License text for the above reference.) | |
23 | ||
24 | INCLUDE(CheckCXXSourceCompiles) | |
25 | ||
26 | MACRO (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT) | |
27 | SET(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") | |
28 | SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}") | |
29 | CHECK_CXX_SOURCE_COMPILES("int main() { return 0;}" ${_RESULT} | |
30 | # Some compilers do not fail with a bad flag | |
31 | FAIL_REGEX "argument unused during compilation" # clang | |
32 | FAIL_REGEX "is valid for .* but not for C\\\\+\\\\+" # GNU | |
33 | FAIL_REGEX "unrecognized .*option" # GNU | |
34 | FAIL_REGEX "ignoring unknown option" # MSVC | |
35 | FAIL_REGEX "[Uu]nknown option" # HP | |
36 | FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro | |
37 | FAIL_REGEX "command option .* is not recognized" # XL | |
38 | FAIL_REGEX "WARNING: unknown flag:" # Open64 | |
39 | FAIL_REGEX " #10159: " # ICC | |
40 | ) | |
41 | SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") | |
42 | ENDMACRO (CHECK_CXX_COMPILER_FLAG) | |
43 |