CMakeCCompilerId.c.in 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #ifdef __cplusplus
  2. # error "A C++ compiler has been selected for C."
  3. #endif
  4. #if defined(__18CXX)
  5. # define ID_VOID_MAIN
  6. #endif
  7. #if defined(__INTEL_COMPILER) || defined(__ICC)
  8. # define COMPILER_ID "Intel"
  9. # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
  10. # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
  11. # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
  12. # if defined(__INTEL_COMPILER_BUILD_DATE)
  13. # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
  14. # endif
  15. #elif defined(__clang__)
  16. # define COMPILER_ID "Clang"
  17. #elif defined(__BORLANDC__)
  18. # define COMPILER_ID "Borland"
  19. #elif defined(__WATCOMC__)
  20. # define COMPILER_ID "Watcom"
  21. #elif defined(__SUNPRO_C)
  22. # define COMPILER_ID "SunPro"
  23. #elif defined(__HP_cc)
  24. # define COMPILER_ID "HP"
  25. #elif defined(__DECC)
  26. # define COMPILER_ID "Compaq"
  27. #elif defined(__IBMC__)
  28. # if defined(__COMPILER_VER__)
  29. # define COMPILER_ID "zOS"
  30. # elif __IBMC__ >= 800
  31. # define COMPILER_ID "XL"
  32. # else
  33. # define COMPILER_ID "VisualAge"
  34. # endif
  35. #elif defined(__PGI)
  36. # define COMPILER_ID "PGI"
  37. #elif defined(__PATHSCALE__)
  38. # define COMPILER_ID "PathScale"
  39. #elif defined(_CRAYC)
  40. # define COMPILER_ID "Cray"
  41. #elif defined(__TI_COMPILER_VERSION__)
  42. # define COMPILER_ID "TI_DSP"
  43. #elif defined(__SCO_VERSION__)
  44. # define COMPILER_ID "SCO"
  45. #elif defined(__GNUC__)
  46. # define COMPILER_ID "GNU"
  47. # define COMPILER_VERSION_MAJOR DEC(__GNUC__)
  48. # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
  49. # if defined(__GNUC_PATCHLEVEL__)
  50. # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
  51. # endif
  52. #elif defined(_MSC_VER)
  53. # define COMPILER_ID "MSVC"
  54. # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
  55. # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
  56. # if defined(_MSC_FULL_VER)
  57. # if _MSC_VER >= 1400
  58. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
  59. # else
  60. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
  61. # endif
  62. # endif
  63. # if defined(_MSC_BUILD)
  64. # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
  65. # endif
  66. #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
  67. /* Analog Devices C++ compiler for Blackfin, TigerSHARC and
  68. SHARC (21000) DSPs */
  69. # define COMPILER_ID "ADSP"
  70. /* IAR Systems compiler for embedded systems.
  71. http://www.iar.com
  72. Not supported yet by CMake
  73. #elif defined(__IAR_SYSTEMS_ICC__)
  74. # define COMPILER_ID "IAR" */
  75. /* sdcc, the small devices C compiler for embedded systems,
  76. http://sdcc.sourceforge.net */
  77. #elif defined(SDCC)
  78. # define COMPILER_ID "SDCC"
  79. #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
  80. # define COMPILER_ID "MIPSpro"
  81. /* This compiler is either not known or is too old to define an
  82. identification macro. Try to identify the platform and guess that
  83. it is the native compiler. */
  84. #elif defined(__sgi)
  85. # define COMPILER_ID "MIPSpro"
  86. #elif defined(__hpux) || defined(__hpua)
  87. # define COMPILER_ID "HP"
  88. #else /* unknown compiler */
  89. # define COMPILER_ID ""
  90. #endif
  91. /* Construct the string literal in pieces to prevent the source from
  92. getting matched. Store it in a pointer rather than an array
  93. because some compilers will just produce instructions to fill the
  94. array rather than assigning a pointer to a static array. */
  95. char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
  96. @CMAKE_C_COMPILER_ID_PLATFORM_CONTENT@
  97. /*--------------------------------------------------------------------------*/
  98. #ifdef ID_VOID_MAIN
  99. void main() {}
  100. #else
  101. int main(int argc, char* argv[])
  102. {
  103. int require = 0;
  104. require += info_compiler[argc];
  105. require += info_platform[argc];
  106. require += info_arch[argc];
  107. #ifdef COMPILER_VERSION_MAJOR
  108. require += info_version[argc];
  109. #endif
  110. (void)argv;
  111. return require;
  112. }
  113. #endif