From eac71647ddab0eb52fe3ab20062519f7693ce44d Mon Sep 17 00:00:00 2001 From: Brad King Date: Sat, 28 Apr 2007 09:35:01 -0400 Subject: ENH: Merging CompilerId implementation from branch CMake-Modules-CompilerId to the main tree. Changes between CMake-Modules-CompilerId-bp and CMake-Modules-CompilerId-mp1 are included. --- Modules/CMakeCCompiler.cmake.in | 4 +- Modules/CMakeCCompilerId.c | 51 +++++++++++++++ Modules/CMakeCXXCompiler.cmake.in | 4 +- Modules/CMakeCXXCompilerId.cpp | 49 ++++++++++++++ Modules/CMakeDetermineCCompiler.cmake | 55 +++++++--------- Modules/CMakeDetermineCXXCompiler.cmake | 69 ++++++++++---------- Modules/CMakeDetermineCompilerId.cmake | 111 ++++++++++++++++++++++++++++++++ Modules/CMakePlatformId.h | 54 ++++++++++++++++ 8 files changed, 330 insertions(+), 67 deletions(-) create mode 100644 Modules/CMakeCCompilerId.c create mode 100644 Modules/CMakeCXXCompilerId.cpp create mode 100644 Modules/CMakeDetermineCompilerId.cmake create mode 100644 Modules/CMakePlatformId.h diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index bc21327..16c7d69 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -1,5 +1,7 @@ SET(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@") SET(CMAKE_C_COMPILER_ARG1 "@CMAKE_C_COMPILER_ARG1@") +SET(CMAKE_C_COMPILER_ID "@CMAKE_C_COMPILER_ID@") +SET(CMAKE_C_PLATFORM_ID "@CMAKE_C_PLATFORM_ID@") SET(CMAKE_AR "@CMAKE_AR@") SET(CMAKE_RANLIB "@CMAKE_RANLIB@") SET(CMAKE_COMPILER_IS_GNUCC @CMAKE_COMPILER_IS_GNUCC@) @@ -16,7 +18,7 @@ SET(CMAKE_C_COMPILER_ENV_VAR "CC") IF(CMAKE_COMPILER_IS_MINGW) SET(MINGW 1) ENDIF(CMAKE_COMPILER_IS_MINGW) -SET(CMAKE_COMPILER_IS_GNUCC_RUN 1) +SET(CMAKE_C_COMPILER_ID_RUN 1) SET(CMAKE_C_SOURCE_FILE_EXTENSIONS c) SET(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) SET(CMAKE_C_LINKER_PREFERENCE None) diff --git a/Modules/CMakeCCompilerId.c b/Modules/CMakeCCompilerId.c new file mode 100644 index 0000000..08a4128 --- /dev/null +++ b/Modules/CMakeCCompilerId.c @@ -0,0 +1,51 @@ +#ifdef __cplusplus +# error "A C++ compiler has been selected for C." +#endif + +#ifdef __CLASSIC_C__ +# define const +#endif + +static char const info_compiler[] = "INFO:compiler[" +#if defined(__INTEL_COMPILER) || defined(__ICC) +"Intel" +#elif defined(__BORLANDC__) +"Borland" +#elif defined(__WATCOMC__) +"Watcom" +#elif defined(__SUNPRO_C) +"SunPro" +#elif defined(__HP_cc) +"HP" +#elif defined(__DECC) +"Compaq" +#elif defined(__IBMC__) +"VisualAge" +#elif defined(__GNUC__) +"GNUC" +#elif defined(_MSC_VER) +"MSVC" +#elif defined(_COMPILER_VERSION) +"MIPSpro" + +/* This compiler is either not known or is too old to define an + identification macro. Try to identify the platform and guess that + it is the native compiler. */ +#elif defined(__sgi) +"MIPSpro" +#elif defined(__hpux) || defined(__hpua) +"HP" + +#else /* unknown compiler */ +"" +#endif +"]"; + +/* Include the platform identification source. */ +#include "CMakePlatformId.h" + +/* Make sure the information strings are referenced. */ +int main() +{ + return ((int)&info_compiler) + ((int)&info_platform); +} diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index ec04b6a..5fafd66 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -1,5 +1,7 @@ SET(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@") SET(CMAKE_CXX_COMPILER_ARG1 "@CMAKE_CXX_COMPILER_ARG1@") +SET(CMAKE_CXX_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@") +SET(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@") SET(CMAKE_AR "@CMAKE_AR@") SET(CMAKE_RANLIB "@CMAKE_RANLIB@") SET(CMAKE_COMPILER_IS_GNUCXX @CMAKE_COMPILER_IS_GNUCXX@) @@ -16,7 +18,7 @@ SET(CMAKE_CXX_COMPILER_ENV_VAR "CXX") IF(CMAKE_COMPILER_IS_MINGW) SET(MINGW 1) ENDIF(CMAKE_COMPILER_IS_MINGW) -SET(CMAKE_COMPILER_IS_GNUCXX_RUN 1) +SET(CMAKE_CXX_COMPILER_ID_RUN 1) SET(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;H;o;O;obj;OBJ;def;DEF;rc;RC) SET(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm) SET(CMAKE_CXX_LINKER_PREFERENCE Prefered) diff --git a/Modules/CMakeCXXCompilerId.cpp b/Modules/CMakeCXXCompilerId.cpp new file mode 100644 index 0000000..f133147 --- /dev/null +++ b/Modules/CMakeCXXCompilerId.cpp @@ -0,0 +1,49 @@ +#ifndef __cplusplus +# error "A C compiler has been selected for C++." +#endif + +static char const info_compiler[] = "INFO:compiler[" +#if defined(__COMO__) +"Comeau" +#elif defined(__INTEL_COMPILER) || defined(__ICC) +"Intel" +#elif defined(__BORLANDC__) +"Borland" +#elif defined(__WATCOMC__) +"Watcom" +#elif defined(__SUNPRO_CC) +"SunPro" +#elif defined(__HP_aCC) +"HP" +#elif defined(__DECCXX) +"Compaq" +#elif defined(__IBMCPP__) +"VisualAge" +#elif defined(__GNUC__) +"GNUC" +#elif defined(_MSC_VER) +"MSVC" +#elif defined(_COMPILER_VERSION) +"MIPSpro" + +/* This compiler is either not known or is too old to define an + identification macro. Try to identify the platform and guess that + it is the native compiler. */ +#elif defined(__sgi) +"MIPSpro" +#elif defined(__hpux) || defined(__hpua) +"HP" + +#else /* unknown compiler */ +"" +#endif +"]"; + +/* Include the platform identification source. */ +#include "CMakePlatformId.h" + +/* Make sure the information strings are referenced. */ +int main() +{ + return ((int)&info_compiler) + ((int)&info_platform); +} diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index c085947..eb79148 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -53,42 +53,33 @@ IF(NOT CMAKE_RANLIB) ENDIF(NOT CMAKE_RANLIB) MARK_AS_ADVANCED(CMAKE_RANLIB) -# do not test for GNU if the generator is visual studio +# Build a small source file to identify the compiler. IF(${CMAKE_GENERATOR} MATCHES "Visual Studio") - SET(CMAKE_COMPILER_IS_GNUCC_RUN 1) -ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio") + SET(CMAKE_C_COMPILER_ID_RUN 1) + SET(CMAKE_C_PLATFORM_ID "Windows") + # TODO: Set the compiler id. It is probably MSVC but + # the user may be using an integrated Intel compiler. + # SET(CMAKE_C_COMPILER_ID "MSVC") +ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio") +IF(NOT CMAKE_C_COMPILER_ID_RUN) + SET(CMAKE_C_COMPILER_ID_RUN 1) -IF(NOT CMAKE_COMPILER_IS_GNUCC_RUN) - # test to see if the c compiler is gnu - - IF(CMAKE_C_FLAGS) - SET(CMAKE_BOOT_C_FLAGS ${CMAKE_C_FLAGS}) - ELSE(CMAKE_C_FLAGS) - SET(CMAKE_BOOT_C_FLAGS $ENV{CFLAGS}) - ENDIF(CMAKE_C_FLAGS) - EXEC_PROGRAM(${CMAKE_C_COMPILER} ARGS ${CMAKE_BOOT_C_FLAGS} -E "\"${CMAKE_ROOT}/Modules/CMakeTestGNU.c\"" OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT RETURN_VALUE CMAKE_COMPILER_RETURN) - SET(CMAKE_COMPILER_IS_GNUCC_RUN 1) - IF(NOT CMAKE_COMPILER_RETURN) - IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" ) - SET(CMAKE_COMPILER_IS_GNUCC 1) - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the C compiler is GNU succeeded with " - "the following output:\n${CMAKE_COMPILER_OUTPUT}\n\n") - ELSE("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" ) - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the C compiler is GNU failed with " - "the following output:\n${CMAKE_COMPILER_OUTPUT}\n\n") - ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" ) - IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_MINGW.*" ) - SET(CMAKE_COMPILER_IS_MINGW 1) - ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_MINGW.*" ) - IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_CYGWIN.*" ) - SET(CMAKE_COMPILER_IS_CYGWIN 1) - ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_CYGWIN.*" ) - ENDIF(NOT CMAKE_COMPILER_RETURN) -ENDIF(NOT CMAKE_COMPILER_IS_GNUCC_RUN) + # Try to identify the compiler. + SET(CMAKE_C_COMPILER_ID) + INCLUDE(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) + CMAKE_DETERMINE_COMPILER_ID(C ${CMAKE_ROOT}/Modules/CMakeCCompilerId.c) + # Set old compiler and platform id variables. + IF("${CMAKE_C_COMPILER_ID}" MATCHES "GNU") + SET(CMAKE_COMPILER_IS_GNUCC 1) + ENDIF("${CMAKE_C_COMPILER_ID}" MATCHES "GNU") + IF("${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW") + SET(CMAKE_COMPILER_IS_MINGW 1) + ELSEIF("${CMAKE_C_PLATFORM_ID}" MATCHES "Cygwin") + SET(CMAKE_COMPILER_IS_CYGWIN 1) + ENDIF("${CMAKE_C_PLATFORM_ID}" MATCHES "MinGW") +ENDIF(NOT CMAKE_C_COMPILER_ID_RUN) # configure variables set in this file for fast reload later on CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeCCompiler.cmake.in diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index 494534d..372d27b 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -61,42 +61,45 @@ IF(NOT CMAKE_RANLIB) ENDIF(NOT CMAKE_RANLIB) MARK_AS_ADVANCED(CMAKE_RANLIB) -# do not test for GNU if the generator is visual studio -IF(${CMAKE_GENERATOR} MATCHES "Visual Studio") - SET(CMAKE_COMPILER_IS_GNUCXX_RUN 1) -ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio") - +# 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. +# # The g++ that comes with BeOS 5 segfaults if you run "g++ -E" # ("gcc -E" is fine), which throws up a system dialog box that hangs cmake # until the user clicks "OK"...so for now, we just assume it's g++. -IF(BEOS) - SET(CMAKE_COMPILER_IS_GNUCXX 1) - SET(CMAKE_COMPILER_IS_GNUCXX_RUN 1) -ENDIF(BEOS) - -IF(NOT CMAKE_COMPILER_IS_GNUCXX_RUN) - # test to see if the cxx compiler is gnu - SET(CMAKE_COMPILER_IS_GNUCXX_RUN 1) - EXEC_PROGRAM(${CMAKE_CXX_COMPILER} ARGS -E "\"${CMAKE_ROOT}/Modules/CMakeTestGNU.c\"" OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT RETURN_VALUE CMAKE_COMPILER_RETURN) - IF(NOT CMAKE_COMPILER_RETURN) - IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" ) - SET(CMAKE_COMPILER_IS_GNUCXX 1) - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the C++ compiler is GNU succeeded with " - "the following output:\n${CMAKE_COMPILER_OUTPUT}\n\n") - ELSE("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" ) - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the C++ compiler is GNU failed with " - "the following output:\n${CMAKE_COMPILER_OUTPUT}\n\n") - ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" ) - IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_MINGW.*" ) - SET(CMAKE_COMPILER_IS_MINGW 1) - ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_MINGW.*" ) - IF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_CYGWIN.*" ) - SET(CMAKE_COMPILER_IS_CYGWIN 1) - ENDIF("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_CYGWIN.*" ) - ENDIF(NOT CMAKE_COMPILER_RETURN) -ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX_RUN) +# IF(BEOS) +# SET(CMAKE_COMPILER_IS_GNUCXX 1) +# SET(CMAKE_COMPILER_IS_GNUCXX_RUN 1) +# ENDIF(BEOS) + +# Build a small source file to identify the compiler. +IF(${CMAKE_GENERATOR} MATCHES "Visual Studio") + SET(CMAKE_CXX_COMPILER_ID_RUN 1) + SET(CMAKE_CXX_PLATFORM_ID "Windows") + + # TODO: Set the compiler id. It is probably MSVC but + # the user may be using an integrated Intel compiler. + # SET(CMAKE_CXX_COMPILER_ID "MSVC") +ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio") +IF(NOT CMAKE_CXX_COMPILER_ID_RUN) + SET(CMAKE_CXX_COMPILER_ID_RUN 1) + + # Try to identify the compiler. + SET(CMAKE_CXX_COMPILER_ID) + INCLUDE(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) + CMAKE_DETERMINE_COMPILER_ID(CXX ${CMAKE_ROOT}/Modules/CMakeCXXCompilerId.cpp) + + # Set old compiler and platform id variables. + IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + SET(CMAKE_COMPILER_IS_GNUCXX 1) + ENDIF("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") + IF("${CMAKE_CXX_PLATFORM_ID}" MATCHES "MinGW") + SET(CMAKE_COMPILER_IS_MINGW 1) + ELSEIF("${CMAKE_CXX_PLATFORM_ID}" MATCHES "Cygwin") + SET(CMAKE_COMPILER_IS_CYGWIN 1) + ENDIF("${CMAKE_CXX_PLATFORM_ID}" MATCHES "MinGW") +ENDIF(NOT CMAKE_CXX_COMPILER_ID_RUN) # configure all variables set in this file CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CMakeCXXCompiler.cmake.in diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake new file mode 100644 index 0000000..a7fe44c --- /dev/null +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -0,0 +1,111 @@ + +# Macro to compile a source file to identify the compiler. This is +# used internally by CMake and should not be included by user code. +MACRO(CMAKE_DETERMINE_COMPILER_ID lang src) + # Store the compiler identification source file. + SET(CMAKE_${lang}_COMPILER_ID_SRC "${src}") + IF(WIN32 AND NOT CYGWIN) + # This seems to escape spaces: + #FILE(TO_NATIVE_PATH "${CMAKE_${lang}_COMPILER_ID_SRC}" + # CMAKE_${lang}_COMPILER_ID_SRC) + STRING(REGEX REPLACE "/" "\\\\" CMAKE_${lang}_COMPILER_ID_SRC + "${CMAKE_${lang}_COMPILER_ID_SRC}") + ENDIF(WIN32 AND NOT CYGWIN) + + # Make sure user-specified compiler flags are used. + IF(CMAKE_${lang}_FLAGS) + SET(CMAKE_${lang}_COMPILER_ID_FLAGS ${CMAKE_${lang}_FLAGS}) + ELSE(CMAKE_${lang}_FLAGS) + SET(CMAKE_${lang}_COMPILER_ID_FLAGS $ENV{${lang}FLAGS}) + ENDIF(CMAKE_${lang}_FLAGS) + + # Create an empty directory in which to run the test. + SET(CMAKE_${lang}_COMPILER_ID_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CompilerId${lang}) + FILE(REMOVE_RECURSE ${CMAKE_${lang}_COMPILER_ID_DIR}) + FILE(MAKE_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}) + + # Compile the compiler identification source. + STRING(REGEX REPLACE " " ";" CMAKE_${lang}_COMPILER_ID_FLAGS_LIST "${CMAKE_${lang}_COMPILER_ID_FLAGS}") + IF(COMMAND EXECUTE_PROCESS) + EXECUTE_PROCESS( + COMMAND ${CMAKE_${lang}_COMPILER} ${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST} ${CMAKE_${lang}_COMPILER_ID_SRC} + WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR} + OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT + ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT + RESULT_VARIABLE CMAKE_${lang}_COMPILER_ID_RESULT + ) + ELSE(COMMAND EXECUTE_PROCESS) + EXEC_PROGRAM( + ${CMAKE_${lang}_COMPILER} ${CMAKE_${lang}_COMPILER_ID_DIR} + ARGS ${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST} \"${CMAKE_${lang}_COMPILER_ID_SRC}\" + OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT + RETURN_VALUE CMAKE_${lang}_COMPILER_ID_RESULT + ) + ENDIF(COMMAND EXECUTE_PROCESS) + + # Check the result of compilation. + IF(CMAKE_${lang}_COMPILER_ID_RESULT) + # Compilation failed. + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "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) + # Compilation succeeded. + FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Compiling the ${lang} compiler identification source file \"" + "${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. + 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") + + # 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}") + ELSEIF("${info}" MATCHES ".*INFO:platform\\[(.*)\\].*") + STRING(REGEX REPLACE ".*INFO:platform\\[(.*)\\].*" "\\1" + CMAKE_${lang}_PLATFORM_ID "${info}") + ENDIF("${info}" MATCHES ".*INFO:compiler\\[(.*)\\].*") + 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}\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. + 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) + ENDIF(CMAKE_${lang}_COMPILER_ID_RESULT) +ENDMACRO(CMAKE_DETERMINE_COMPILER_ID) diff --git a/Modules/CMakePlatformId.h b/Modules/CMakePlatformId.h new file mode 100644 index 0000000..e7e0d50 --- /dev/null +++ b/Modules/CMakePlatformId.h @@ -0,0 +1,54 @@ +/* Identify known platforms by name. */ +static char const info_platform[] = "INFO:platform[" +#if defined(__linux) || defined(__linux__) || defined(linux) +"Linux" +#elif defined(__CYGWIN__) +"Cygwin" +#elif defined(__MINGW32__) +"MinGW" +#elif defined(__APPLE__) +"Darwin" +#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +"Windows" +#elif defined(__FreeBSD__) || defined(__FreeBSD) +"FreeBSD" +#elif defined(__NetBSD__) || defined(__NetBSD) +"NetBSD" +#elif defined(__OpenBSD__) || defined(__OPENBSD) +"OpenBSD" +#elif defined(__sun) || defined(sun) +"SunOS" +#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) +"AIX" +#elif defined(__sgi) || defined(__sgi__) || defined(_SGI) +"IRIX" +#elif defined(__hpux) || defined(__hpux__) +"HP-UX" +#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) +"BeOS" +#elif defined(__QNX__) || defined(__QNXNTO__) +"QNX" +#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) +"Tru64" +#elif defined(__riscos) || defined(__riscos__) +"RISCos" +#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) +"SINIX" +#elif defined(__UNIX_SV__) +"UNIX_SV" +#elif defined(__bsdos__) +"BSDOS" +#elif defined(_MPRAS) || defined(MPRAS) +"MP-RAS" +#elif defined(__osf) || defined(__osf__) +"OSF1" +#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) +"SCO_SV" +#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) +"ULTRIX" +#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) +"Xenix" +#else /* unknown platform */ +"" +#endif +"]"; -- cgit v0.12