CMakeCCompilerId.c.in 7.5 KB

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