Initial commit.
[CMakeLuaTailorHgBridge.git] / CMakeLua / Modules / CMakeForceCompiler.cmake
blob79ac054a797b58dd2743e01fb3a2832c0ddb3e77
2 # These are macros intended to be used only when crosscompiling in the 
3 # toolchain-file and only if the compiler is not able to link an 
4 # executable by default (usually because they need user-specific 
5 # linker files which describe the layout of the target memory).
7 # It offers the following macros:
9 # macro CMAKE_FORCE_SYSTEM(name version processor)
10 #   Set CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_VERSION and CMAKE_SYSTEM_PROCESSOR
12 # macro CMAKE_FORCE_C_COMPILER(compiler compiler_id sizeof_void_p)
13 #   Set CMAKE_C_COMPILER to the given compiler and set CMAKE_C_COMPILER_ID
14 #   to the given compiler_id. This Id is used by cmake to construct the filename
15 #   of the system-compiler.cmake file. For C also the size of a void-pointer
16 #   has to be predefined.
18 # macro CMAKE_FORCE_CXX_COMPILER(compiler compiler_id)
19 #   The same as CMAKE_FORCE_C_COMPILER, but for CXX. Here the size of 
20 #   the void pointer is not requried.
22 # So a simple toolchain file could look like this:
24 # INCLUDE (CMakeForceCompiler)
25 # CMAKE_FORCE_SYSTEM ("Generic"   "0.0"   "hc12")
26 # CMAKE_FORCE_C_COMPILER   (chc12 FreescaleCHC12  2)
27 # CMAKE_FORCE_CXX_COMPILER (chc12 FreescaleCHC12)
30 MACRO(CMAKE_FORCE_SYSTEM name version proc)
31    SET(CMAKE_SYSTEM_NAME "${name}")
32    SET(CMAKE_SYSTEM_VERSION "${version}")
33    SET(CMAKE_SYSTEM_PROCESSOR "${proc}")
34 ENDMACRO(CMAKE_FORCE_SYSTEM)
36 MACRO(CMAKE_FORCE_C_COMPILER compiler id sizeof_void)
37   SET(CMAKE_C_COMPILER "${compiler}")
38   SET(CMAKE_C_COMPILER_ID_RUN TRUE)
39   SET(CMAKE_C_COMPILER_ID ${id})
40   SET(CMAKE_C_COMPILER_WORKS TRUE)
42   # Set old compiler and platform id variables.
43   IF("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
44     SET(CMAKE_COMPILER_IS_GNUCC 1)
45   ENDIF("${CMAKE_C_COMPILER_ID}" MATCHES "GNU")
47   SET(CMAKE_SIZEOF_VOID_P ${sizeof_void} CACHE STRING "sizeof void")
48   SET(HAVE_CMAKE_SIZEOF_VOID_P TRUE CACHE INTERNAL "have sizeof void")
49 ENDMACRO(CMAKE_FORCE_C_COMPILER)
51 MACRO(CMAKE_FORCE_CXX_COMPILER compiler id)
52   SET(CMAKE_CXX_COMPILER "${compiler}")
53   SET(CMAKE_CXX_COMPILER_ID_RUN TRUE)
54   SET(CMAKE_CXX_COMPILER_ID ${id})
55   SET(CMAKE_CXX_COMPILER_WORKS TRUE)
57   IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
58     SET(CMAKE_COMPILER_IS_GNUCXX 1)
59   ENDIF("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
61 ENDMACRO(CMAKE_FORCE_CXX_COMPILER)