Clang-OBJCXX.cmake 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. include(Compiler/Clang)
  2. __compiler_clang(OBJCXX)
  3. if("x${CMAKE_OBJCXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
  4. if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 2.1)
  5. set(CMAKE_OBJCXX98_STANDARD_COMPILE_OPTION "-std=c++98")
  6. set(CMAKE_OBJCXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
  7. endif()
  8. if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 3.1)
  9. set(CMAKE_OBJCXX98_STANDARD__HAS_FULL_SUPPORT ON)
  10. set(CMAKE_OBJCXX11_STANDARD_COMPILE_OPTION "-std=c++11")
  11. set(CMAKE_OBJCXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
  12. set(CMAKE_OBJCXX11_STANDARD__HAS_FULL_SUPPORT ON)
  13. elseif(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 2.1)
  14. set(CMAKE_OBJCXX11_STANDARD_COMPILE_OPTION "-std=c++0x")
  15. set(CMAKE_OBJCXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x")
  16. endif()
  17. if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 3.5)
  18. set(CMAKE_OBJCXX14_STANDARD_COMPILE_OPTION "-std=c++14")
  19. set(CMAKE_OBJCXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14")
  20. set(CMAKE_OBJCXX14_STANDARD__HAS_FULL_SUPPORT ON)
  21. elseif(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 3.4)
  22. set(CMAKE_OBJCXX14_STANDARD_COMPILE_OPTION "-std=c++1y")
  23. set(CMAKE_OBJCXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y")
  24. set(CMAKE_OBJCXX14_STANDARD__HAS_FULL_SUPPORT ON)
  25. endif()
  26. set(_clang_version_std17 5.0)
  27. if (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}")
  28. set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std=c++17")
  29. set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17")
  30. elseif (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 3.5)
  31. set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std=c++1z")
  32. set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z")
  33. endif()
  34. if (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}")
  35. set(CMAKE_OBJCXX20_STANDARD_COMPILE_OPTION "-std=c++2a")
  36. set(CMAKE_OBJCXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a")
  37. endif()
  38. unset(_clang_version_std17)
  39. __compiler_check_default_language_standard(OBJCXX 2.1 98)
  40. elseif(CMAKE_OBJCXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.9
  41. AND CMAKE_OBJCXX_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.0)
  42. # This version of clang-cl and the MSVC version it simulates have
  43. # support for -std: flags.
  44. set(CMAKE_OBJCXX98_STANDARD_COMPILE_OPTION "")
  45. set(CMAKE_OBJCXX98_EXTENSION_COMPILE_OPTION "")
  46. set(CMAKE_OBJCXX98_STANDARD__HAS_FULL_SUPPORT ON)
  47. set(CMAKE_OBJCXX11_STANDARD_COMPILE_OPTION "")
  48. set(CMAKE_OBJCXX11_EXTENSION_COMPILE_OPTION "")
  49. set(CMAKE_OBJCXX14_STANDARD_COMPILE_OPTION "-std:c++14")
  50. set(CMAKE_OBJCXX14_EXTENSION_COMPILE_OPTION "-std:c++14")
  51. if (CMAKE_OBJCXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
  52. set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std:c++17")
  53. set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std:c++17")
  54. set(CMAKE_OBJCXX20_STANDARD_COMPILE_OPTION "-std:c++latest")
  55. set(CMAKE_OBJCXX20_EXTENSION_COMPILE_OPTION "-std:c++latest")
  56. else()
  57. set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std:c++latest")
  58. set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std:c++latest")
  59. endif()
  60. __compiler_check_default_language_standard(OBJCXX 3.9 14)
  61. endif()