Browse Source

ENH: fix up compiler id to be more robust

Bill Hoffman 18 years ago
parent
commit
871f7cf222

+ 1 - 1
Modules/CMakeCCompilerId.c

@@ -47,5 +47,5 @@ static char const info_compiler[] = "INFO:compiler["
 /* Make sure the information strings are referenced.  */
 /* Make sure the information strings are referenced.  */
 int main()
 int main()
 {
 {
-  return ((int)&info_compiler) + ((int)&info_platform);
+  return (&info_compiler[0] != &info_platform[0]);
 }
 }

+ 1 - 5
Modules/CMakeCXXCompilerId.cpp

@@ -48,9 +48,5 @@ static char const info_compiler[] = "INFO:compiler["
 /* Make sure the information strings are referenced.  */
 /* Make sure the information strings are referenced.  */
 int main()
 int main()
 {
 {
-  if(&info_compiler[0] != &info_platform[0])
-    {
-    return 1;
-    }
-  return 0;
+  return (&info_compiler[0] != &info_platform[0]);
 }
 }

+ 11 - 0
Modules/CMakeDetermineCompilerId.cmake

@@ -53,6 +53,10 @@ MACRO(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
       "${CMAKE_${lang}_COMPILER_ID_SRC}\" failed with the following output:\n"
       "${CMAKE_${lang}_COMPILER_ID_SRC}\" failed with the following output:\n"
       "${CMAKE_${lang}_COMPILER_ID_RESULT}\n"
       "${CMAKE_${lang}_COMPILER_ID_RESULT}\n"
       "${CMAKE_${lang}_COMPILER_ID_OUTPUT}\n\n")
       "${CMAKE_${lang}_COMPILER_ID_OUTPUT}\n\n")
+    MESSAGE(FATAL_ERROR "Compiling the ${lang} compiler identification source file \""
+      "${CMAKE_${lang}_COMPILER_ID_SRC}\" failed with the following output:\n"
+      "${CMAKE_${lang}_COMPILER_ID_RESULT}\n"
+      "${CMAKE_${lang}_COMPILER_ID_OUTPUT}\n\n")
   ELSE(CMAKE_${lang}_COMPILER_ID_RESULT)
   ELSE(CMAKE_${lang}_COMPILER_ID_RESULT)
     # Compilation succeeded.
     # Compilation succeeded.
     FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
     FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
@@ -110,5 +114,12 @@ MACRO(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
         "${CMAKE_${lang}_COMPILER_ID_DIR} "
         "${CMAKE_${lang}_COMPILER_ID_DIR} "
         "with a name known to CMake.\n\n")
         "with a name known to CMake.\n\n")
     ENDIF(CMAKE_${lang}_COMPILER_ID_EXE)
     ENDIF(CMAKE_${lang}_COMPILER_ID_EXE)
+
+    IF(CMAKE_${lang}_COMPILER_ID)
+      MESSAGE(STATUS "The ${lang} compiler identification is "
+        "${CMAKE_${lang}_COMPILER_ID}")
+    ELSE(CMAKE_${lang}_COMPILER_ID)
+      MESSAGE(STATUS "The ${lang} compiler identification is unknown")
+    ENDIF(CMAKE_${lang}_COMPILER_ID)
   ENDIF(CMAKE_${lang}_COMPILER_ID_RESULT)
   ENDIF(CMAKE_${lang}_COMPILER_ID_RESULT)
 ENDMACRO(CMAKE_DETERMINE_COMPILER_ID)
 ENDMACRO(CMAKE_DETERMINE_COMPILER_ID)