CMakeCCompilerId.c.in 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. #ifdef __cplusplus
  2. # error "A C++ compiler has been selected for C."
  3. #endif
  4. /* Version number components: V=Version, R=Revision, P=Patch
  5. Version date components: YYYY=Year, MM=Month, DD=Day */
  6. #if defined(__18CXX)
  7. # define ID_VOID_MAIN
  8. #endif
  9. #if defined(__INTEL_COMPILER) || defined(__ICC)
  10. # define COMPILER_ID "Intel"
  11. /* __INTEL_COMPILER = VRP */
  12. # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
  13. # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
  14. # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
  15. # if defined(__INTEL_COMPILER_BUILD_DATE)
  16. /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
  17. # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
  18. # endif
  19. #elif defined(__clang__)
  20. # define COMPILER_ID "Clang"
  21. # define COMPILER_VERSION_MAJOR DEC(__clang_major__)
  22. # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
  23. # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
  24. #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
  25. # define COMPILER_ID "Embarcadero"
  26. # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
  27. # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
  28. # define COMPILER_VERSION_PATCH HEX(__CODEGEARC_VERSION__ & 0xFFFF)
  29. #elif defined(__BORLANDC__)
  30. # define COMPILER_ID "Borland"
  31. /* __BORLANDC__ = 0xVRR */
  32. # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
  33. # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
  34. #elif defined(__WATCOMC__)
  35. # define COMPILER_ID "Watcom"
  36. /* __WATCOMC__ = VVRR */
  37. # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
  38. # define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100)
  39. #elif defined(__SUNPRO_C)
  40. # define COMPILER_ID "SunPro"
  41. # if __SUNPRO_C >= 0x5100
  42. /* __SUNPRO_C = 0xVRRP */
  43. # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12)
  44. # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF)
  45. # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
  46. # else
  47. /* __SUNPRO_C = 0xVRP */
  48. # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8)
  49. # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF)
  50. # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
  51. # endif
  52. #elif defined(__HP_cc)
  53. # define COMPILER_ID "HP"
  54. /* __HP_cc = VVRRPP */
  55. # define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000)
  56. # define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100)
  57. # define COMPILER_VERSION_PATCH DEC(__HP_cc % 100)
  58. #elif defined(__DECC)
  59. # define COMPILER_ID "Compaq"
  60. #elif defined(__IBMC__)
  61. # if defined(__COMPILER_VER__)
  62. # define COMPILER_ID "zOS"
  63. # else
  64. # if __IBMC__ >= 800
  65. # define COMPILER_ID "XL"
  66. # else
  67. # define COMPILER_ID "VisualAge"
  68. # endif
  69. /* __IBMC__ = VRP */
  70. # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
  71. # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
  72. # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
  73. # endif
  74. #elif defined(__PGI)
  75. # define COMPILER_ID "PGI"
  76. # define COMPILER_VERSION_MAJOR DEC(__PGIC__)
  77. # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
  78. # if defined(__PGIC_PATCHLEVEL__)
  79. # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
  80. # endif
  81. #elif defined(__PATHSCALE__)
  82. # define COMPILER_ID "PathScale"
  83. #elif defined(_CRAYC)
  84. # define COMPILER_ID "Cray"
  85. #elif defined(__TI_COMPILER_VERSION__)
  86. # define COMPILER_ID "TI_DSP"
  87. #elif defined(__TINYC__)
  88. # define COMPILER_ID "TinyCC"
  89. #elif defined(__SCO_VERSION__)
  90. # define COMPILER_ID "SCO"
  91. #elif defined(__GNUC__)
  92. # define COMPILER_ID "GNU"
  93. # define COMPILER_VERSION_MAJOR DEC(__GNUC__)
  94. # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
  95. # if defined(__GNUC_PATCHLEVEL__)
  96. # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
  97. # endif
  98. #elif defined(_MSC_VER)
  99. # define COMPILER_ID "MSVC"
  100. /* _MSC_VER = VVRR */
  101. # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
  102. # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
  103. # if defined(_MSC_FULL_VER)
  104. # if _MSC_VER >= 1400
  105. /* _MSC_FULL_VER = VVRRPPPPP */
  106. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
  107. # else
  108. /* _MSC_FULL_VER = VVRRPPPP */
  109. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
  110. # endif
  111. # endif
  112. # if defined(_MSC_BUILD)
  113. # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
  114. # endif
  115. #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
  116. /* Analog Devices C++ compiler for Blackfin, TigerSHARC and
  117. SHARC (21000) DSPs */
  118. # define COMPILER_ID "ADSP"
  119. /* IAR Systems compiler for embedded systems.
  120. http://www.iar.com
  121. Not supported yet by CMake
  122. #elif defined(__IAR_SYSTEMS_ICC__)
  123. # define COMPILER_ID "IAR" */
  124. /* sdcc, the small devices C compiler for embedded systems,
  125. http://sdcc.sourceforge.net */
  126. #elif defined(SDCC)
  127. # define COMPILER_ID "SDCC"
  128. #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
  129. # define COMPILER_ID "MIPSpro"
  130. # if defined(_SGI_COMPILER_VERSION)
  131. /* _SGI_COMPILER_VERSION = VRP */
  132. # define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100)
  133. # define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10)
  134. # define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10)
  135. # else
  136. /* _COMPILER_VERSION = VRP */
  137. # define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100)
  138. # define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10)
  139. # define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10)
  140. # endif
  141. /* This compiler is either not known or is too old to define an
  142. identification macro. Try to identify the platform and guess that
  143. it is the native compiler. */
  144. #elif defined(__sgi)
  145. # define COMPILER_ID "MIPSpro"
  146. #elif defined(__hpux) || defined(__hpua)
  147. # define COMPILER_ID "HP"
  148. #else /* unknown compiler */
  149. # define COMPILER_ID ""
  150. #endif
  151. /* Construct the string literal in pieces to prevent the source from
  152. getting matched. Store it in a pointer rather than an array
  153. because some compilers will just produce instructions to fill the
  154. array rather than assigning a pointer to a static array. */
  155. char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
  156. @CMAKE_C_COMPILER_ID_PLATFORM_CONTENT@
  157. /*--------------------------------------------------------------------------*/
  158. #ifdef ID_VOID_MAIN
  159. void main() {}
  160. #else
  161. int main(int argc, char* argv[])
  162. {
  163. int require = 0;
  164. require += info_compiler[argc];
  165. require += info_platform[argc];
  166. require += info_arch[argc];
  167. #ifdef COMPILER_VERSION_MAJOR
  168. require += info_version[argc];
  169. #endif
  170. (void)argv;
  171. return require;
  172. }
  173. #endif