Setting up repository
[linux-libre-firmware.git] / carl9170fw / extra / GCCVersion.cmake
1 #=============================================================================
2 # Copyright 2006-2009 Kitware, Inc.
3 # Copyright 2006-2008 Andreas Schneider <mail@cynapses.org>
4 # Copyright 2007      Wengo
5 # Copyright 2007      Mike Jackson
6 # Copyright 2008      Andreas Pakulat <apaku@gmx.de>
7 # Copyright 2008-2009 Philip Lowman <philip@yhbt.com>
8 #
9 # Redistribution and use in source and binary forms, with or without
10 # modification, are permitted provided that the following conditions
11 # are met:
12 #
13 # * Redistributions of source code must retain the above copyright
14 #   notice, this list of conditions and the following disclaimer.
15 #
16 # * Redistributions in binary form must reproduce the above copyright
17 #   notice, this list of conditions and the following disclaimer in the
18 #   documentation and/or other materials provided with the distribution.
19 #
20 # * Neither the names of Kitware, Inc., the Insight Software Consortium,
21 #   nor the names of their contributors may be used to endorse or promote
22 #   products derived from this software without specific prior written
23 #   permission.
24 #
25 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 # HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
37 #-------------------------------------------------------------------------------
38
39 #
40 # Runs compiler with "-dumpversion" and parses major/minor
41 # version with a regex.
42 #
43 FUNCTION(_COMPILER_DUMPVERSION _OUTPUT_VERSION)
44
45   EXEC_PROGRAM(${CMAKE_C_COMPILER}
46     ARGS ${CMAKE_C_COMPILER_ARG1} -dumpversion
47     OUTPUT_VARIABLE _COMPILER_VERSION
48   )
49   STRING(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
50     _COMPILER_VERSION ${_COMPILER_VERSION})
51
52   SET(${_OUTPUT_VERSION} ${_COMPILER_VERSION} PARENT_SCOPE)
53 ENDFUNCTION()
54
55 #
56 # End functions/macros
57 #
58 #-------------------------------------------------------------------------------
59
60