CMakeBackwardCompatibilityCXX.cmake 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #.rst:
  4. # CMakeBackwardCompatibilityCXX
  5. # -----------------------------
  6. #
  7. # define a bunch of backwards compatibility variables
  8. #
  9. # ::
  10. #
  11. # CMAKE_ANSI_CXXFLAGS - flag for ansi c++
  12. # CMAKE_HAS_ANSI_STRING_STREAM - has <strstream>
  13. # include(TestForANSIStreamHeaders)
  14. # include(CheckIncludeFileCXX)
  15. # include(TestForSTDNamespace)
  16. # include(TestForANSIForScope)
  17. if(NOT CMAKE_SKIP_COMPATIBILITY_TESTS)
  18. # check for some ANSI flags in the CXX compiler if it is not gnu
  19. if(NOT CMAKE_COMPILER_IS_GNUCXX)
  20. include(TestCXXAcceptsFlag)
  21. set(CMAKE_TRY_ANSI_CXX_FLAGS "")
  22. if(CMAKE_SYSTEM_NAME MATCHES "IRIX")
  23. set(CMAKE_TRY_ANSI_CXX_FLAGS "-LANG:std")
  24. endif()
  25. if(CMAKE_SYSTEM_NAME MATCHES "OSF")
  26. set(CMAKE_TRY_ANSI_CXX_FLAGS "-std strict_ansi -nopure_cname")
  27. endif()
  28. # if CMAKE_TRY_ANSI_CXX_FLAGS has something in it, see
  29. # if the compiler accepts it
  30. if(NOT CMAKE_TRY_ANSI_CXX_FLAGS STREQUAL "")
  31. CHECK_CXX_ACCEPTS_FLAG(${CMAKE_TRY_ANSI_CXX_FLAGS} CMAKE_CXX_ACCEPTS_FLAGS)
  32. # if the compiler liked the flag then set CMAKE_ANSI_CXXFLAGS
  33. # to the flag
  34. if(CMAKE_CXX_ACCEPTS_FLAGS)
  35. set(CMAKE_ANSI_CXXFLAGS ${CMAKE_TRY_ANSI_CXX_FLAGS} CACHE INTERNAL
  36. "What flags are required by the c++ compiler to make it ansi." )
  37. endif()
  38. endif()
  39. endif()
  40. set(CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS})
  41. string(APPEND CMAKE_CXX_FLAGS " ${CMAKE_ANSI_CXXFLAGS}")
  42. include(TestForANSIStreamHeaders)
  43. include(CheckIncludeFileCXX)
  44. include(TestForSTDNamespace)
  45. include(TestForANSIForScope)
  46. include(TestForSSTREAM)
  47. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_SAVE}")
  48. endif()