diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-05-19 17:18:01 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-11-19 17:38:53 (GMT) |
commit | 76552d595db509d47e9bf179aac7a00e2f1fcfae (patch) | |
tree | ebaee909e7d3b9f32cc109906d87d1d2caa3dd64 /Modules | |
parent | f41ecd1db4341a9ab6087e6959993f4384eb6c53 (diff) | |
download | CMake-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')
-rw-r--r-- | Modules/CMakeDetermineCCompiler.cmake | 6 | ||||
-rw-r--r-- | Modules/CMakeDetermineCXXCompiler.cmake | 6 | ||||
-rw-r--r-- | Modules/Compiler/Clang.cmake | 1 | ||||
-rw-r--r-- | Modules/Platform/QNX.cmake | 3 |
4 files changed, 16 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 diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index e882189..5f9d9bf 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -156,6 +156,12 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) get_filename_component(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME) if (COMPILER_BASENAME MATCHES "^(.+-)(clan)?[gc]\\+\\+(-[0-9]+\\.[0-9]+\\.[0-9]+)?(\\.exe)?$") set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_CXX_COMPILER_TARGET}-) + elseif(COMPILER_BASENAME MATCHES "QCC(\\.exe)?$") + if(CMAKE_CXX_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 diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index 7d7be5c..f0ea2f8 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -30,5 +30,6 @@ else() set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE") set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") set(CMAKE_${lang}_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") + set(CMAKE_${lang}_COMPILE_OPTIONS_TARGET "-target ") endmacro() endif() diff --git a/Modules/Platform/QNX.cmake b/Modules/Platform/QNX.cmake index 068799f..9afde05 100644 --- a/Modules/Platform/QNX.cmake +++ b/Modules/Platform/QNX.cmake @@ -16,6 +16,9 @@ set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":") set(CMAKE_SHARED_LIBRARY_RPATH_LINK_C_FLAG "-Wl,-rpath-link,") set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,") set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic") +# http://www.qnx.com/developers/docs/6.4.0/neutrino/utilities/q/qcc.html#examples +set(CMAKE_C_COMPILE_OPTIONS_TARGET "-V") +set(CMAKE_CXX_COMPILE_OPTIONS_TARGET "-V") # Shared libraries with no builtin soname may not be linked safely by # specifying the file path. |