Hi Andreas,

On Wednesday 14 May 2008, you wrote:
> Hi,
> Thank you for all these hints. Are details like that described in the
> Mastering CMake book?


Yes and no.
The process how the system and the compiler are determined is described, but 
not every implementation detail of the files.

> I tracked it down to:
> CMakeDetermineCCompiler.cmake: line 97:
> IF (NOT _CMAKE_TOOLCHAIN_PREFIX)
>   GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME_WE)
>   MESSAGE(STATUS "CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}")
>   MESSAGE(STATUS "COMPILER_BASENAME: ${COMPILER_BASENAME}")
>   IF (COMPILER_BASENAME MATCHES "^(.+-)g?cc")
>     STRING(REGEX REPLACE "^(.+-)g?cc"  "\\1" _CMAKE_TOOLCHAIN_PREFIX
> "${COMPILER _BASENAME}")
>   ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?cc")
> ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX)
>
> MESSAGE(STATUS "TOOLCHAIN: ${_CMAKE_TOOLCHAIN_PREFIX}")
>
>
> It prints
> CMAKE_C_COMPILER:
> c:/work/QNX632/host/win32/x86/usr/bin/arm-unknown-nto-qnx6.3.0-gcc.exe
> COMPILER_BASENAME: arm-unknown-nto-qnx6
> TOOLCHAIN:
>
> Seems like get_filename_component takes the first dot to determine the
> extension!

Yes, it does.

Anyway, does the attached patch (against cvs HEAD) work for you ?

Alex
Index: CMakeDetermineCCompiler.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CMakeDetermineCCompiler.cmake,v
retrieving revision 1.52
diff -b -u -p -r1.52 CMakeDetermineCCompiler.cmake
--- CMakeDetermineCCompiler.cmake	25 Feb 2008 14:23:14 -0000	1.52
+++ CMakeDetermineCCompiler.cmake	14 May 2008 22:07:24 -0000
@@ -88,17 +88,19 @@ 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
+# 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_WE)
-  IF (COMPILER_BASENAME MATCHES "^(.+-)g?cc")
-    STRING(REGEX REPLACE "^(.+-)g?cc"  "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}")
-  ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?cc")
+  GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_C_COMPILER}" NAME)
+  IF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(\\.exe)?$")
+    STRING(REGEX REPLACE "^(.+-)g?cc(\\.exe)?$"  "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}")
+  ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?cc(\\.exe)?$")
 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)
Index: CMakeDetermineCXXCompiler.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CMakeDetermineCXXCompiler.cmake,v
retrieving revision 1.45
diff -b -u -p -r1.45 CMakeDetermineCXXCompiler.cmake
--- CMakeDetermineCXXCompiler.cmake	25 Feb 2008 14:23:14 -0000	1.45
+++ CMakeDetermineCXXCompiler.cmake	14 May 2008 22:07:24 -0000
@@ -91,11 +91,14 @@ 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_WE)
-  IF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+")
-    STRING(REGEX REPLACE "^(.+-)[gc]\\+\\+"  "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}")
-  ENDIF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+")
+  GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_CXX_COMPILER}" NAME)
+  IF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(\\.exe)?$")
+    STRING(REGEX REPLACE "^(.+-)[gc]\\+\\+(\\.exe)?$"  "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}")
+  ENDIF (COMPILER_BASENAME MATCHES "^(.+-)[gc]\\+\\+(\\.exe)?$")
 ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX)
 
 # This block was used before the compiler was identified by building a
Index: CMakeDetermineASMCompiler.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CMakeDetermineASMCompiler.cmake,v
retrieving revision 1.2
diff -b -u -p -r1.2 CMakeDetermineASMCompiler.cmake
--- CMakeDetermineASMCompiler.cmake	21 Apr 2008 22:51:55 -0000	1.2
+++ CMakeDetermineASMCompiler.cmake	14 May 2008 22:07:24 -0000
@@ -43,16 +43,20 @@ IF (NOT _CMAKE_TOOLCHAIN_LOCATION)
   GET_FILENAME_COMPONENT(_CMAKE_TOOLCHAIN_LOCATION "${CMAKE_ASM${ASM_DIALECT}_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
+# 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_ASM${ASM_DIALECT}_COMPILER}" NAME_WE)
-  IF (COMPILER_BASENAME MATCHES "^(.+-)g?as")
-    STRING(REGEX REPLACE "^(.+-)g?as"  "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}")
-  ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?as")
+  GET_FILENAME_COMPONENT(COMPILER_BASENAME "${CMAKE_ASM${ASM_DIALECT}_COMPILER}" NAME)
+  IF (COMPILER_BASENAME MATCHES "^(.+-)g?as(\\.exe)?$")
+    STRING(REGEX REPLACE "^(.+-)g?as(\\.exe)?$"  "\\1" _CMAKE_TOOLCHAIN_PREFIX "${COMPILER_BASENAME}")
+  ENDIF (COMPILER_BASENAME MATCHES "^(.+-)g?as(\\.exe)?$")
 ENDIF (NOT _CMAKE_TOOLCHAIN_PREFIX)
 
+
 INCLUDE(CMakeFindBinUtils)
 
 SET(CMAKE_ASM${ASM_DIALECT}_COMPILER_ENV_VAR "ASM")
_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to