]> git.uio.no Git - u/mrichter/AliRoot.git/blame - Vc/cmake/CheckCXXCompilerFlag.cmake
update to Vc 0.7.3-dev
[u/mrichter/AliRoot.git] / Vc / cmake / CheckCXXCompilerFlag.cmake
CommitLineData
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>
c017a39f 12# Copyright 2011-2013 Matthias Kretz <kretz@kde.org>
f22341db 13#
c017a39f 14# Redistribution and use in source and binary forms, with or without
15# modification, are permitted provided that the following conditions are
16# met:
f22341db 17#
c017a39f 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.
f22341db 40#=============================================================================
f22341db 41
42INCLUDE(CheckCXXSourceCompiles)
43
44MACRO (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT)
45 SET(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
46 SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
c017a39f 47 if(${ARGC} GREATER 2)
48 SET(TEST_SOURCE "${ARGV2}")
49 else()
50 SET(TEST_SOURCE "int main() { return 0;}")
51 endif()
52 CHECK_CXX_SOURCE_COMPILES("${TEST_SOURCE}" ${_RESULT}
f22341db 53 # Some compilers do not fail with a bad flag
23a11150 54 FAIL_REGEX "error: bad value (.*) for .* switch" # GNU
f22341db 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
c017a39f 58 FAIL_REGEX "ignored for target" # GNU
f22341db 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 )
66 SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
67ENDMACRO (CHECK_CXX_COMPILER_FLAG)
68