CMakeCCompilerId.c.in 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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(__PATHCC__)
  20. # define COMPILER_ID "PathScale"
  21. # define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
  22. # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
  23. # if defined(__PATHCC_PATCHLEVEL__)
  24. # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
  25. # endif
  26. #elif defined(__clang__)
  27. # define COMPILER_ID "Clang"
  28. # define COMPILER_VERSION_MAJOR DEC(__clang_major__)
  29. # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
  30. # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
  31. # if defined(_MSC_VER)
  32. # define SIMULATE_ID "MSVC"
  33. /* _MSC_VER = VVRR */
  34. # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
  35. # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
  36. # endif
  37. #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
  38. # define COMPILER_ID "Embarcadero"
  39. # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
  40. # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
  41. # define COMPILER_VERSION_PATCH HEX(__CODEGEARC_VERSION__ & 0xFFFF)
  42. #elif defined(__BORLANDC__)
  43. # define COMPILER_ID "Borland"
  44. /* __BORLANDC__ = 0xVRR */
  45. # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
  46. # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
  47. #elif defined(__WATCOMC__)
  48. # define COMPILER_ID "Watcom"
  49. /* __WATCOMC__ = VVRR */
  50. # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
  51. # define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100)
  52. #elif defined(__SUNPRO_C)
  53. # define COMPILER_ID "SunPro"
  54. # if __SUNPRO_C >= 0x5100
  55. /* __SUNPRO_C = 0xVRRP */
  56. # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>12)
  57. # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xFF)
  58. # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
  59. # else
  60. /* __SUNPRO_C = 0xVRP */
  61. # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_C>>8)
  62. # define COMPILER_VERSION_MINOR HEX(__SUNPRO_C>>4 & 0xF)
  63. # define COMPILER_VERSION_PATCH HEX(__SUNPRO_C & 0xF)
  64. # endif
  65. #elif defined(__HP_cc)
  66. # define COMPILER_ID "HP"
  67. /* __HP_cc = VVRRPP */
  68. # define COMPILER_VERSION_MAJOR DEC(__HP_cc/10000)
  69. # define COMPILER_VERSION_MINOR DEC(__HP_cc/100 % 100)
  70. # define COMPILER_VERSION_PATCH DEC(__HP_cc % 100)
  71. #elif defined(__DECC)
  72. # define COMPILER_ID "Compaq"
  73. /* __DECC_VER = VVRRTPPPP */
  74. # define COMPILER_VERSION_MAJOR DEC(__DECC_VER/10000000)
  75. # define COMPILER_VERSION_MINOR DEC(__DECC_VER/100000 % 100)
  76. # define COMPILER_VERSION_PATCH DEC(__DECC_VER % 10000)
  77. #elif defined(__IBMC__)
  78. # if defined(__COMPILER_VER__)
  79. # define COMPILER_ID "zOS"
  80. # else
  81. # if __IBMC__ >= 800
  82. # define COMPILER_ID "XL"
  83. # else
  84. # define COMPILER_ID "VisualAge"
  85. # endif
  86. /* __IBMC__ = VRP */
  87. # define COMPILER_VERSION_MAJOR DEC(__IBMC__/100)
  88. # define COMPILER_VERSION_MINOR DEC(__IBMC__/10 % 10)
  89. # define COMPILER_VERSION_PATCH DEC(__IBMC__ % 10)
  90. # endif
  91. #elif defined(__PGI)
  92. # define COMPILER_ID "PGI"
  93. # define COMPILER_VERSION_MAJOR DEC(__PGIC__)
  94. # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
  95. # if defined(__PGIC_PATCHLEVEL__)
  96. # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
  97. # endif
  98. #elif defined(_CRAYC)
  99. # define COMPILER_ID "Cray"
  100. # define COMPILER_VERSION_MAJOR DEC(_RELEASE)
  101. # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
  102. #elif defined(__TI_COMPILER_VERSION__)
  103. # define COMPILER_ID "TI"
  104. /* __TI_COMPILER_VERSION__ = VVVRRRPPP */
  105. # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
  106. # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
  107. # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
  108. #elif defined(__TINYC__)
  109. # define COMPILER_ID "TinyCC"
  110. #elif defined(__SCO_VERSION__)
  111. # define COMPILER_ID "SCO"
  112. #elif defined(__GNUC__)
  113. # define COMPILER_ID "GNU"
  114. # define COMPILER_VERSION_MAJOR DEC(__GNUC__)
  115. # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
  116. # if defined(__GNUC_PATCHLEVEL__)
  117. # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
  118. # endif
  119. #elif defined(_MSC_VER)
  120. # define COMPILER_ID "MSVC"
  121. /* _MSC_VER = VVRR */
  122. # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
  123. # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
  124. # if defined(_MSC_FULL_VER)
  125. # if _MSC_VER >= 1400
  126. /* _MSC_FULL_VER = VVRRPPPPP */
  127. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
  128. # else
  129. /* _MSC_FULL_VER = VVRRPPPP */
  130. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
  131. # endif
  132. # endif
  133. # if defined(_MSC_BUILD)
  134. # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
  135. # endif
  136. /* Analog VisualDSP++ >= 4.5.6 */
  137. #elif defined(__VISUALDSPVERSION__)
  138. # define COMPILER_ID "ADSP"
  139. /* __VISUALDSPVERSION__ = 0xVVRRPP00 */
  140. # define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
  141. # define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
  142. # define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
  143. /* Analog VisualDSP++ < 4.5.6 */
  144. #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
  145. # define COMPILER_ID "ADSP"
  146. /* IAR Systems compiler for embedded systems.
  147. http://www.iar.com */
  148. #elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC)
  149. # define COMPILER_ID "IAR"
  150. /* sdcc, the small devices C compiler for embedded systems,
  151. http://sdcc.sourceforge.net */
  152. #elif defined(SDCC)
  153. # define COMPILER_ID "SDCC"
  154. /* SDCC = VRP */
  155. # define COMPILER_VERSION_MAJOR DEC(SDCC/100)
  156. # define COMPILER_VERSION_MINOR DEC(SDCC/10 % 10)
  157. # define COMPILER_VERSION_PATCH DEC(SDCC % 10)
  158. #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
  159. # define COMPILER_ID "MIPSpro"
  160. # if defined(_SGI_COMPILER_VERSION)
  161. /* _SGI_COMPILER_VERSION = VRP */
  162. # define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100)
  163. # define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10)
  164. # define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10)
  165. # else
  166. /* _COMPILER_VERSION = VRP */
  167. # define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100)
  168. # define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10)
  169. # define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10)
  170. # endif
  171. /* This compiler is either not known or is too old to define an
  172. identification macro. Try to identify the platform and guess that
  173. it is the native compiler. */
  174. #elif defined(__sgi)
  175. # define COMPILER_ID "MIPSpro"
  176. #elif defined(__hpux) || defined(__hpua)
  177. # define COMPILER_ID "HP"
  178. #else /* unknown compiler */
  179. # define COMPILER_ID ""
  180. #endif
  181. /* Construct the string literal in pieces to prevent the source from
  182. getting matched. Store it in a pointer rather than an array
  183. because some compilers will just produce instructions to fill the
  184. array rather than assigning a pointer to a static array. */
  185. char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
  186. #ifdef SIMULATE_ID
  187. char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
  188. #endif
  189. @CMAKE_C_COMPILER_ID_PLATFORM_CONTENT@
  190. /*--------------------------------------------------------------------------*/
  191. #ifdef ID_VOID_MAIN
  192. void main() {}
  193. #else
  194. int main(int argc, char* argv[])
  195. {
  196. int require = 0;
  197. require += info_compiler[argc];
  198. require += info_platform[argc];
  199. require += info_arch[argc];
  200. #ifdef COMPILER_VERSION_MAJOR
  201. require += info_version[argc];
  202. #endif
  203. #ifdef SIMULATE_ID
  204. require += info_simulate[argc];
  205. #endif
  206. #ifdef SIMULATE_VERSION_MAJOR
  207. require += info_simulate_version[argc];
  208. #endif
  209. (void)argv;
  210. return require;
  211. }
  212. #endif