summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorSebastian Pop <spop@codeaurora.org>2012-08-20 19:56:52 +0000
committerSebastian Pop <spop@codeaurora.org>2012-08-20 19:56:52 +0000
commitdf2598871e07fe5eda960c5a461b55eced1e1657 (patch)
treecc0a10fb74ad4560ed4a4035db80b393c2df318d /CMakeLists.txt
parent974e12b376f21234e2262d65805791b9c36b356e (diff)
downloadllvm-df2598871e07fe5eda960c5a461b55eced1e1657.tar.gz
llvm-df2598871e07fe5eda960c5a461b55eced1e1657.tar.bz2
llvm-df2598871e07fe5eda960c5a461b55eced1e1657.tar.xz
enable cross compilation with cmake
This patch allows us to use cmake to specify a cross compiler: target different than host. In particular, it moves LLVM_DEFAULT_TARGET_TRIPLE and TARGET_TRIPLE variables from cmake/config-ix.cmake to the toplevel CMakeLists.txt to make them available at configure time. Here is the command line that I have used to test my patches to create a Hexagon cross compiler hosted on x86: $ cmake -G Ninja -D LLVM_TARGETS_TO_BUILD:STRING=Hexagon -D TARGET_TRIPLE:STRING=hexagon-unknown-linux-gnu -D LLVM_DEFAULT_TARGET_TRIPLE:STRING=hexagon-unknown-linux-gnu -D LLVM_TARGET_ARCH:STRING=hexagon-unknown-linux-gnu .. $ ninja check git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@162219 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt8
1 files changed, 8 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fbf8e2bb90..df781f52cd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -249,6 +249,14 @@ option(LLVM_INCLUDE_TESTS "Generate build targets for the LLVM unit tests." ON)
# BEFORE this include, otherwise options will not be correctly set on
# first cmake run
include(config-ix)
+
+# By default, we target the host, but this can be overridden at CMake
+# invocation time.
+set(LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_HOST_TRIPLE}" CACHE STRING
+ "Default target for which LLVM will generate code." )
+set(TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}" CACHE STRING
+ "Default target for which LLVM will generate code." )
+
include(HandleLLVMOptions)
# Verify that we can find a Python interpreter,