1
0

Clang-CXX.cmake 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. include(Compiler/Clang)
  2. __compiler_clang(CXX)
  3. if(NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
  4. set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
  5. endif()
  6. cmake_policy(GET CMP0025 appleClangPolicy)
  7. if(WIN32 OR (APPLE AND NOT appleClangPolicy STREQUAL NEW))
  8. return()
  9. endif()
  10. if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1)
  11. set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
  12. set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
  13. endif()
  14. if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
  15. set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
  16. set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
  17. elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1)
  18. set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x")
  19. set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x")
  20. endif()
  21. if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)
  22. set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14")
  23. set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14")
  24. elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
  25. set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y")
  26. set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y")
  27. endif()
  28. set(CMAKE_CXX_STANDARD_DEFAULT 98)
  29. macro(cmake_record_cxx_compile_features)
  30. macro(_get_clang_features std_version list)
  31. record_compiler_features(CXX "${std_version}" ${list})
  32. endmacro()
  33. if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
  34. _get_clang_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES)
  35. if (_result EQUAL 0)
  36. _get_clang_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES)
  37. endif()
  38. if (_result EQUAL 0)
  39. _get_clang_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES)
  40. endif()
  41. else()
  42. set(_result 0)
  43. endif()
  44. endmacro()