CMakeCXXCompilerId.cpp.in 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  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. #elif defined(__PATHCC__)
  25. # define COMPILER_ID "PathScale"
  26. # define COMPILER_VERSION_MAJOR DEC(__PATHCC__)
  27. # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__)
  28. # if defined(__PATHCC_PATCHLEVEL__)
  29. # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__)
  30. # endif
  31. #elif defined(__clang__)
  32. # define COMPILER_ID "Clang"
  33. # define COMPILER_VERSION_MAJOR DEC(__clang_major__)
  34. # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
  35. # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
  36. # if defined(_MSC_VER)
  37. # define SIMULATE_ID "MSVC"
  38. /* _MSC_VER = VVRR */
  39. # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100)
  40. # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100)
  41. # endif
  42. #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
  43. # define COMPILER_ID "Embarcadero"
  44. # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
  45. # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
  46. # define COMPILER_VERSION_PATCH HEX(__CODEGEARC_VERSION__ & 0xFFFF)
  47. #elif defined(__BORLANDC__)
  48. # define COMPILER_ID "Borland"
  49. /* __BORLANDC__ = 0xVRR */
  50. # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
  51. # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
  52. #elif defined(__WATCOMC__)
  53. # define COMPILER_ID "Watcom"
  54. /* __WATCOMC__ = VVRR */
  55. # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
  56. # define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100)
  57. #elif defined(__SUNPRO_CC)
  58. # define COMPILER_ID "SunPro"
  59. # if __SUNPRO_CC >= 0x5100
  60. /* __SUNPRO_CC = 0xVRRP */
  61. # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12)
  62. # define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF)
  63. # define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
  64. # else
  65. /* __SUNPRO_CC = 0xVRP */
  66. # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8)
  67. # define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF)
  68. # define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
  69. # endif
  70. #elif defined(__HP_aCC)
  71. # define COMPILER_ID "HP"
  72. /* __HP_aCC = VVRRPP */
  73. # define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000)
  74. # define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100)
  75. # define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100)
  76. #elif defined(__DECCXX)
  77. # define COMPILER_ID "Compaq"
  78. /* __DECCXX_VER = VVRRTPPPP */
  79. # define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000)
  80. # define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100)
  81. # define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000)
  82. #elif defined(__IBMCPP__)
  83. # if defined(__COMPILER_VER__)
  84. # define COMPILER_ID "zOS"
  85. # else
  86. # if __IBMCPP__ >= 800
  87. # define COMPILER_ID "XL"
  88. # else
  89. # define COMPILER_ID "VisualAge"
  90. # endif
  91. /* __IBMCPP__ = VRP */
  92. # define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
  93. # define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
  94. # define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
  95. # endif
  96. #elif defined(__PGI)
  97. # define COMPILER_ID "PGI"
  98. # define COMPILER_VERSION_MAJOR DEC(__PGIC__)
  99. # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
  100. # if defined(__PGIC_PATCHLEVEL__)
  101. # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
  102. # endif
  103. #elif defined(_CRAYC)
  104. # define COMPILER_ID "Cray"
  105. # define COMPILER_VERSION_MAJOR DEC(_RELEASE)
  106. # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR)
  107. #elif defined(__TI_COMPILER_VERSION__)
  108. # define COMPILER_ID "TI"
  109. /* __TI_COMPILER_VERSION__ = VVVRRRPPP */
  110. # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000)
  111. # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000)
  112. # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000)
  113. #elif defined(__SCO_VERSION__)
  114. # define COMPILER_ID "SCO"
  115. #elif defined(__GNUC__)
  116. # define COMPILER_ID "GNU"
  117. # define COMPILER_VERSION_MAJOR DEC(__GNUC__)
  118. # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
  119. # if defined(__GNUC_PATCHLEVEL__)
  120. # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
  121. # endif
  122. #elif defined(_MSC_VER)
  123. # define COMPILER_ID "MSVC"
  124. /* _MSC_VER = VVRR */
  125. # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
  126. # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
  127. # if defined(_MSC_FULL_VER)
  128. # if _MSC_VER >= 1400
  129. /* _MSC_FULL_VER = VVRRPPPPP */
  130. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
  131. # else
  132. /* _MSC_FULL_VER = VVRRPPPP */
  133. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
  134. # endif
  135. # endif
  136. # if defined(_MSC_BUILD)
  137. # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
  138. # endif
  139. /* Analog VisualDSP++ >= 4.5.6 */
  140. #elif defined(__VISUALDSPVERSION__)
  141. # define COMPILER_ID "ADSP"
  142. /* __VISUALDSPVERSION__ = 0xVVRRPP00 */
  143. # define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24)
  144. # define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF)
  145. # define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF)
  146. /* Analog VisualDSP++ < 4.5.6 */
  147. #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
  148. # define COMPILER_ID "ADSP"
  149. /* IAR Systems compiler for embedded systems.
  150. http://www.iar.com */
  151. #elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC)
  152. # define COMPILER_ID "IAR"
  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. #ifdef SIMULATE_ID
  182. char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]";
  183. #endif
  184. @CMAKE_CXX_COMPILER_ID_PLATFORM_CONTENT@
  185. /*--------------------------------------------------------------------------*/
  186. int main(int argc, char* argv[])
  187. {
  188. int require = 0;
  189. require += info_compiler[argc];
  190. require += info_platform[argc];
  191. #ifdef COMPILER_VERSION_MAJOR
  192. require += info_version[argc];
  193. #endif
  194. #ifdef SIMULATE_ID
  195. require += info_simulate[argc];
  196. #endif
  197. #ifdef SIMULATE_VERSION_MAJOR
  198. require += info_simulate_version[argc];
  199. #endif
  200. (void)argv;
  201. return require;
  202. }