carl9170 firmware: import 1.7.0
[carl9170fw.git] / 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 # Distributed under the OSI-approved BSD License (the "License");
10 # see accompanying file Copyright.txt for details.
11 #
12 # This software is distributed WITHOUT ANY WARRANTY; without even the
13 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 # See the License for more information.
15 #=============================================================================
16 # (To distributed this file outside of CMake, substitute the full
17 #  License text for the above reference.)
18
19 #-------------------------------------------------------------------------------
20
21 #
22 # Runs compiler with "-dumpversion" and parses major/minor
23 # version with a regex.
24 #
25 FUNCTION(_COMPILER_DUMPVERSION _OUTPUT_VERSION)
26
27   EXEC_PROGRAM(${CMAKE_C_COMPILER}
28     ARGS ${CMAKE_C_COMPILER_ARG1} -dumpversion
29     OUTPUT_VARIABLE _COMPILER_VERSION
30   )
31   STRING(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
32     _COMPILER_VERSION ${_COMPILER_VERSION})
33
34   SET(${_OUTPUT_VERSION} ${_COMPILER_VERSION} PARENT_SCOPE)
35 ENDFUNCTION()
36
37 #
38 # End functions/macros
39 #
40 #-------------------------------------------------------------------------------
41
42