CMakeCCompilerId.c.in 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #ifdef __cplusplus
  2. # error "A C++ compiler has been selected for C."
  3. #endif
  4. #if defined(__18CXX)
  5. # define ID_VOID_MAIN
  6. #endif
  7. #if defined(__INTEL_COMPILER) || defined(__ICC)
  8. # define COMPILER_ID "Intel"
  9. #elif defined(__clang__)
  10. # define COMPILER_ID "Clang"
  11. #elif defined(__BORLANDC__)
  12. # define COMPILER_ID "Borland"
  13. #elif defined(__WATCOMC__)
  14. # define COMPILER_ID "Watcom"
  15. #elif defined(__SUNPRO_C)
  16. # define COMPILER_ID "SunPro"
  17. #elif defined(__HP_cc)
  18. # define COMPILER_ID "HP"
  19. #elif defined(__DECC)
  20. # define COMPILER_ID "Compaq"
  21. #elif defined(__IBMC__)
  22. # if defined(__COMPILER_VER__)
  23. # define COMPILER_ID "zOS"
  24. # elif __IBMC__ >= 800
  25. # define COMPILER_ID "XL"
  26. # else
  27. # define COMPILER_ID "VisualAge"
  28. # endif
  29. #elif defined(__PGI)
  30. # define COMPILER_ID "PGI"
  31. #elif defined(__PATHSCALE__)
  32. # define COMPILER_ID "PathScale"
  33. #elif defined(_CRAYC)
  34. # define COMPILER_ID "Cray"
  35. #elif defined(__TI_COMPILER_VERSION__)
  36. # define COMPILER_ID "TI_DSP"
  37. #elif defined(__SCO_VERSION__)
  38. # define COMPILER_ID "SCO"
  39. #elif defined(__GNUC__)
  40. # define COMPILER_ID "GNU"
  41. # define COMPILER_VERSION_MAJOR DEC(__GNUC__)
  42. # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__)
  43. # if defined(__GNUC_PATCHLEVEL__)
  44. # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__)
  45. # endif
  46. #elif defined(_MSC_VER)
  47. # define COMPILER_ID "MSVC"
  48. # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100)
  49. # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100)
  50. # if defined(_MSC_FULL_VER)
  51. # if _MSC_VER >= 1400
  52. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000)
  53. # else
  54. # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000)
  55. # endif
  56. # endif
  57. # if defined(_MSC_BUILD)
  58. # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD)
  59. # endif
  60. #elif defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__)
  61. /* Analog Devices C++ compiler for Blackfin, TigerSHARC and
  62. SHARC (21000) DSPs */
  63. # define COMPILER_ID "ADSP"
  64. /* IAR Systems compiler for embedded systems.
  65. http://www.iar.com
  66. Not supported yet by CMake
  67. #elif defined(__IAR_SYSTEMS_ICC__)
  68. # define COMPILER_ID "IAR" */
  69. /* sdcc, the small devices C compiler for embedded systems,
  70. http://sdcc.sourceforge.net */
  71. #elif defined(SDCC)
  72. # define COMPILER_ID "SDCC"
  73. #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION)
  74. # define COMPILER_ID "MIPSpro"
  75. /* This compiler is either not known or is too old to define an
  76. identification macro. Try to identify the platform and guess that
  77. it is the native compiler. */
  78. #elif defined(__sgi)
  79. # define COMPILER_ID "MIPSpro"
  80. #elif defined(__hpux) || defined(__hpua)
  81. # define COMPILER_ID "HP"
  82. #else /* unknown compiler */
  83. # define COMPILER_ID ""
  84. #endif
  85. /* Construct the string literal in pieces to prevent the source from
  86. getting matched. Store it in a pointer rather than an array
  87. because some compilers will just produce instructions to fill the
  88. array rather than assigning a pointer to a static array. */
  89. char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]";
  90. @CMAKE_C_COMPILER_ID_PLATFORM_CONTENT@
  91. /*--------------------------------------------------------------------------*/
  92. #ifdef ID_VOID_MAIN
  93. void main() {}
  94. #else
  95. int main(int argc, char* argv[])
  96. {
  97. int require = 0;
  98. require += info_compiler[argc];
  99. require += info_platform[argc];
  100. require += info_arch[argc];
  101. #ifdef COMPILER_VERSION_MAJOR
  102. require += info_version[argc];
  103. #endif
  104. (void)argv;
  105. return require;
  106. }
  107. #endif