~ubuntu-branches/ubuntu/lucid/cmake/lucid

« back to all changes in this revision

Viewing changes to Modules/CheckCCompilerFlag.cmake

  • Committer: Bazaar Package Importer
  • Author(s): Artur Rona
  • Date: 2009-12-16 11:11:54 UTC
  • mfrom: (3.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20091216111154-6accvv6yq86h2hkc
Tags: 2.8.0-5ubuntu1
* Merge from debian testing (LP: #497349). Remaining changes:
  - Keep the Replaces: on cmake-data to cover the Kubuntu version from
    Jaunty in case someone decides to do an (unsupported) Jaunty->Lucid
    upgrade.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# - Check whether the C compiler supports a given flag.
2
 
# CHECK_C_COMPILER_FLAG(FLAG VARIABLE)
3
 
#
4
 
#  FLAG - the compiler flag
5
 
#  VARIABLE - variable to store the result
6
 
7
 
#  This actually calls the check_c_source_compiles macro.
8
 
#  See help for CheckCSourceCompiles for a listing of variables
9
 
#  that can modify the build.
10
 
 
11
 
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
12
 
#
13
 
# Redistribution and use is allowed according to the terms of the BSD license.
14
 
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
15
 
 
 
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
#
 
13
# Distributed under the OSI-approved BSD License (the "License");
 
14
# see accompanying file Copyright.txt for details.
 
15
#
 
16
# This software is distributed WITHOUT ANY WARRANTY; without even the
 
17
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
18
# See the License for more information.
 
19
#=============================================================================
 
20
# (To distributed this file outside of CMake, substitute the full
 
21
#  License text for the above reference.)
16
22
 
17
23
INCLUDE(CheckCSourceCompiles)
18
24
 
19
25
MACRO (CHECK_C_COMPILER_FLAG _FLAG _RESULT)
20
26
   SET(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
21
27
   SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
22
 
   CHECK_C_SOURCE_COMPILES("int main() { return 0;}" ${_RESULT})
 
28
   CHECK_C_SOURCE_COMPILES("int main() { return 0;}" ${_RESULT}
 
29
     # Some compilers do not fail with a bad flag
 
30
     FAIL_REGEX "unrecognized .*option"                     # GNU
 
31
     FAIL_REGEX "ignoring unknown option"                   # MSVC
 
32
     FAIL_REGEX "[Uu]nknown option"                         # HP
 
33
     FAIL_REGEX "[Ww]arning: [Oo]ption"                     # SunPro
 
34
     FAIL_REGEX "command option .* is not recognized"       # XL
 
35
     )
23
36
   SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
24
37
ENDMACRO (CHECK_C_COMPILER_FLAG)
25
38