CMakeCXXCompilerId.cpp.in 5.2 KB

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