CMakeCXXCompilerId.cpp.in 7.3 KB

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