summaryrefslogtreecommitdiff
path: root/share/cmake-3.6/Modules/CheckCCompilerFlag.cmake
diff options
context:
space:
mode:
authorChaoren Lin <aoe@google.com>2016-07-12 11:53:58 -0700
committerChaoren Lin <aoe@google.com>2016-07-13 11:35:29 -0700
commitecf0ec027d28d2c26ce13075003dc57db20d279e (patch)
tree8ad8b5881235f6e813451e8916201104d8155bd5 /share/cmake-3.6/Modules/CheckCCompilerFlag.cmake
parent091caafda44f7fe52a94387b2eafcf204ea909d3 (diff)
downloadlinux-x86-ecf0ec027d28d2c26ce13075003dc57db20d279e.tar.gz
Update prebuilts to CMake 3.6.0-rc2 (go/ab/3043163).
Change-Id: Ibe6715663df09f1d9ac5fcb588e12c657b2caab1
Diffstat (limited to 'share/cmake-3.6/Modules/CheckCCompilerFlag.cmake')
-rw-r--r--share/cmake-3.6/Modules/CheckCCompilerFlag.cmake64
1 files changed, 64 insertions, 0 deletions
diff --git a/share/cmake-3.6/Modules/CheckCCompilerFlag.cmake b/share/cmake-3.6/Modules/CheckCCompilerFlag.cmake
new file mode 100644
index 0000000..53f3454
--- /dev/null
+++ b/share/cmake-3.6/Modules/CheckCCompilerFlag.cmake
@@ -0,0 +1,64 @@
+#.rst:
+# CheckCCompilerFlag
+# ------------------
+#
+# Check whether the C compiler supports a given flag.
+#
+# CHECK_C_COMPILER_FLAG(<flag> <var>)
+#
+# ::
+#
+# <flag> - the compiler flag
+# <var> - variable to store the result
+# Will be created as an internal cache variable.
+#
+# This internally calls the check_c_source_compiles macro and sets
+# CMAKE_REQUIRED_DEFINITIONS to <flag>. See help for
+# CheckCSourceCompiles for a listing of variables that can otherwise
+# modify the build. The result only tells that the compiler does not
+# give an error message when it encounters the flag. If the flag has
+# any effect or even a specific one is beyond the scope of this module.
+
+#=============================================================================
+# Copyright 2006-2011 Kitware, Inc.
+# Copyright 2006 Alexander Neundorf <neundorf@kde.org>
+# Copyright 2011 Matthias Kretz <kretz@kde.org>
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+include(CheckCSourceCompiles)
+include(CMakeCheckCompilerFlagCommonPatterns)
+
+macro (CHECK_C_COMPILER_FLAG _FLAG _RESULT)
+ set(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
+ set(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
+
+ # Normalize locale during test compilation.
+ set(_CheckCCompilerFlag_LOCALE_VARS LC_ALL LC_MESSAGES LANG)
+ foreach(v ${_CheckCCompilerFlag_LOCALE_VARS})
+ set(_CheckCCompilerFlag_SAVED_${v} "$ENV{${v}}")
+ set(ENV{${v}} C)
+ endforeach()
+ CHECK_COMPILER_FLAG_COMMON_PATTERNS(_CheckCCompilerFlag_COMMON_PATTERNS)
+ CHECK_C_SOURCE_COMPILES("int main(void) { return 0; }" ${_RESULT}
+ # Some compilers do not fail with a bad flag
+ FAIL_REGEX "command line option .* is valid for .* but not for C" # GNU
+ ${_CheckCCompilerFlag_COMMON_PATTERNS}
+ )
+ foreach(v ${_CheckCCompilerFlag_LOCALE_VARS})
+ set(ENV{${v}} ${_CheckCCompilerFlag_SAVED_${v}})
+ unset(_CheckCCompilerFlag_SAVED_${v})
+ endforeach()
+ unset(_CheckCCompilerFlag_LOCALE_VARS)
+ unset(_CheckCCompilerFlag_COMMON_PATTERNS)
+
+ set (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
+endmacro ()