From 9211b0d23482c0fee8dc64171cf3524feb1ae446 Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 25 Feb 2008 09:23:14 -0500 Subject: ENH: Improvied compiler identification robustness - Write a single source file into the compiler id directory - This avoid requiring the compiler to behave correctly with respect to include rules and the current working directory - Helps to identify cross-compiling toolchains with unusual default behavior --- Modules/CMakeCCompilerId.c | 81 ----------------------------- Modules/CMakeCCompilerId.c.in | 73 ++++++++++++++++++++++++++ Modules/CMakeCXXCompilerId.cpp | 72 ------------------------- Modules/CMakeCXXCompilerId.cpp.in | 68 ++++++++++++++++++++++++ Modules/CMakeDetermineCCompiler.cmake | 4 +- Modules/CMakeDetermineCXXCompiler.cmake | 4 +- Modules/CMakeDetermineCompilerId.cmake | 76 ++++++++++++++------------- Modules/CMakeDetermineFortranCompiler.cmake | 2 +- Modules/CMakeFortranCompilerId.F90 | 78 --------------------------- Modules/CMakeFortranCompilerId.F90.in | 78 +++++++++++++++++++++++++++ Modules/CMakePlatformId.h | 79 ---------------------------- Modules/CMakePlatformId.h.in | 79 ++++++++++++++++++++++++++++ 12 files changed, 344 insertions(+), 350 deletions(-) delete mode 100644 Modules/CMakeCCompilerId.c create mode 100644 Modules/CMakeCCompilerId.c.in delete mode 100644 Modules/CMakeCXXCompilerId.cpp create mode 100644 Modules/CMakeCXXCompilerId.cpp.in delete mode 100644 Modules/CMakeFortranCompilerId.F90 create mode 100644 Modules/CMakeFortranCompilerId.F90.in delete mode 100644 Modules/CMakePlatformId.h create mode 100644 Modules/CMakePlatformId.h.in diff --git a/Modules/CMakeCCompilerId.c b/Modules/CMakeCCompilerId.c deleted file mode 100644 index ec11b6c..0000000 --- a/Modules/CMakeCCompilerId.c +++ /dev/null @@ -1,81 +0,0 @@ -#ifdef __cplusplus -# error "A C++ compiler has been selected for C." -#endif - -#ifdef __CLASSIC_C__ -# define const -#endif - -#if defined(__INTEL_COMPILER) || defined(__ICC) -# define COMPILER_ID "Intel" - -#elif defined(__BORLANDC__) -# define COMPILER_ID "Borland" - -#elif defined(__WATCOMC__) -# define COMPILER_ID "Watcom" - -#elif defined(__SUNPRO_C) -# define COMPILER_ID "SunPro" - -#elif defined(__HP_cc) -# define COMPILER_ID "HP" - -#elif defined(__DECC) -# define COMPILER_ID "Compaq" - -#elif defined(__IBMC__) -# define COMPILER_ID "VisualAge" - -#elif defined(__PGI) -# define COMPILER_ID "PGI" - -#elif defined(__GNUC__) -# define COMPILER_ID "GNU" - -#elif defined(_MSC_VER) -# define COMPILER_ID "MSVC" - -#elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) -/* Analog Devices C++ compiler for Blackfin, TigerSHARC and - SHARC (21000) DSPs */ -# define COMPILER_ID "ADSP" - -/* IAR Systems compiler for embedded systems. - http://www.iar.com - Not supported yet by CMake -#elif defined(__IAR_SYSTEMS_ICC__) -# define COMPILER_ID "IAR" */ - -/* sdcc, the small devices C compiler for embedded systems, - http://sdcc.sourceforge.net */ -#elif defined(SDCC) -# define COMPILER_ID "SDCC" - -#elif defined(_COMPILER_VERSION) -# define COMPILER_ID "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) -# define COMPILER_ID "MIPSpro" - -#elif defined(__hpux) || defined(__hpua) -# define COMPILER_ID "HP" - -#else /* unknown compiler */ -# define COMPILER_ID "" - -#endif - -static char const info_compiler[] = "INFO:compiler[" COMPILER_ID "]"; - -/* Include the platform identification source. */ -#include "CMakePlatformId.h" - -/* Make sure the information strings are referenced. */ -int main() -{ - return (&info_compiler[0] != &info_platform[0]); -} diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in new file mode 100644 index 0000000..e9675ca --- /dev/null +++ b/Modules/CMakeCCompilerId.c.in @@ -0,0 +1,73 @@ +#ifdef __cplusplus +# error "A C++ compiler has been selected for C." +#endif + +/* Provide main() so the program can link. */ +int main() { return 0; } + +#if defined(__INTEL_COMPILER) || defined(__ICC) +# define COMPILER_ID "Intel" + +#elif defined(__BORLANDC__) +# define COMPILER_ID "Borland" + +#elif defined(__WATCOMC__) +# define COMPILER_ID "Watcom" + +#elif defined(__SUNPRO_C) +# define COMPILER_ID "SunPro" + +#elif defined(__HP_cc) +# define COMPILER_ID "HP" + +#elif defined(__DECC) +# define COMPILER_ID "Compaq" + +#elif defined(__IBMC__) +# define COMPILER_ID "VisualAge" + +#elif defined(__PGI) +# define COMPILER_ID "PGI" + +#elif defined(__GNUC__) +# define COMPILER_ID "GNU" + +#elif defined(_MSC_VER) +# define COMPILER_ID "MSVC" + +#elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) +/* Analog Devices C++ compiler for Blackfin, TigerSHARC and + SHARC (21000) DSPs */ +# define COMPILER_ID "ADSP" + +/* IAR Systems compiler for embedded systems. + http://www.iar.com + Not supported yet by CMake +#elif defined(__IAR_SYSTEMS_ICC__) +# define COMPILER_ID "IAR" */ + +/* sdcc, the small devices C compiler for embedded systems, + http://sdcc.sourceforge.net */ +#elif defined(SDCC) +# define COMPILER_ID "SDCC" + +#elif defined(_COMPILER_VERSION) +# define COMPILER_ID "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) +# define COMPILER_ID "MIPSpro" + +#elif defined(__hpux) || defined(__hpua) +# define COMPILER_ID "HP" + +#else /* unknown compiler */ +# define COMPILER_ID "" + +#endif + +char info_compiler[] = "INFO:compiler[" COMPILER_ID "]"; + +@CMAKE_C_COMPILER_ID_PLATFORM_CONTENT@ diff --git a/Modules/CMakeCXXCompilerId.cpp b/Modules/CMakeCXXCompilerId.cpp deleted file mode 100644 index 86d65bd..0000000 --- a/Modules/CMakeCXXCompilerId.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* This source file must have a .cpp extension so that all C++ compilers - recognize the extension without flags. Borland does not know .cxx for - example. */ -#ifndef __cplusplus -# error "A C compiler has been selected for C++." -#endif - -#if defined(__COMO__) -# define COMPILER_ID "Comeau" - -#elif defined(__INTEL_COMPILER) || defined(__ICC) -# define COMPILER_ID "Intel" - -#elif defined(__BORLANDC__) -# define COMPILER_ID "Borland" - -#elif defined(__WATCOMC__) -# define COMPILER_ID "Watcom" - -#elif defined(__SUNPRO_CC) -# define COMPILER_ID "SunPro" - -#elif defined(__HP_aCC) -# define COMPILER_ID "HP" - -#elif defined(__DECCXX) -# define COMPILER_ID "Compaq" - -#elif defined(__IBMCPP__) -# define COMPILER_ID "VisualAge" - -#elif defined(__PGI) -# define COMPILER_ID "PGI" - -#elif defined(__GNUC__) -# define COMPILER_ID "GNU" - -#elif defined(_MSC_VER) -# define COMPILER_ID "MSVC" - -#elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) -/* Analog Devices C++ compiler for Blackfin, TigerSHARC and - SHARC (21000) DSPs */ -# define COMPILER_ID "ADSP" - -#elif defined(_COMPILER_VERSION) -# define COMPILER_ID "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) -# define COMPILER_ID "MIPSpro" - -#elif defined(__hpux) || defined(__hpua) -# define COMPILER_ID "HP" - -#else /* unknown compiler */ -# define COMPILER_ID "" - -#endif - -static char const info_compiler[] = "INFO:compiler[" COMPILER_ID "]"; - -/* Include the platform identification source. */ -#include "CMakePlatformId.h" - -/* Make sure the information strings are referenced. */ -int main() -{ - return (&info_compiler[0] != &info_platform[0]); -} diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in new file mode 100644 index 0000000..7bdb5e0 --- /dev/null +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -0,0 +1,68 @@ +/* This source file must have a .cpp extension so that all C++ compilers + recognize the extension without flags. Borland does not know .cxx for + example. */ +#ifndef __cplusplus +# error "A C compiler has been selected for C++." +#endif + +/* Provide main() so the program can link. */ +int main() { return 0; } + +#if defined(__COMO__) +# define COMPILER_ID "Comeau" + +#elif defined(__INTEL_COMPILER) || defined(__ICC) +# define COMPILER_ID "Intel" + +#elif defined(__BORLANDC__) +# define COMPILER_ID "Borland" + +#elif defined(__WATCOMC__) +# define COMPILER_ID "Watcom" + +#elif defined(__SUNPRO_CC) +# define COMPILER_ID "SunPro" + +#elif defined(__HP_aCC) +# define COMPILER_ID "HP" + +#elif defined(__DECCXX) +# define COMPILER_ID "Compaq" + +#elif defined(__IBMCPP__) +# define COMPILER_ID "VisualAge" + +#elif defined(__PGI) +# define COMPILER_ID "PGI" + +#elif defined(__GNUC__) +# define COMPILER_ID "GNU" + +#elif defined(_MSC_VER) +# define COMPILER_ID "MSVC" + +#elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) +/* Analog Devices C++ compiler for Blackfin, TigerSHARC and + SHARC (21000) DSPs */ +# define COMPILER_ID "ADSP" + +#elif defined(_COMPILER_VERSION) +# define COMPILER_ID "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) +# define COMPILER_ID "MIPSpro" + +#elif defined(__hpux) || defined(__hpua) +# define COMPILER_ID "HP" + +#else /* unknown compiler */ +# define COMPILER_ID "" + +#endif + +char info_compiler[] = "INFO:compiler[" COMPILER_ID "]"; + +@CMAKE_CXX_COMPILER_ID_PLATFORM_CONTENT@ diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake index 3ae9ba2..ffe0703 100644 --- a/Modules/CMakeDetermineCCompiler.cmake +++ b/Modules/CMakeDetermineCCompiler.cmake @@ -122,8 +122,10 @@ IF(NOT CMAKE_C_COMPILER_ID_RUN) # Try to identify the compiler. SET(CMAKE_C_COMPILER_ID) + FILE(READ ${CMAKE_ROOT}/Modules/CMakePlatformId.h.in + CMAKE_C_COMPILER_ID_PLATFORM_CONTENT) INCLUDE(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) - CMAKE_DETERMINE_COMPILER_ID(C CFLAGS ${CMAKE_ROOT}/Modules/CMakeCCompilerId.c) + CMAKE_DETERMINE_COMPILER_ID(C CFLAGS CMakeCCompilerId.c) # Set old compiler and platform id variables. IF("${CMAKE_C_COMPILER_ID}" MATCHES "GNU") diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake index d354165..b024034 100644 --- a/Modules/CMakeDetermineCXXCompiler.cmake +++ b/Modules/CMakeDetermineCXXCompiler.cmake @@ -132,8 +132,10 @@ IF(NOT CMAKE_CXX_COMPILER_ID_RUN) # Try to identify the compiler. SET(CMAKE_CXX_COMPILER_ID) + FILE(READ ${CMAKE_ROOT}/Modules/CMakePlatformId.h.in + CMAKE_CXX_COMPILER_ID_PLATFORM_CONTENT) INCLUDE(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) - CMAKE_DETERMINE_COMPILER_ID(CXX CXXFLAGS ${CMAKE_ROOT}/Modules/CMakeCXXCompilerId.cpp) + CMAKE_DETERMINE_COMPILER_ID(CXX CXXFLAGS CMakeCXXCompilerId.cpp) # Set old compiler and platform id variables. IF("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index d684fb8..05c8ca6 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -4,16 +4,6 @@ # If successful, sets CMAKE__COMPILER_ID and CMAKE__PLATFORM_ID FUNCTION(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) - # Store the compiler identification source file. - SET(CMAKE_${lang}_COMPILER_ID_SRC "${src}") - IF(CMAKE_HOST_WIN32 AND NOT CMAKE_HOST_UNIX) - # 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(CMAKE_HOST_WIN32 AND NOT CMAKE_HOST_UNIX) - # Make sure the compiler arguments are clean. STRING(STRIP "${CMAKE_${lang}_COMPILER_ARG1}" CMAKE_${lang}_COMPILER_ID_ARG1) @@ -32,9 +22,9 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) # of helper flags. Stop when the compiler is identified. FOREACH(flags "" ${CMAKE_${lang}_COMPILER_ID_TEST_FLAGS}) IF(NOT CMAKE_${lang}_COMPILER_ID) - CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${flags}") + CMAKE_DETERMINE_COMPILER_ID_BUILD("${lang}" "${flags}" "${src}") FOREACH(file ${COMPILER_${lang}_PRODUCED_FILES}) - CMAKE_DETERMINE_COMPILER_ID_CHECK("${lang}" "${file}") + CMAKE_DETERMINE_COMPILER_ID_CHECK("${lang}" "${CMAKE_${lang}_COMPILER_ID_DIR}/${file}" "${src}") ENDFOREACH(file) ENDIF(NOT CMAKE_${lang}_COMPILER_ID) ENDFOREACH(flags) @@ -57,19 +47,28 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID) #----------------------------------------------------------------------------- +# Function to write the compiler id source file. +FUNCTION(CMAKE_DETERMINE_COMPILER_ID_WRITE lang src) + FILE(READ ${CMAKE_ROOT}/Modules/${src}.in ID_CONTENT_IN) + STRING(CONFIGURE "${ID_CONTENT_IN}" ID_CONTENT_OUT @ONLY) + FILE(WRITE ${CMAKE_${lang}_COMPILER_ID_DIR}/${src} "${ID_CONTENT_OUT}") +ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_WRITE) + +#----------------------------------------------------------------------------- # Function to build the compiler id source file and look for output # files. -FUNCTION(CMAKE_DETERMINE_COMPILER_ID_BUILD lang testflags) +FUNCTION(CMAKE_DETERMINE_COMPILER_ID_BUILD lang testflags src) # Create a clean working directory. FILE(REMOVE_RECURSE ${CMAKE_${lang}_COMPILER_ID_DIR}) FILE(MAKE_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR}) + CMAKE_DETERMINE_COMPILER_ID_WRITE("${lang}" "${src}") # Construct a description of this test case. SET(COMPILER_DESCRIPTION - "Compiler: ${CMAKE_${lang}_COMPILER} ${CMAKE_${lang}_COMPILER_ID_ARG1}\n" - "Build flags: ${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST}\n" - "Id flags: ${testflags}\n" - ) + "Compiler: ${CMAKE_${lang}_COMPILER} ${CMAKE_${lang}_COMPILER_ID_ARG1} +Build flags: ${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST} +Id flags: ${testflags} +") # Compile the compiler identification source. IF(COMMAND EXECUTE_PROCESS) @@ -78,7 +77,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_BUILD lang testflags) ${CMAKE_${lang}_COMPILER_ID_ARG1} ${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST} ${testflags} - ${CMAKE_${lang}_COMPILER_ID_SRC} + "${src}" WORKING_DIRECTORY ${CMAKE_${lang}_COMPILER_ID_DIR} OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT ERROR_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT @@ -90,7 +89,7 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_BUILD lang testflags) ARGS ${CMAKE_${lang}_COMPILER_ID_ARG1} ${CMAKE_${lang}_COMPILER_ID_FLAGS_LIST} ${testflags} - \"${CMAKE_${lang}_COMPILER_ID_SRC}\" + \"${src}\" OUTPUT_VARIABLE CMAKE_${lang}_COMPILER_ID_OUTPUT RETURN_VALUE CMAKE_${lang}_COMPILER_ID_RESULT ) @@ -100,13 +99,13 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_BUILD lang testflags) IF(CMAKE_${lang}_COMPILER_ID_RESULT) # Compilation failed. SET(MSG - "Compiling the ${lang} compiler identification source file \"" - "${CMAKE_${lang}_COMPILER_ID_SRC}\" failed.\n" - ${COMPILER_DESCRIPTION} - "The output was:\n" - "${CMAKE_${lang}_COMPILER_ID_RESULT}\n" - "${CMAKE_${lang}_COMPILER_ID_OUTPUT}\n\n" - ) + "Compiling the ${lang} compiler identification source file \"${src}\" failed. +${COMPILER_DESCRIPTION} +The output was: +${CMAKE_${lang}_COMPILER_ID_RESULT} +${CMAKE_${lang}_COMPILER_ID_OUTPUT} + +") FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "${MSG}") #IF(NOT CMAKE_${lang}_COMPILER_ID_ALLOW_FAIL) # MESSAGE(FATAL_ERROR "${MSG}") @@ -117,35 +116,38 @@ FUNCTION(CMAKE_DETERMINE_COMPILER_ID_BUILD lang testflags) 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.\n" - ${COMPILER_DESCRIPTION} - "The output was:\n" - "${CMAKE_${lang}_COMPILER_ID_RESULT}\n" - "${CMAKE_${lang}_COMPILER_ID_OUTPUT}\n\n" - ) + "Compiling the ${lang} compiler identification source file \"${src}\" succeeded. +${COMPILER_DESCRIPTION} +The output was: +${CMAKE_${lang}_COMPILER_ID_RESULT} +${CMAKE_${lang}_COMPILER_ID_OUTPUT} + +") # Find the executable produced by the compiler, try all files in the # binary dir. - FILE(GLOB COMPILER_${lang}_PRODUCED_FILES ${CMAKE_${lang}_COMPILER_ID_DIR}/*) + FILE(GLOB COMPILER_${lang}_PRODUCED_FILES + RELATIVE ${CMAKE_${lang}_COMPILER_ID_DIR} + ${CMAKE_${lang}_COMPILER_ID_DIR}/*) + LIST(REMOVE_ITEM COMPILER_${lang}_PRODUCED_FILES "${src}") FOREACH(file ${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 \"${file}\"\n\n") + "${src}\" produced \"${file}\"\n\n") ENDFOREACH(file) 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 \"" + "${src}\" did not produce an executable in \"" "${CMAKE_${lang}_COMPILER_ID_DIR}\".\n\n") ENDIF(NOT COMPILER_${lang}_PRODUCED_FILES) ENDIF(CMAKE_${lang}_COMPILER_ID_RESULT) # Return the files produced by the compilation. SET(COMPILER_${lang}_PRODUCED_FILES "${COMPILER_${lang}_PRODUCED_FILES}" PARENT_SCOPE) -ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_BUILD lang testflags) +ENDFUNCTION(CMAKE_DETERMINE_COMPILER_ID_BUILD lang testflags src) #----------------------------------------------------------------------------- # Function to extract the compiler id from an executable. diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake index 1f2ce80..defb5a7 100644 --- a/Modules/CMakeDetermineFortranCompiler.cmake +++ b/Modules/CMakeDetermineFortranCompiler.cmake @@ -94,7 +94,7 @@ IF(NOT CMAKE_Fortran_COMPILER_ID_RUN) # Try to identify the compiler. SET(CMAKE_Fortran_COMPILER_ID) INCLUDE(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake) - CMAKE_DETERMINE_COMPILER_ID(Fortran FFLAGS ${CMAKE_ROOT}/Modules/CMakeFortranCompilerId.F90) + CMAKE_DETERMINE_COMPILER_ID(Fortran FFLAGS CMakeFortranCompilerId.F90) # Fall back to old is-GNU test. IF(NOT CMAKE_Fortran_COMPILER_ID) diff --git a/Modules/CMakeFortranCompilerId.F90 b/Modules/CMakeFortranCompilerId.F90 deleted file mode 100644 index 870c204..0000000 --- a/Modules/CMakeFortranCompilerId.F90 +++ /dev/null @@ -1,78 +0,0 @@ -PROGRAM CMakeFortranCompilerId -! Identify the compiler -#if defined(__INTEL_COMPILER) || defined(__ICC) - PRINT *, 'INFO:compiler[Intel]' -#elif defined(__SUNPRO_F90) || defined(__SUNPRO_F95) - PRINT *, 'INFO:compiler[SunPro]' -#elif defined(__GNUC__) - PRINT *, 'INFO:compiler[GNU]' -#elif defined(__IBM__) || defined(__IBMC__) - PRINT *, 'INFO:compiler[VisualAge]' -#elif defined(_COMPILER_VERSION) - PRINT *, 'INFO:compiler[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(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) - PRINT *, 'INFO:compiler[VisualAge]' -#elif defined(__sgi) || defined(__sgi__) || defined(_SGI) - PRINT *, 'INFO:compiler[MIPSpro]' -#elif defined(__hpux) || defined(__hpux__) - PRINT *, 'INFO:compiler[HP]' -#else - PRINT *, 'INFO:compiler[]' -#endif - -! Identify the platform -#if defined(__linux) || defined(__linux__) || defined(linux) - PRINT *, 'INFO:platform[Linux]' -#elif defined(__CYGWIN__) - PRINT *, 'INFO:platform[Cygwin]' -#elif defined(__MINGW32__) - PRINT *, 'INFO:platform[MinGW]' -#elif defined(__APPLE__) - PRINT *, 'INFO:platform[Darwin]' -#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) - PRINT *, 'INFO:platform[Windows]' -#elif defined(__FreeBSD__) || defined(__FreeBSD) - PRINT *, 'INFO:platform[FreeBSD]' -#elif defined(__NetBSD__) || defined(__NetBSD) - PRINT *, 'INFO:platform[NetBSD]' -#elif defined(__OpenBSD__) || defined(__OPENBSD) - PRINT *, 'INFO:platform[OpenBSD]' -#elif defined(__sun) || defined(sun) - PRINT *, 'INFO:platform[SunOS]' -#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) - PRINT *, 'INFO:platform[AIX]' -#elif defined(__sgi) || defined(__sgi__) || defined(_SGI) - PRINT *, 'INFO:platform[IRIX]' -#elif defined(__hpux) || defined(__hpux__) - PRINT *, 'INFO:platform[HP-UX]' -#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) - PRINT *, 'INFO:platform[BeOS]' -#elif defined(__QNX__) || defined(__QNXNTO__) - PRINT *, 'INFO:platform[QNX]' -#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) - PRINT *, 'INFO:platform[Tru64]' -#elif defined(__riscos) || defined(__riscos__) - PRINT *, 'INFO:platform[RISCos]' -#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) - PRINT *, 'INFO:platform[SINIX]' -#elif defined(__UNIX_SV__) - PRINT *, 'INFO:platform[UNIX_SV]' -#elif defined(__bsdos__) - PRINT *, 'INFO:platform[BSDOS]' -#elif defined(_MPRAS) || defined(MPRAS) - PRINT *, 'INFO:platform[MP-RAS]' -#elif defined(__osf) || defined(__osf__) - PRINT *, 'INFO:platform[OSF1]' -#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) - PRINT *, 'INFO:platform[SCO_SV]' -#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) - PRINT *, 'INFO:platform[ULTRIX]' -#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) - PRINT *, 'INFO:platform[Xenix]' -#else - PRINT *, 'INFO:platform[]' -#endif -END PROGRAM diff --git a/Modules/CMakeFortranCompilerId.F90.in b/Modules/CMakeFortranCompilerId.F90.in new file mode 100644 index 0000000..870c204 --- /dev/null +++ b/Modules/CMakeFortranCompilerId.F90.in @@ -0,0 +1,78 @@ +PROGRAM CMakeFortranCompilerId +! Identify the compiler +#if defined(__INTEL_COMPILER) || defined(__ICC) + PRINT *, 'INFO:compiler[Intel]' +#elif defined(__SUNPRO_F90) || defined(__SUNPRO_F95) + PRINT *, 'INFO:compiler[SunPro]' +#elif defined(__GNUC__) + PRINT *, 'INFO:compiler[GNU]' +#elif defined(__IBM__) || defined(__IBMC__) + PRINT *, 'INFO:compiler[VisualAge]' +#elif defined(_COMPILER_VERSION) + PRINT *, 'INFO:compiler[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(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) + PRINT *, 'INFO:compiler[VisualAge]' +#elif defined(__sgi) || defined(__sgi__) || defined(_SGI) + PRINT *, 'INFO:compiler[MIPSpro]' +#elif defined(__hpux) || defined(__hpux__) + PRINT *, 'INFO:compiler[HP]' +#else + PRINT *, 'INFO:compiler[]' +#endif + +! Identify the platform +#if defined(__linux) || defined(__linux__) || defined(linux) + PRINT *, 'INFO:platform[Linux]' +#elif defined(__CYGWIN__) + PRINT *, 'INFO:platform[Cygwin]' +#elif defined(__MINGW32__) + PRINT *, 'INFO:platform[MinGW]' +#elif defined(__APPLE__) + PRINT *, 'INFO:platform[Darwin]' +#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) + PRINT *, 'INFO:platform[Windows]' +#elif defined(__FreeBSD__) || defined(__FreeBSD) + PRINT *, 'INFO:platform[FreeBSD]' +#elif defined(__NetBSD__) || defined(__NetBSD) + PRINT *, 'INFO:platform[NetBSD]' +#elif defined(__OpenBSD__) || defined(__OPENBSD) + PRINT *, 'INFO:platform[OpenBSD]' +#elif defined(__sun) || defined(sun) + PRINT *, 'INFO:platform[SunOS]' +#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) + PRINT *, 'INFO:platform[AIX]' +#elif defined(__sgi) || defined(__sgi__) || defined(_SGI) + PRINT *, 'INFO:platform[IRIX]' +#elif defined(__hpux) || defined(__hpux__) + PRINT *, 'INFO:platform[HP-UX]' +#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) + PRINT *, 'INFO:platform[BeOS]' +#elif defined(__QNX__) || defined(__QNXNTO__) + PRINT *, 'INFO:platform[QNX]' +#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) + PRINT *, 'INFO:platform[Tru64]' +#elif defined(__riscos) || defined(__riscos__) + PRINT *, 'INFO:platform[RISCos]' +#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) + PRINT *, 'INFO:platform[SINIX]' +#elif defined(__UNIX_SV__) + PRINT *, 'INFO:platform[UNIX_SV]' +#elif defined(__bsdos__) + PRINT *, 'INFO:platform[BSDOS]' +#elif defined(_MPRAS) || defined(MPRAS) + PRINT *, 'INFO:platform[MP-RAS]' +#elif defined(__osf) || defined(__osf__) + PRINT *, 'INFO:platform[OSF1]' +#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) + PRINT *, 'INFO:platform[SCO_SV]' +#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) + PRINT *, 'INFO:platform[ULTRIX]' +#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) + PRINT *, 'INFO:platform[Xenix]' +#else + PRINT *, 'INFO:platform[]' +#endif +END PROGRAM diff --git a/Modules/CMakePlatformId.h b/Modules/CMakePlatformId.h deleted file mode 100644 index 1907422..0000000 --- a/Modules/CMakePlatformId.h +++ /dev/null @@ -1,79 +0,0 @@ -/* Identify known platforms by name. */ -#if defined(__linux) || defined(__linux__) || defined(linux) -# define PLATFORM_ID "Linux" - -#elif defined(__CYGWIN__) -# define PLATFORM_ID "Cygwin" - -#elif defined(__MINGW32__) -# define PLATFORM_ID "MinGW" - -#elif defined(__APPLE__) -# define PLATFORM_ID "Darwin" - -#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) -# define PLATFORM_ID "Windows" - -#elif defined(__FreeBSD__) || defined(__FreeBSD) -# define PLATFORM_ID "FreeBSD" - -#elif defined(__NetBSD__) || defined(__NetBSD) -# define PLATFORM_ID "NetBSD" - -#elif defined(__OpenBSD__) || defined(__OPENBSD) -# define PLATFORM_ID "OpenBSD" - -#elif defined(__sun) || defined(sun) -# define PLATFORM_ID "SunOS" - -#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) -# define PLATFORM_ID "AIX" - -#elif defined(__sgi) || defined(__sgi__) || defined(_SGI) -# define PLATFORM_ID "IRIX" - -#elif defined(__hpux) || defined(__hpux__) -# define PLATFORM_ID "HP-UX" - -#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) -# define PLATFORM_ID "BeOS" - -#elif defined(__QNX__) || defined(__QNXNTO__) -# define PLATFORM_ID "QNX" - -#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) -# define PLATFORM_ID "Tru64" - -#elif defined(__riscos) || defined(__riscos__) -# define PLATFORM_ID "RISCos" - -#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) -# define PLATFORM_ID "SINIX" - -#elif defined(__UNIX_SV__) -# define PLATFORM_ID "UNIX_SV" - -#elif defined(__bsdos__) -# define PLATFORM_ID "BSDOS" - -#elif defined(_MPRAS) || defined(MPRAS) -# define PLATFORM_ID "MP-RAS" - -#elif defined(__osf) || defined(__osf__) -# define PLATFORM_ID "OSF1" - -#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) -# define PLATFORM_ID "SCO_SV" - -#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) -# define PLATFORM_ID "ULTRIX" - -#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) -# define PLATFORM_ID "Xenix" - -#else /* unknown platform */ -# define PLATFORM_ID "" - -#endif - -static char const info_platform[] = "INFO:platform[" PLATFORM_ID "]"; diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in new file mode 100644 index 0000000..f62eb36 --- /dev/null +++ b/Modules/CMakePlatformId.h.in @@ -0,0 +1,79 @@ +/* Identify known platforms by name. */ +#if defined(__linux) || defined(__linux__) || defined(linux) +# define PLATFORM_ID "Linux" + +#elif defined(__CYGWIN__) +# define PLATFORM_ID "Cygwin" + +#elif defined(__MINGW32__) +# define PLATFORM_ID "MinGW" + +#elif defined(__APPLE__) +# define PLATFORM_ID "Darwin" + +#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) +# define PLATFORM_ID "Windows" + +#elif defined(__FreeBSD__) || defined(__FreeBSD) +# define PLATFORM_ID "FreeBSD" + +#elif defined(__NetBSD__) || defined(__NetBSD) +# define PLATFORM_ID "NetBSD" + +#elif defined(__OpenBSD__) || defined(__OPENBSD) +# define PLATFORM_ID "OpenBSD" + +#elif defined(__sun) || defined(sun) +# define PLATFORM_ID "SunOS" + +#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) +# define PLATFORM_ID "AIX" + +#elif defined(__sgi) || defined(__sgi__) || defined(_SGI) +# define PLATFORM_ID "IRIX" + +#elif defined(__hpux) || defined(__hpux__) +# define PLATFORM_ID "HP-UX" + +#elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) +# define PLATFORM_ID "BeOS" + +#elif defined(__QNX__) || defined(__QNXNTO__) +# define PLATFORM_ID "QNX" + +#elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) +# define PLATFORM_ID "Tru64" + +#elif defined(__riscos) || defined(__riscos__) +# define PLATFORM_ID "RISCos" + +#elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) +# define PLATFORM_ID "SINIX" + +#elif defined(__UNIX_SV__) +# define PLATFORM_ID "UNIX_SV" + +#elif defined(__bsdos__) +# define PLATFORM_ID "BSDOS" + +#elif defined(_MPRAS) || defined(MPRAS) +# define PLATFORM_ID "MP-RAS" + +#elif defined(__osf) || defined(__osf__) +# define PLATFORM_ID "OSF1" + +#elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) +# define PLATFORM_ID "SCO_SV" + +#elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) +# define PLATFORM_ID "ULTRIX" + +#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) +# define PLATFORM_ID "Xenix" + +#else /* unknown platform */ +# define PLATFORM_ID "" + +#endif + +char info_platform[] = "INFO:platform[" PLATFORM_ID "]"; -- cgit v0.12