Clang-CXX.cmake 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. if(UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
  29. set(CMAKE_CXX_STANDARD_DEFAULT 98)
  30. endif()
  31. macro(cmake_record_cxx_compile_features)
  32. macro(_get_clang_features std_version list)
  33. record_compiler_features(CXX "${std_version}" ${list})
  34. endmacro()
  35. set(_result 0)
  36. if (UNIX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
  37. _get_clang_features(${CMAKE_CXX14_STANDARD_COMPILE_OPTION} CMAKE_CXX14_COMPILE_FEATURES)
  38. if (_result EQUAL 0)
  39. _get_clang_features(${CMAKE_CXX11_STANDARD_COMPILE_OPTION} CMAKE_CXX11_COMPILE_FEATURES)
  40. endif()
  41. if (_result EQUAL 0)
  42. _get_clang_features(${CMAKE_CXX98_STANDARD_COMPILE_OPTION} CMAKE_CXX98_COMPILE_FEATURES)
  43. endif()
  44. endif()
  45. endmacro()