[cmake-commits] alex committed CMakeCCompilerId.c 1.9 1.10 CMakeDetermineCompilerId.cmake 1.6 1.7 CMakeLists.txt 1.11 1.12

cmake-commits at cmake.org cmake-commits at cmake.org
Fri May 25 15:22:24 EDT 2007


Update of /cvsroot/CMake/CMake/Modules
In directory public:/mounts/ram/cvs-serv1214/Modules

Modified Files:
	CMakeCCompilerId.c CMakeDetermineCompilerId.cmake 
	CMakeLists.txt 
Log Message:

ENH: make the compiler id detection work, even if the output file name of
the compiler is completely unknown and even if it produces intel hex or
motorola s-record files, with test

Alex


Index: CMakeCCompilerId.c
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CMakeCCompilerId.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- CMakeCCompilerId.c	24 May 2007 20:03:39 -0000	1.9
+++ CMakeCCompilerId.c	25 May 2007 19:22:22 -0000	1.10
@@ -41,14 +41,9 @@
 
 /* sdcc, the small devices C compiler for embedded systems, 
    http://sdcc.sourceforge.net 
-   Beside this id not supported yet by CMake 
-   Unfortunately this doesn't work because SDCC (and other embedded compilers 
-   too) produce not binary files, but e.g. Intel hex files by default. 
-   This also means it has a different suffix (.ihx) so the file isn't even
-   found. */
-/*
+   Beside this id not supported yet by CMake. */
 #elif defined(SDCC)
-# define COMPILER_ID "SDCC" */
+# define COMPILER_ID "SDCC"
 
 #elif defined(_COMPILER_VERSION)
 # define COMPILER_ID "MIPSpro"

Index: CMakeLists.txt
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CMakeLists.txt,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- CMakeLists.txt	21 May 2007 15:26:40 -0000	1.11
+++ CMakeLists.txt	25 May 2007 19:22:22 -0000	1.12
@@ -1,5 +1,5 @@
 # just install the modules
-# new file added, force rerunning cmake #
+# new file added, force rerunning cmake 
 
 SUBDIRS(Platform)
 INSTALL_FILES(${CMAKE_DATA_DIR}/Modules .*\\.cmake$)

Index: CMakeDetermineCompilerId.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CMakeDetermineCompilerId.cmake,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- CMakeDetermineCompilerId.cmake	18 May 2007 13:08:49 -0000	1.6
+++ CMakeDetermineCompilerId.cmake	25 May 2007 19:22:22 -0000	1.7
@@ -66,56 +66,52 @@
       "${CMAKE_${lang}_COMPILER_ID_SRC}\" succeeded with the following output:\n"
       "${CMAKE_${lang}_COMPILER_ID_OUTPUT}\n\n")
 
