BoostDetectToolset-1.72.0.cmake 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. # Copyright 2017-2019 Peter Dimov
  2. # Distributed under the Boost Software License, Version 1.0.
  3. # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
  4. string(REGEX MATCHALL "[0-9]+" _BOOST_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION})
  5. list(GET _BOOST_COMPILER_VERSION 0 _BOOST_COMPILER_VERSION_MAJOR)
  6. list(GET _BOOST_COMPILER_VERSION 1 _BOOST_COMPILER_VERSION_MINOR)
  7. if(BORLAND)
  8. # Borland is unversioned
  9. set(BOOST_DETECTED_TOOLSET "bcb")
  10. set(_BOOST_COMPILER_VERSION_MAJOR)
  11. set(_BOOST_COMPILER_VERSION_MINOR)
  12. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
  13. set(BOOST_DETECTED_TOOLSET "clang-darwin")
  14. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  15. if(MSVC)
  16. set(BOOST_DETECTED_TOOLSET "clangw")
  17. else()
  18. set(BOOST_DETECTED_TOOLSET "clang")
  19. endif()
  20. if(_BOOST_COMPILER_VERSION_MAJOR GREATER 3)
  21. set(_BOOST_COMPILER_VERSION_MINOR)
  22. endif()
  23. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
  24. if(WIN32)
  25. # Intel-Win is unversioned
  26. set(BOOST_DETECTED_TOOLSET "iw")
  27. set(_BOOST_COMPILER_VERSION_MAJOR)
  28. set(_BOOST_COMPILER_VERSION_MINOR)
  29. else()
  30. set(BOOST_DETECTED_TOOLSET "il")
  31. endif()
  32. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MIPSpro")
  33. set(BOOST_DETECTED_TOOLSET "mp")
  34. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro")
  35. set(BOOST_DETECTED_TOOLSET "sun")
  36. elseif(CMAKE_CXX_COMPILER_ID STREQUAL "IBM XL")
  37. set(BOOST_DETECTED_TOOLSET "xlc")
  38. elseif(MINGW)
  39. set(BOOST_DETECTED_TOOLSET "mgw")
  40. if(_BOOST_COMPILER_VERSION_MAJOR GREATER 4)
  41. set(_BOOST_COMPILER_VERSION_MINOR)
  42. endif()
  43. elseif(CMAKE_COMPILER_IS_GNUCXX)
  44. if(APPLE)
  45. set(BOOST_DETECTED_TOOLSET "xgcc")
  46. else()
  47. set(BOOST_DETECTED_TOOLSET "gcc")
  48. endif()
  49. if(_BOOST_COMPILER_VERSION_MAJOR GREATER 4)
  50. set(_BOOST_COMPILER_VERSION_MINOR)
  51. endif()
  52. elseif(MSVC)
  53. if((MSVC_VERSION GREATER 1919) AND (MSVC_VERSION LESS 1930))
  54. set(BOOST_DETECTED_TOOLSET "vc142")
  55. elseif((MSVC_VERSION GREATER 1909) AND (MSVC_VERSION LESS 1920))
  56. set(BOOST_DETECTED_TOOLSET "vc141")
  57. elseif(MSVC_VERSION EQUAL 1900)
  58. set(BOOST_DETECTED_TOOLSET "vc140")
  59. elseif(MSVC_VERSION EQUAL 1800)
  60. set(BOOST_DETECTED_TOOLSET "vc120")
  61. elseif(MSVC_VERSION EQUAL 1700)
  62. set(BOOST_DETECTED_TOOLSET "vc110")
  63. elseif(MSVC_VERSION EQUAL 1600)
  64. set(BOOST_DETECTED_TOOLSET "vc100")
  65. elseif(MSVC_VERSION EQUAL 1500)
  66. set(BOOST_DETECTED_TOOLSET "vc90")
  67. elseif(MSVC_VERSION EQUAL 1400)
  68. set(BOOST_DETECTED_TOOLSET "vc80")
  69. elseif(MSVC_VERSION EQUAL 1310)
  70. set(BOOST_DETECTED_TOOLSET "vc71")
  71. elseif(MSVC_VERSION EQUAL 1300)
  72. set(BOOST_DETECTED_TOOLSET "vc7")
  73. elseif(MSVC_VERSION EQUAL 1200)
  74. set(BOOST_DETECTED_TOOLSET "vc6")
  75. endif()
  76. set(_BOOST_COMPILER_VERSION_MAJOR)
  77. set(_BOOST_COMPILER_VERSION_MINOR)
  78. endif()
  79. # Add version
  80. if(BOOST_DETECTED_TOOLSET)
  81. set(BOOST_DETECTED_TOOLSET ${BOOST_DETECTED_TOOLSET}${_BOOST_COMPILER_VERSION_MAJOR}${_BOOST_COMPILER_VERSION_MINOR})
  82. endif()
  83. unset(_BOOST_COMPILER_VERSION)
  84. unset(_BOOST_COMPILER_VERSION_MAJOR)
  85. unset(_BOOST_COMPILER_VERSION_MINOR)
  86. if("${BOOST_DETECTED_TOOLSET}" STREQUAL "")
  87. # Unknown toolset
  88. message(STATUS "Boost toolset is unknown (compiler ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION})")
  89. elseif(Boost_DEBUG)
  90. message(STATUS "Boost toolset is ${BOOST_DETECTED_TOOLSET} (${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION})")
  91. endif()