diff options
Diffstat (limited to 'Modules/CMakeDetermineCCompiler.cmake')
-rw-r--r-- | Modules/CMakeDetermineCCompiler.cmake | 48 |
1 files changed, 27 insertions, 21 deletions
diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 85d6c46..82e9448 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -88,27 +88,6 @@ IF (NOT _CMAKE_TOOLCHAIN_LOCATION) GET_FILENAME_COMPONENT(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_C_COMPILER}" PATH) ENDIF (NOT _CMAKE_TOOLCHAIN_LOCATION) -# If we have a gcc cross compiler, they have usually some prefix, like -# e.g. powerpc-linux-gcc, arm-elf-gcc or i586-mingw32msvc-gcc . -# The other tools of the toolchain usually have the same prefix -# NAME_WE cannot be used since then this test will fail for names lile -# "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be -# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" -IF (NOT _CMAKE_TOOLCHAIN_PREFIX) - GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME) - IF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(\\.exe)?$") - SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) - ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(\\.exe)?$") - - # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils - # but uses the regular ar, objcopy, etc. (instead of llvm-objcopy etc.) - IF ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") - SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) - ENDIF ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") - -ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX) - - # Build a small source file to identify the compiler. IF(${CMAKE_GENERATOR} MATCHES "Visual Studio") SET(CMAKE_C_COMPILER_ID_RUN 1) @@ -148,6 +127,33 @@ IF(NOT CMAKE_C_COMPILER_ID_RUN) ENDIF("${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW") ENDIF(NOT CMAKE_C_COMPILER_ID_RUN) +# If we have a gcc cross compiler, they have usually some prefix, like +# e.g. powerpc-linux-gcc, arm-elf-gcc or i586-mingw32msvc-gcc . +# The other tools of the toolchain usually have the same prefix +# NAME_WE cannot be used since then this test will fail for names lile +# "arm-unknown-nto-qnx6.3.0-gcc.exe", where BASENAME would be +# "arm-unknown-nto-qnx6" instead of the correct "arm-unknown-nto-qnx6.3.0-" +IF (CMAKE_CROSSCOMPILING + AND "${CMAKE_C_COMPILER_ID}" MATCHES "GNU" + AND NOT _CMAKE_TOOLCHAIN_PREFIX) + GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME) + IF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(\\.exe)?$") + SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(\\.exe)?$") + + # if "llvm-" is part of the prefix, remove it, since llvm doesn't have its own binutils + # but uses the regular ar, objcopy, etc. (instead of llvm-objcopy etc.) + IF ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") + SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1}) + ENDIF ("${_CMAKE_TOOLCHAIN_PREFIX}" MATCHES "(.+-)?llvm-$") + +ENDIF (CMAKE_CROSSCOMPILING + AND "${CMAKE_C_COMPILER_ID}" MATCHES "GNU" + AND NOT _CMAKE_TOOLCHAIN_PREFIX) + + + + INCLUDE(CMakeFindBinUtils) # configure variables set in this file for fast reload later on |