Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / CMakeForceCompiler.cmake
1 # This module defines macros intended for use by cross-compiling
2 # toolchain files when CMake is not able to automatically detect the
3 # compiler identification.
4 #
5 # Macro CMAKE_FORCE_C_COMPILER has the following signature:
6 #   CMAKE_FORCE_C_COMPILER(<compiler> <compiler-id>)
7 # It sets CMAKE_C_COMPILER to the given compiler and the cmake
8 # internal variable CMAKE_C_COMPILER_ID to the given compiler-id.
9 # It also bypasses the check for working compiler and basic compiler
10 # information tests.
11 #
12 # Macro CMAKE_FORCE_CXX_COMPILER has the following signature:
13 #   CMAKE_FORCE_CXX_COMPILER(<compiler> <compiler-id>)
14 # It sets CMAKE_CXX_COMPILER to the given compiler and the cmake
15 # internal variable CMAKE_CXX_COMPILER_ID to the given compiler-id.
16 # It also bypasses the check for working compiler and basic compiler
17 # information tests.
18 #
19 # Macro CMAKE_FORCE_Fortran_COMPILER has the following signature:
20 #   CMAKE_FORCE_Fortran_COMPILER(<compiler> <compiler-id>)
21 # It sets CMAKE_Fortran_COMPILER to the given compiler and the cmake
22 # internal variable CMAKE_Fortran_COMPILER_ID to the given compiler-id.
23 # It also bypasses the check for working compiler and basic compiler
24 # information tests.
25 #
26 # So a simple toolchain file could look like this:
27 #   include (CMakeForceCompiler)
28 #   set(CMAKE_SYSTEM_NAME Generic)
29 #   CMAKE_FORCE_C_COMPILER   (chc12 MetrowerksHicross)
30 #   CMAKE_FORCE_CXX_COMPILER (chc12 MetrowerksHicross)
31
32 #=============================================================================
33 # Copyright 2007-2009 Kitware, Inc.
34 #
35 # Distributed under the OSI-approved BSD License (the "License");
36 # see accompanying file Copyright.txt for details.
37 #
38 # This software is distributed WITHOUT ANY WARRANTY; without even the
39 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
40 # See the License for more information.
41 #=============================================================================
42 # (To distribute this file outside of CMake, substitute the full
43 #  License text for the above reference.)
44
45 macro(CMAKE_FORCE_C_COMPILER compiler id)
46   set(CMAKE_C_COMPILER "${compiler}")
47   set(CMAKE_C_COMPILER_ID_RUN TRUE)
48   set(CMAKE_C_COMPILER_ID ${id})
49   set(CMAKE_C_COMPILER_FORCED TRUE)
50
51   # Set old compiler id variables.
52   if("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
53     set(CMAKE_COMPILER_IS_GNUCC 1)
54   endif()
55 endmacro()
56
57 macro(CMAKE_FORCE_CXX_COMPILER compiler id)
58   set(CMAKE_CXX_COMPILER "${compiler}")
59   set(CMAKE_CXX_COMPILER_ID_RUN TRUE)
60   set(CMAKE_CXX_COMPILER_ID ${id})
61   set(CMAKE_CXX_COMPILER_FORCED TRUE)
62
63   # Set old compiler id variables.
64   if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
65     set(CMAKE_COMPILER_IS_GNUCXX 1)
66   endif()
67 endmacro()
68
69 macro(CMAKE_FORCE_Fortran_COMPILER compiler id)
70   set(CMAKE_Fortran_COMPILER "${compiler}")
71   set(CMAKE_Fortran_COMPILER_ID_RUN TRUE)
72   set(CMAKE_Fortran_COMPILER_ID ${id})
73   set(CMAKE_Fortran_COMPILER_FORCED TRUE)
74
75   # Set old compiler id variables.
76   if("${CMAKE_Fortran_COMPILER_ID}" MATCHES "GNU")
77     set(CMAKE_COMPILER_IS_GNUG77 1)
78   endif()
79 endmacro()