CMakeCXXCompilerId.cpp.in 3.7 KB

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