GNU-CXX.cmake 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. include(Compiler/GNU)
  2. __compiler_gnu(CXX)
  3. if (WIN32)
  4. if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6)
  5. set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fno-keep-inline-dllexport")
  6. endif()
  7. else()
  8. if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0)
  9. set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
  10. endif()
  11. endif()
  12. if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
  13. set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
  14. set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
  15. endif()
  16. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
  17. set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON)
  18. set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
  19. set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
  20. elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4)
  21. # 4.3 supports 0x variants
  22. set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x")
  23. set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x")
  24. endif()
  25. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8.1)
  26. set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON)
  27. endif()
  28. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
  29. set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14")
  30. set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14")
  31. elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
  32. set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y")
  33. set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y")
  34. endif()
  35. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
  36. set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON)
  37. endif()
  38. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
  39. set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17")
  40. set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17")
  41. elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
  42. set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++1z")
  43. set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z")
  44. endif()
  45. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
  46. set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a")
  47. set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a")
  48. endif()
  49. __compiler_check_default_language_standard(CXX 3.4 98 6.0 14)