CMakeCXXCompilerId.cpp.in 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /* This source file must have a .cpp extension so that all C++ compilers
  2. recognize the extension without flags. Borland does not know .cxx for
  3. example. */
  4. #ifndef __cplusplus
  5. # error "A C compiler has been selected for C++."
  6. #endif
  7. /* Version number components: V=Version, R=Revision, P=Patch
  8. Version date components: YYYY=Year, MM=Month, DD=Day */
  9. #if defined(__COMO__)
  10. # define COMPILER_ID "Comeau"
  11. /* __COMO_VERSION__ = VRR */
  12. # define COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100)
  13. # define COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100)
  14. #elif defined(__INTEL_COMPILER) || defined(__ICC)
  15. # define COMPILER_ID "Intel"
  16. /* __INTEL_COMPILER = VRP */
  17. # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
  18. # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
  19. # if defined(__INTEL_COMPILER_UPDATE)
  20. # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE)
  21. # else
  22. # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
  23. # endif
  24. # if defined(__INTEL_COMPILER_BUILD_DATE)
  25. /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
  26. # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
  27. # endif
  28. # if defined(_MSC_VER)
  29. # define SIMULATE_ID "MSVC"
  30. /* _MSC_VER = VVRR */
  31. # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
  32. # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
  33. # endif
  34. #elif defined(__PATHCC__)
  35. # define COMPILER_ID "PathScale"
  36. # define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
  37. # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
  38. # if defined(__PATHCC_PATCHLEVEL__)
  39. # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
  40. # endif
  41. #elif defined(__clang__)
  42. # if defined(__apple_build_version__)
  43. # define COMPILER_ID "AppleClang"
  44. # define COMPILER_VERSION_TWEAK DEC(__apple_build_version__)
  45. # else
  46. # define COMPILER_ID "Clang"
  47. # endif
  48. # define COMPILER_VERSION_MAJOR DEC(__clang_major__)
  49. # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
  50. # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
  51. # if defined(_MSC_VER)
  52. # define SIMULATE_ID "MSVC"
  53. /* _MSC_VER = VVRR */
  54. # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
  55. # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
  56. # endif
  57. #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
  58. # define COMPILER_ID "Embarcadero"
  59. # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
  60. # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
  61. # define COMPILER_VERSION_PATCH HEX(__CODEGEARC_VERSION__ & 0xFFFF)
  62. #elif defined(__BORLANDC__)
  63. # define COMPILER_ID "Borland"
  64. /* __BORLANDC__ = 0xVRR */
  65. # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
  66. # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
  67. #elif defined(__WATCOMC__)
  68. # if __WATCOMC__ < 1200
  69. # define COMPILER_ID "Watcom"
  70. /* __WATCOMC__ = VVRP */
  71. # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
  72. # else
  73. # define COMPILER_ID "OpenWatcom"
  74. /* __WATCOMC__ = VVRP + 1100 */
  75. # define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
  76. # endif
  77. # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
  78. # if (__WATCOMC__ % 10) > 0
  79. # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
  80. # endif
  81. #elif defined(__SUNPRO_CC)
  82. # define COMPILER_ID "SunPro"
  83. # if __SUNPRO_CC >= 0x5100
  84. /* __SUNPRO_CC = 0xVRRP */
  85. # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12)
  86. # define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF)
  87. # define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
  88. # else
  89. /* __SUNPRO_CC = 0xVRP */
  90. # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8)
  91. # define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF)
  92. # define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
  93. # endif
  94. #elif defined(__HP_aCC)
  95. # define COMPILER_ID "HP"
  96. /* __HP_aCC = VVRRPP */
  97. # define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000)
  98. # define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100)
  99. # define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100)
  100. #elif defined(__DECCXX)
  101. # define COMPILER_ID "Compaq"
  102. /* __DECCXX_VER = VVRRTPPPP */
  103. # define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000)
  104. # define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100)
  105. # define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000)
  106. #elif defined(__IBMCPP__)
  107. # if defined(__COMPILER_VER__)
  108. # define COMPILER_ID "zOS"
  109. # else
  110. # if __IBMCPP__ >= 800
  111. # define COMPILER_ID "XL"
  112. # else
  113. # define COMPILER_ID "VisualAge"
  114. # endif
  115. /* __IBMCPP__ = VRP */
  116. # define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
  117. # define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
  118. # define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
  119. # endif
  120. #elif defined(__PGI)
  121. # define COMPILER_ID "PGI"
  122. # define COMPILER_VERSION_MAJOR DEC(__PGIC__)
  123. # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
  124. # if defined(__PGIC_PATCHLEVEL__)
  125. # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
  126. # endif
  127. #elif defined(_CRAYC)
  128. # define COMPILER_ID "Cray"
  129. # define COMPILER_VERSION_MAJOR DEC(_RELEASE)
  130. # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
  131. #elif defined(__TI_COMPILER_VERSION__)
  132. # define COMPILER_ID "TI"
  133. /* __TI_COMPILER_VERSION__ = VVVRRRPPP */
  134. # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
  135. # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
  136. # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
  137. #elif defined(__SCO_VERSION__)
  138. # define COMPILER_ID "SCO"
  139. #elif defined(__GNUC__)
  140. # define COMPILER_ID "GNU"
  141. # define COMPILER_VERSION_MAJOR DEC(__GNUC__)
  142. # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
  143. # if defined(__GNUC_PATCHLEVEL__)
  144. # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
  145. # endif
  146. #elif defined(_MSC_VER)
  147. # define COMPILER_ID "MSVC"
  148. /* _MSC_VER = VVRR */
  149. # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
  150. # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
  151. # if defined(_MSC_FULL_VER)
  152. # if _MSC_VER >= 1400
  153. /* _MSC_FULL_VER = VVRRPPPPP */
  154. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
  155. # else
  156. /* _MSC_FULL_VER = VVRRPPPP */
  157. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
  158. # endif
  159. # endif
  160. # if defined(_MSC_BUILD)
  161. # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
  162. # endif
  163. /* Analog VisualDSP++ >= 4.5.6 */
  164. #elif defined(__VISUALDSPVERSION__)
  165. # define COMPILER_ID "ADSP"
  166. /* __VISUALDSPVERSION__ = 0xVVRRPP00 */
  167. # define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
  168. # define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
  169. # define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
  170. /* Analog VisualDSP++ < 4.5.6 */
  171. #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
  172. # define COMPILER_ID "ADSP"
  173. /* IAR Systems compiler for embedded systems.
  174. http://www.iar.com */
  175. #elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC)
  176. # define COMPILER_ID "IAR"
  177. #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
  178. # define COMPILER_ID "MIPSpro"
  179. # if defined(_SGI_COMPILER_VERSION)
  180. /* _SGI_COMPILER_VERSION = VRP */
  181. # define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100)
  182. # define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10)
  183. # define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10)
  184. # else
  185. /* _COMPILER_VERSION = VRP */
  186. # define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100)
  187. # define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10)
  188. # define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10)
  189. # endif
  190. /* This compiler is either not known or is too old to define an
  191. identification macro. Try to identify the platform and guess that
  192. it is the native compiler. */
  193. #elif defined(__sgi)
  194. # define COMPILER_ID "MIPSpro"
  195. #elif defined(__hpux) || defined(__hpua)
  196. # define COMPILER_ID "HP"
  197. #else /* unknown compiler */
  198. # define COMPILER_ID ""
  199. #endif
  200. /* Construct the string literal in pieces to prevent the source from
  201. getting matched. Store it in a pointer rather than an array
  202. because some compilers will just produce instructions to fill the
  203. array rather than assigning a pointer to a static array. */
  204. char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
  205. #ifdef SIMULATE_ID
  206. char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
  207. #endif
  208. #ifdef __QNXNTO__
  209. char const* qnxnto = "INFO" ":" "qnxnto";
  210. #endif
  211. @CMAKE_CXX_COMPILER_ID_PLATFORM_CONTENT@
  212. @CMAKE_CXX_COMPILER_ID_ERROR_FOR_TEST@
  213. /*--------------------------------------------------------------------------*/
  214. int main(int argc, char* argv[])
  215. {
  216. int require = 0;
  217. require += info_compiler[argc];
  218. require += info_platform[argc];
  219. #ifdef COMPILER_VERSION_MAJOR
  220. require += info_version[argc];
  221. #endif
  222. #ifdef SIMULATE_ID
  223. require += info_simulate[argc];
  224. #endif
  225. #ifdef SIMULATE_VERSION_MAJOR
  226. require += info_simulate_version[argc];
  227. #endif
  228. (void)argv;
  229. return require;
  230. }