CMakeCXXCompilerId.cpp.in 3.1 KB

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