CMakeCXXCompilerId.cpp.in 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. #elif defined(__INTEL_COMPILER) || defined(__ICC)
  12. # define COMPILER_ID "Intel"
  13. /* __INTEL_COMPILER = VRP */
  14. # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100)
  15. # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10)
  16. # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10)
  17. # if defined(__INTEL_COMPILER_BUILD_DATE)
  18. /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */
  19. # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE)
  20. # endif
  21. #elif defined(__clang__)
  22. # define COMPILER_ID "Clang"
  23. # define COMPILER_VERSION_MAJOR DEC(__clang_major__)
  24. # define COMPILER_VERSION_MINOR DEC(__clang_minor__)
  25. # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__)
  26. #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__)
  27. # define COMPILER_ID "Embarcadero"
  28. # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF)
  29. # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF)
  30. # define COMPILER_VERSION_PATCH HEX(__CODEGEARC_VERSION__ & 0xFFFF)
  31. #elif defined(__BORLANDC__)
  32. # define COMPILER_ID "Borland"
  33. /* __BORLANDC__ = 0xVRR */
  34. # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8)
  35. # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
  36. #elif defined(__WATCOMC__)
  37. # define COMPILER_ID "Watcom"
  38. /* __WATCOMC__ = VVRR */
  39. # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
  40. # define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100)
  41. #elif defined(__SUNPRO_CC)
  42. # define COMPILER_ID "SunPro"
  43. # if __SUNPRO_CC >= 0x5100
  44. /* __SUNPRO_CC = 0xVRRP */
  45. # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12)
  46. # define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF)
  47. # define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
  48. # else
  49. /* __SUNPRO_CC = 0xVRP */
  50. # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8)
  51. # define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF)
  52. # define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF)
  53. # endif
  54. #elif defined(__HP_aCC)
  55. # define COMPILER_ID "HP"
  56. /* __HP_aCC = VVRRPP */
  57. # define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000)
  58. # define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100)
  59. # define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100)
  60. #elif defined(__DECCXX)
  61. # define COMPILER_ID "Compaq"
  62. #elif defined(__IBMCPP__)
  63. # if defined(__COMPILER_VER__)
  64. # define COMPILER_ID "zOS"
  65. # else
  66. # if __IBMCPP__ >= 800
  67. # define COMPILER_ID "XL"
  68. # else
  69. # define COMPILER_ID "VisualAge"
  70. # endif
  71. /* __IBMCPP__ = VRP */
  72. # define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100)
  73. # define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10)
  74. # define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10)
  75. # endif
  76. #elif defined(__PGI)
  77. # define COMPILER_ID "PGI"
  78. # define COMPILER_VERSION_MAJOR DEC(__PGIC__)
  79. # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__)
  80. # if defined(__PGIC_PATCHLEVEL__)
  81. # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__)
  82. # endif
  83. #elif defined(__PATHSCALE__)
  84. # define COMPILER_ID "PathScale"
  85. #elif defined(_CRAYC)
  86. # define COMPILER_ID "Cray"
  87. #elif defined(__TI_COMPILER_VERSION__)
  88. # define COMPILER_ID "TI_DSP"
  89. #elif defined(__SCO_VERSION__)
  90. # define COMPILER_ID "SCO"
  91. #elif defined(__GNUC__)
  92. # define COMPILER_ID "GNU"
  93. # define COMPILER_VERSION_MAJOR DEC(__GNUC__)
  94. # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
  95. # if defined(__GNUC_PATCHLEVEL__)
  96. # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
  97. # endif
  98. #elif defined(_MSC_VER)
  99. # define COMPILER_ID "MSVC"
  100. /* _MSC_VER = VVRR */
  101. # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
  102. # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
  103. # if defined(_MSC_FULL_VER)
  104. # if _MSC_VER >= 1400
  105. /* _MSC_FULL_VER = VVRRPPPPP */
  106. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
  107. # else
  108. /* _MSC_FULL_VER = VVRRPPPP */
  109. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
  110. # endif
  111. # endif
  112. # if defined(_MSC_BUILD)
  113. # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
  114. # endif
  115. #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
  116. /* Analog Devices C++ compiler for Blackfin, TigerSHARC and
  117. SHARC (21000) DSPs */
  118. # define COMPILER_ID "ADSP"
  119. #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
  120. # define COMPILER_ID "MIPSpro"
  121. # if defined(_SGI_COMPILER_VERSION)
  122. /* _SGI_COMPILER_VERSION = VRP */
  123. # define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100)
  124. # define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10)
  125. # define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10)
  126. # else
  127. /* _COMPILER_VERSION = VRP */
  128. # define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100)
  129. # define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10)
  130. # define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10)
  131. # endif
  132. /* This compiler is either not known or is too old to define an
  133. identification macro. Try to identify the platform and guess that
  134. it is the native compiler. */
  135. #elif defined(__sgi)
  136. # define COMPILER_ID "MIPSpro"
  137. #elif defined(__hpux) || defined(__hpua)
  138. # define COMPILER_ID "HP"
  139. #else /* unknown compiler */
  140. # define COMPILER_ID ""
  141. #endif
  142. /* Construct the string literal in pieces to prevent the source from
  143. getting matched. Store it in a pointer rather than an array
  144. because some compilers will just produce instructions to fill the
  145. array rather than assigning a pointer to a static array. */
  146. char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
  147. @CMAKE_CXX_COMPILER_ID_PLATFORM_CONTENT@
  148. /*--------------------------------------------------------------------------*/
  149. int main(int argc, char* argv[])
  150. {
  151. int require = 0;
  152. require += info_compiler[argc];
  153. require += info_platform[argc];
  154. #ifdef COMPILER_VERSION_MAJOR
  155. require += info_version[argc];
  156. #endif
  157. (void)argv;
  158. return require;
  159. }