CMakeCCompilerId.c.in 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. /* __DECC_VER = VVRRTPPPP */
  61. # define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000)
  62. # define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100)
  63. # define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000)
  64. #elif defined(__IBMC__)
  65. # if defined(__COMPILER_VER__)
  66. # define COMPILER_ID "zOS"
  67. # else
  68. # if __IBMC__ >= 800
  69. # define COMPILER_ID "XL"
  70. # else
  71. # define COMPILER_ID "VisualAge"
  72. # endif
  73. /* __IBMC__ = VRP */
  74. # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
  75. # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
  76. # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
  77. # endif
  78. #elif defined(__PGI)
  79. # define COMPILER_ID "PGI"
  80. # define COMPILER_VERSION_MAJOR DEC(__PGIC__)
  81. # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
  82. # if defined(__PGIC_PATCHLEVEL__)
  83. # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
  84. # endif
  85. #elif defined(__PATHCC__)
  86. # define COMPILER_ID "PathScale"
  87. # define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
  88. # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
  89. # if defined(__PATHCC_PATCHLEVEL__)
  90. # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
  91. # endif
  92. #elif defined(_CRAYC)
  93. # define COMPILER_ID "Cray"
  94. #elif defined(__TI_COMPILER_VERSION__)
  95. # define COMPILER_ID "TI_DSP"
  96. /* __TI_COMPILER_VERSION__ = VVVRRRPPP */
  97. # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
  98. # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
  99. # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
  100. #elif defined(__TINYC__)
  101. # define COMPILER_ID "TinyCC"
  102. #elif defined(__SCO_VERSION__)
  103. # define COMPILER_ID "SCO"
  104. #elif defined(__GNUC__)
  105. # define COMPILER_ID "GNU"
  106. # define COMPILER_VERSION_MAJOR DEC(__GNUC__)
  107. # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
  108. # if defined(__GNUC_PATCHLEVEL__)
  109. # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
  110. # endif
  111. #elif defined(_MSC_VER)
  112. # define COMPILER_ID "MSVC"
  113. /* _MSC_VER = VVRR */
  114. # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
  115. # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
  116. # if defined(_MSC_FULL_VER)
  117. # if _MSC_VER >= 1400
  118. /* _MSC_FULL_VER = VVRRPPPPP */
  119. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
  120. # else
  121. /* _MSC_FULL_VER = VVRRPPPP */
  122. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
  123. # endif
  124. # endif
  125. # if defined(_MSC_BUILD)
  126. # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
  127. # endif
  128. #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
  129. /* Analog Devices C++ compiler for Blackfin, TigerSHARC and
  130. SHARC (21000) DSPs */
  131. # define COMPILER_ID "ADSP"
  132. /* IAR Systems compiler for embedded systems.
  133. http://www.iar.com
  134. Not supported yet by CMake
  135. #elif defined(__IAR_SYSTEMS_ICC__)
  136. # define COMPILER_ID "IAR" */
  137. /* sdcc, the small devices C compiler for embedded systems,
  138. http://sdcc.sourceforge.net */
  139. #elif defined(SDCC)
  140. # define COMPILER_ID "SDCC"
  141. #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
  142. # define COMPILER_ID "MIPSpro"
  143. # if defined(_SGI_COMPILER_VERSION)
  144. /* _SGI_COMPILER_VERSION = VRP */
  145. # define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100)
  146. # define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10)
  147. # define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10)
  148. # else
  149. /* _COMPILER_VERSION = VRP */
  150. # define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100)
  151. # define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10)
  152. # define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10)
  153. # endif
  154. /* This compiler is either not known or is too old to define an
  155. identification macro. Try to identify the platform and guess that
  156. it is the native compiler. */
  157. #elif defined(__sgi)
  158. # define COMPILER_ID "MIPSpro"
  159. #elif defined(__hpux) || defined(__hpua)
  160. # define COMPILER_ID "HP"
  161. #else /* unknown compiler */
  162. # define COMPILER_ID ""
  163. #endif
  164. /* Construct the string literal in pieces to prevent the source from
  165. getting matched. Store it in a pointer rather than an array
  166. because some compilers will just produce instructions to fill the
  167. array rather than assigning a pointer to a static array. */
  168. char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
  169. @CMAKE_C_COMPILER_ID_PLATFORM_CONTENT@
  170. /*--------------------------------------------------------------------------*/
  171. #ifdef ID_VOID_MAIN
  172. void main() {}
  173. #else
  174. int main(int argc, char* argv[])
  175. {
  176. int require = 0;
  177. require += info_compiler[argc];
  178. require += info_platform[argc];
  179. require += info_arch[argc];
  180. #ifdef COMPILER_VERSION_MAJOR
  181. require += info_version[argc];
  182. #endif
  183. (void)argv;
  184. return require;
  185. }
  186. #endif