GNU-CXX.cmake 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. include(Compiler/GNU)
  2. __compiler_gnu(CXX)
  3. if((NOT DEFINED CMAKE_DEPENDS_USE_COMPILER OR CMAKE_DEPENDS_USE_COMPILER)
  4. AND CMAKE_GENERATOR MATCHES "Makefiles|WMake"
  5. AND CMAKE_DEPFILE_FLAGS_CXX)
  6. # dependencies are computed by the compiler itself
  7. set(CMAKE_CXX_DEPFILE_FORMAT gcc)
  8. set(CMAKE_CXX_DEPENDS_USE_COMPILER TRUE)
  9. endif()
  10. set(CMAKE_CXX_COMPILE_OPTIONS_EXPLICIT_LANGUAGE -x c++)
  11. if (WIN32)
  12. if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6)
  13. set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fno-keep-inline-dllexport")
  14. endif()
  15. else()
  16. if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0)
  17. set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
  18. endif()
  19. endif()
  20. if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
  21. set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
  22. set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
  23. endif()
  24. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
  25. set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON)
  26. set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
  27. set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
  28. elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4)
  29. # 4.3 supports 0x variants
  30. set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x")
  31. set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x")
  32. endif()
  33. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8.1)
  34. set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON)
  35. endif()
  36. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
  37. set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14")
  38. set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14")
  39. elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
  40. set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y")
  41. set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y")
  42. endif()
  43. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
  44. set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON)
  45. endif()
  46. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
  47. set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17")
  48. set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17")
  49. elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.1)
  50. set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++1z")
  51. set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z")
  52. endif()
  53. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0)
  54. set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a")
  55. set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a")
  56. endif()
  57. __compiler_check_default_language_standard(CXX 3.4 98 6.0 14)