From 27e6f6ef398d3ccfc496b1ecedf2db89991be10d Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 14 Mar 2013 19:42:03 +0100 Subject: TI compiler: add automatic detection of prefix and suffixes The TI cross compilers are named e.g. cl6x or armcl, the accompanying strip and ar have the same prefixes/suffixes. Alex --- Modules/CMakeDetermineCCompiler.cmake | 7 +++++++ Modules/CMakeDetermineCXXCompiler.cmake | 8 ++++++++ Modules/CMakeFindBinUtils.cmake | 9 ++------- 3 files changed, 17 insertions(+), 7 deletions(-) (limited to 'Modules') diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 736fc8932c..d2220e09ec 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -158,6 +158,13 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) if ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) endif () + elseif("${CMAKE_C_COMPILER_ID}" MATCHES "TI") + # TI compilers are named e.g. cl6x, cl470 or armcl.exe + get_filename_component(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME) + if (COMPILER_BASENAME MATCHES "^(.+)?cl([^.]+)?(\\.exe)?$") + set(_CMAKE_TOOLCHAIN_PREFIX "${CMAKE_MATCH_1}") + set(_CMAKE_TOOLCHAIN_SUFFIX "${CMAKE_MATCH_2}") + endif () endif() endif () diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index c128cfa463..6f7e8f6d4e 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -156,6 +156,14 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX) if ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) endif () + elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "TI") + # TI compilers are named e.g. cl6x, cl470 or armcl.exe + get_filename_component(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME) + if (COMPILER_BASENAME MATCHES "^(.+)?cl([^.]+)?(\\.exe)?$") + set(_CMAKE_TOOLCHAIN_PREFIX "${CMAKE_MATCH_1}") + set(_CMAKE_TOOLCHAIN_SUFFIX "${CMAKE_MATCH_2}") + endif () + endif() endif () diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 1b30801306..e70c013beb 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -41,19 +41,14 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC" # in all other cases search for ar, ranlib, etc. else() - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "TI" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "TI") - find_program(CMAKE_AR NAMES ar6x HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - find_program(CMAKE_STRIP NAMES strip6x HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) - endif() - - find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + find_program(CMAKE_AR NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ar${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_RANLIB NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ranlib HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) if(NOT CMAKE_RANLIB) set(CMAKE_RANLIB : CACHE INTERNAL "noop for ranlib") endif() - find_program(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) + find_program(CMAKE_STRIP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}strip${_CMAKE_TOOLCHAIN_SUFFIX} HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_LINKER NAMES ${_CMAKE_TOOLCHAIN_PREFIX}ld HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_NM NAMES ${_CMAKE_TOOLCHAIN_PREFIX}nm HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) find_program(CMAKE_OBJDUMP NAMES ${_CMAKE_TOOLCHAIN_PREFIX}objdump HINTS ${_CMAKE_TOOLCHAIN_LOCATION}) -- cgit v1.2.1