-    # Find the executable produced by the compiler.
-    SET(CMAKE_${lang}_COMPILER_ID_EXE)
-    GET_FILENAME_COMPONENT(CMAKE_${lang}_COMPILER_ID_SRC_BASE ${CMAKE_${lang}_COMPILER_ID_SRC} NAME_WE)
-    FOREACH(name a.out a.exe ${CMAKE_${lang}_COMPILER_ID_SRC_BASE}.exe)
-      IF(EXISTS ${CMAKE_${lang}_COMPILER_ID_DIR}/${name})
-        SET(CMAKE_${lang}_COMPILER_ID_EXE ${CMAKE_${lang}_COMPILER_ID_DIR}/${name})
-      ENDIF(EXISTS ${CMAKE_${lang}_COMPILER_ID_DIR}/${name})
-    ENDFOREACH(name)
-
-    # Check if the executable was found.
-    IF(CMAKE_${lang}_COMPILER_ID_EXE)
-      # The executable was found.
+    # Find the executable produced by the compiler, try all files in the binary dir
+    SET(CMAKE_${lang}_COMPILER_ID)
+    FILE(GLOB COMPILER_${lang}_PRODUCED_FILES ${CMAKE_${lang}_COMPILER_ID_DIR}/*)
+    FOREACH(CMAKE_${lang}_COMPILER_ID_EXE ${COMPILER_${lang}_PRODUCED_FILES})
       FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
         "Compilation of the ${lang} compiler identification source \""
         "${CMAKE_${lang}_COMPILER_ID_SRC}\" produced \""
         "${CMAKE_${lang}_COMPILER_ID_EXE}\"\n\n")
+      # only check if we don't have it yet 
+      IF(NOT CMAKE_${lang}_COMPILER_ID)
+        # Read the compiler identification string from the executable file.
+        FILE(STRINGS ${CMAKE_${lang}_COMPILER_ID_EXE}
+          CMAKE_${lang}_COMPILER_ID_STRINGS LIMIT_COUNT 2 REGEX "INFO:")
+        FOREACH(info ${CMAKE_${lang}_COMPILER_ID_STRINGS})
+          IF("${info}" MATCHES ".*INFO:compiler\\[([^]]*)\\].*")
+            STRING(REGEX REPLACE ".*INFO:compiler\\[([^]]*)\\].*" "\\1"
+              CMAKE_${lang}_COMPILER_ID "${info}")
+          ENDIF("${info}" MATCHES ".*INFO:compiler\\[([^]]*)\\].*")
+          IF("${info}" MATCHES ".*INFO:platform\\[([^]]*)\\].*")
+            STRING(REGEX REPLACE ".*INFO:platform\\[([^]]*)\\].*" "\\1"
+              CMAKE_${lang}_PLATFORM_ID "${info}")
+          ENDIF("${info}" MATCHES ".*INFO:platform\\[([^]]*)\\].*")
+        ENDFOREACH(info)
 
-      # Read the compiler identification string from the executable file.
-      FILE(STRINGS ${CMAKE_${lang}_COMPILER_ID_EXE}
-        CMAKE_${lang}_COMPILER_ID_STRINGS LIMIT_COUNT 2 REGEX "INFO:")
-      FOREACH(info ${CMAKE_${lang}_COMPILER_ID_STRINGS})
-        IF("${info}" MATCHES ".*INFO:compiler\\[([^]]*)\\].*")
-          STRING(REGEX REPLACE ".*INFO:compiler\\[([^]]*)\\].*" "\\1"
-            CMAKE_${lang}_COMPILER_ID "${info}")
-        ENDIF("${info}" MATCHES ".*INFO:compiler\\[([^]]*)\\].*")
-        IF("${info}" MATCHES ".*INFO:platform\\[([^]]*)\\].*")
-          STRING(REGEX REPLACE ".*INFO:platform\\[([^]]*)\\].*" "\\1"
-            CMAKE_${lang}_PLATFORM_ID "${info}")
-        ENDIF("${info}" MATCHES ".*INFO:platform\\[([^]]*)\\].*")
-      ENDFOREACH(info)
+        # Check the compiler identification string.
+        IF(CMAKE_${lang}_COMPILER_ID)
+          # The compiler identification was found.
+          FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+            "The ${lang} compiler identification is ${CMAKE_${lang}_COMPILER_ID}, found in \""
+            "${CMAKE_${lang}_COMPILER_ID_EXE}\"\n\n")
+        ELSE(CMAKE_${lang}_COMPILER_ID)
+          # The compiler identification could not be found.
+          FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+            "The ${lang} compiler identification could not be found in \""
+            "${CMAKE_${lang}_COMPILER_ID_EXE}\"\n\n")
+        ENDIF(CMAKE_${lang}_COMPILER_ID)
+      ENDIF(NOT CMAKE_${lang}_COMPILER_ID)
+    ENDFOREACH(CMAKE_${lang}_COMPILER_ID_EXE)
 
-      # Check the compiler identification string.
-      IF(CMAKE_${lang}_COMPILER_ID)
-        # The compiler identification was found.
-        FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
-          "The ${lang} compiler identification is ${CMAKE_${lang}_COMPILER_ID}\n\n")
-      ELSE(CMAKE_${lang}_COMPILER_ID)
-        # The compiler identification could not be found.
-        FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
-          "The ${lang} compiler identification could not be found in \""
-          "${CMAKE_${lang}_COMPILER_ID_EXE}\"\n\n")
-      ENDIF(CMAKE_${lang}_COMPILER_ID)
-    ELSE(CMAKE_${lang}_COMPILER_ID_EXE)
-      # The executable was not found.
+    IF(NOT COMPILER_${lang}_PRODUCED_FILES)
+      # No executable was found.
       FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
         "Compilation of the ${lang} compiler identification source \""
         "${CMAKE_${lang}_COMPILER_ID_SRC}\" did not produce an executable in "
-        "${CMAKE_${lang}_COMPILER_ID_DIR} "
-        "with a name known to CMake.\n\n")
-    ENDIF(CMAKE_${lang}_COMPILER_ID_EXE)
+        "${CMAKE_${lang}_COMPILER_ID_DIR} .\n\n")
+    ENDIF(NOT COMPILER_${lang}_PRODUCED_FILES)
 
     IF(CMAKE_${lang}_COMPILER_ID)
       MESSAGE(STATUS "The ${lang} compiler identification is "



More information about the Cmake-commits mailing list