CMakeCXXCompilerId.cpp.in 8.2 KB

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