CMakeCXXCompilerId.cpp.in 4.5 KB

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