CMakeCCompilerId.c.in 4.4 KB

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