summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineCXXCompiler.cmake
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2008-09-08 21:43:31 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2008-09-08 21:43:31 (GMT)
commit1bcf48de98bdde537a5fcc2cbd2d93b2be60c31d (patch)
tree05c29c9b0527eac9351cadd6311614296cdf8cd4 /Modules/CMakeDetermineCXXCompiler.cmake
parent43837fb3e115c621af89c7d7d9d1df884e9c50d4 (diff)
downloadCMake-1bcf48de98bdde537a5fcc2cbd2d93b2be60c31d.zip
CMake-1bcf48de98bdde537a5fcc2cbd2d93b2be60c31d.tar.gz
CMake-1bcf48de98bdde537a5fcc2cbd2d93b2be60c31d.tar.bz2
BUG: only check for a toolchain prefix (e.g. "arm-linux-" in
"arm-linux-gcc") if we are cross compiling and the compiler is gcc Alex
Diffstat (limited to 'Modules/CMakeDetermineCXXCompiler.cmake')
-rw-r--r--Modules/CMakeDetermineCXXCompiler.cmake44
1 files changed, 24 insertions, 20 deletions
diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake
index 7337846..87abffa 100644
--- a/Modules/CMakeDetermineCXXCompiler.cmake
+++ b/Modules/CMakeDetermineCXXCompiler.cmake
@@ -88,26 +88,6 @@ IF (NOT _CMAKE_TOOLCHAIN_LOCATION)
GET_FILENAME_COMPONENT(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_CXX_COMPILER}" PATH)
ENDIF (NOT _CMAKE_TOOLCHAIN_LOCATION)
-# if we have a g++ cross compiler, they have usually some prefix, like
-# e.g. powerpc-linux-g++, arm-elf-g++ or i586-mingw32msvc-g++
-# 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_CXX_COMPILER}" NAME)
- IF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(\\.exe)?$")
- SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
- ENDIF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(\\.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)
-
# This block was used before the compiler was identified by building a
# source file. Unless g++ crashes when building a small C++
# executable this should no longer be needed.
@@ -158,6 +138,30 @@ IF(NOT CMAKE_CXX_COMPILER_ID_RUN)
ENDIF("${CMAKE_CXX_PLATFORM_ID}" MATCHES "MinGW")
ENDIF(NOT CMAKE_CXX_COMPILER_ID_RUN)
+# if we have a g++ cross compiler, they have usually some prefix, like
+# e.g. powerpc-linux-g++, arm-elf-g++ or i586-mingw32msvc-g++
+# 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_CXX_COMPILER_ID}" MATCHES "GNU"
+ AND NOT _CMAKE_TOOLCHAIN_PREFIX)
+ GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME)
+ IF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(\\.exe)?$")
+ SET(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_MATCH_1})
+ ENDIF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(\\.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_CXX_COMPILER_ID}" MATCHES "GNU"
+ AND NOT _CMAKE_TOOLCHAIN_PREFIX)
+
INCLUDE(CMakeFindBinUtils)
# configure all variables set in this file