summaryrefslogtreecommitdiff
path: root/Modules/CMakeForceCompiler.cmake
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2007-07-02 14:18:16 -0400
committerAlexander Neundorf <neundorf@kde.org>2007-07-02 14:18:16 -0400
commitfda7753f5ccac7ed2d3c9822e55cebd42c4467d2 (patch)
tree8d9af03f30fd262d62865ae66bcf2376ff4b40e4 /Modules/CMakeForceCompiler.cmake
parentcac79e92b83b5c9e6be128528f65a5d11d59411f (diff)
downloadcmake-fda7753f5ccac7ed2d3c9822e55cebd42c4467d2.tar.gz
ENH: make supporting embedded compilers need a user specific linker file for
compiling an executable (amd thus cannot build the compiler-id program) easier by providing CMAKE_FORCE_XXX() macros which force cmake to use the given compilers anyway Alex
Diffstat (limited to 'Modules/CMakeForceCompiler.cmake')
-rw-r--r--Modules/CMakeForceCompiler.cmake51
1 files changed, 51 insertions, 0 deletions
diff --git a/Modules/CMakeForceCompiler.cmake b/Modules/CMakeForceCompiler.cmake
new file mode 100644
index 0000000000..d104ad9c02
--- /dev/null
+++ b/Modules/CMakeForceCompiler.cmake
@@ -0,0 +1,51 @@
+
+# These are macros intended to be used only when crosscompiling in the
+# toolchain-file and only if the compiler is not able to link an
+# executable by default (usually because they need user-specific
+# linker files which describe the layout of the target memory).
+#
+# It offers the following macros:
+#
+# macro CMAKE_FORCE_SYSTEM(name version processor)
+# Set CMAKE_SYSTEM_NAME, CMAKE_SYSTEM_VERSION and CMAKE_SYSTEM_PROCESSOR
+#
+# macro CMAKE_FORCE_C_COMPILER(compiler compiler_id sizeof_void)
+# Set CMAKE_C_COMPILER to the given compiler and set CMAKE_C_COMPILER_ID
+# to the given compiler_id. This Id is used by cmake to construct the filename
+# of the system-compiler.cmake file. For C also the size of a void-pointer
+# has to be predefined.
+#
+# macro CMAKE_FORCE_CXX_COMPILER(compiler compiler_id)
+# The same as CMAKE_FORCE_C_COMPILER, but for CXX. Here the size of
+# the void pointer is not requried.
+#
+# So a simple toolchain file could look like this:
+#
+# INCLUDE (CMakeForceCompiler)
+# CMAKE_FORCE_SYSTEM ("Generic" "0.0" "hc12")
+# CMAKE_FORCE_C_COMPILER (chc12 FreescaleCHC12 2)
+# CMAKE_FORCE_CXX_COMPILER (chc12 FreescaleCHC12)
+
+
+MACRO(CMAKE_FORCE_SYSTEM name version proc)
+ SET(CMAKE_SYSTEM_NAME "${name}")
+ SET(CMAKE_SYSTEM_VERSION "${version}")
+ SET(CMAKE_SYSTEM_PROCESSOR "${proc}")
+ENDMACRO(CMAKE_FORCE_SYSTEM)
+
+MACRO(CMAKE_FORCE_C_COMPILER compiler id sizeof_void)
+ SET(CMAKE_C_COMPILER "${compiler}")
+ SET(CMAKE_C_COMPILER_ID_RUN TRUE)
+ SET(CMAKE_C_COMPILER_ID ${id})
+ SET(CMAKE_C_COMPILER_WORKS TRUE)
+ SET(CMAKE_SIZEOF_VOID_P ${sizeof_void} CACHE STRING "sizeof void")
+ SET(HAVE_CMAKE_SIZEOF_VOID_P TRUE CACHE INTERNAL "have sizeof void")
+ENDMACRO(CMAKE_FORCE_C_COMPILER)
+
+MACRO(CMAKE_FORCE_CXX_COMPILER compiler id)
+ SET(CMAKE_CXX_COMPILER "${compiler}")
+ SET(CMAKE_CXX_COMPILER_ID_RUN TRUE)
+ SET(CMAKE_CXX_COMPILER_ID ${id})
+ SET(CMAKE_CXX_COMPILER_WORKS TRUE)
+ENDMACRO(CMAKE_FORCE_CXX_COMPILER)
+