summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineCCompiler.cmake
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-05-19 17:18:01 (GMT)
committerBrad King <brad.king@kitware.com>2013-11-19 17:38:53 (GMT)
commit76552d595db509d47e9bf179aac7a00e2f1fcfae (patch)
treeebaee909e7d3b9f32cc109906d87d1d2caa3dd64 /Modules/CMakeDetermineCCompiler.cmake
parentf41ecd1db4341a9ab6087e6959993f4384eb6c53 (diff)
downloadCMake-76552d595db509d47e9bf179aac7a00e2f1fcfae.zip
CMake-76552d595db509d47e9bf179aac7a00e2f1fcfae.tar.gz
CMake-76552d595db509d47e9bf179aac7a00e2f1fcfae.tar.bz2
Add compiler target compile options.
For clang, this allows passing -target <triple> to the compiler, and for qcc, -V<arch> using toolchain files containing something like set(triple arm-linux-gnueabihf) set(CMAKE_C_COMPILER "/usr/bin/clang") set(CMAKE_C_COMPILER_TARGET ${triple}) set(CMAKE_CXX_COMPILER "/usr/bin/clang++") set(CMAKE_CXX_COMPILER_TARGET ${triple}) or set(arch gcc_ntoarmv7le) set(CMAKE_C_COMPILER /opt/qnx650/host/linux/x86/usr/bin/qcc) set(CMAKE_C_COMPILER_TARGET ${arch}) set(CMAKE_CXX_COMPILER /opt/qnx650/host/linux/x86/usr/bin/QCC) set(CMAKE_CXX_COMPILER_TARGET ${arch}) Both clang and qcc are inherently cross compiler( driver)s. When cross-compiling with clang, use the CMAKE_${lang}_COMPILER_TARGET as the _CMAKE_TOOLCHAIN_PREFIX to find the appropriate binutils. When cross-compiling with QNX qcc, use the CMAKE_${lang}_COMPILER_TARGET to set the appropriate _CMAKE_TOOLCHAIN_PREFIX.
Diffstat (limited to 'Modules/CMakeDetermineCCompiler.cmake')
-rw-r--r--Modules/CMakeDetermineCCompiler.cmake6
1 files changed, 6 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake
index 0d47a60..438a98a 100644
--- a/Modules/CMakeDetermineCCompiler.cmake
+++ b/Modules/CMakeDetermineCCompiler.cmake
@@ -158,6 +158,12 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX)
get_filename_component(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME)
if (COMPILER_BASENAME MATCHES "^(.+-)(clang|g?cc)(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$")
set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
+ elseif("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
+ set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_C_COMPILER_TARGET}-)
+ elseif(COMPILER_BASENAME MATCHES "qcc(\\.exe)?$")
+ if(CMAKE_C_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?.*$")
+ set(_CMAKE_TOOLCHAIN_PREFIX nto${CMAKE_MATCH_1}-)
+ endif()
endif ()
# if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils