CMakeBackwardCompatibilityCXX.cmake 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #.rst:
  2. # CMakeBackwardCompatibilityCXX
  3. # -----------------------------
  4. #
  5. # define a bunch of backwards compatibility variables
  6. #
  7. # ::
  8. #
  9. # CMAKE_ANSI_CXXFLAGS - flag for ansi c++
  10. # CMAKE_HAS_ANSI_STRING_STREAM - has <strstream>
  11. # include(TestForANSIStreamHeaders)
  12. # include(CheckIncludeFileCXX)
  13. # include(TestForSTDNamespace)
  14. # include(TestForANSIForScope)
  15. #=============================================================================
  16. # Copyright 2002-2009 Kitware, Inc.
  17. #
  18. # Distributed under the OSI-approved BSD License (the "License");
  19. # see accompanying file Copyright.txt for details.
  20. #
  21. # This software is distributed WITHOUT ANY WARRANTY; without even the
  22. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  23. # See the License for more information.
  24. #=============================================================================
  25. # (To distribute this file outside of CMake, substitute the full
  26. # License text for the above reference.)
  27. if(NOT CMAKE_SKIP_COMPATIBILITY_TESTS)
  28. # check for some ANSI flags in the CXX compiler if it is not gnu
  29. if(NOT CMAKE_COMPILER_IS_GNUCXX)
  30. include(TestCXXAcceptsFlag)
  31. set(CMAKE_TRY_ANSI_CXX_FLAGS "")
  32. if(CMAKE_SYSTEM_NAME MATCHES "IRIX")
  33. set(CMAKE_TRY_ANSI_CXX_FLAGS "-LANG:std")
  34. endif()
  35. if(CMAKE_SYSTEM_NAME MATCHES "OSF")
  36. set(CMAKE_TRY_ANSI_CXX_FLAGS "-std strict_ansi -nopure_cname")
  37. endif()
  38. # if CMAKE_TRY_ANSI_CXX_FLAGS has something in it, see
  39. # if the compiler accepts it
  40. if(NOT CMAKE_TRY_ANSI_CXX_FLAGS STREQUAL "")
  41. CHECK_CXX_ACCEPTS_FLAG(${CMAKE_TRY_ANSI_CXX_FLAGS} CMAKE_CXX_ACCEPTS_FLAGS)
  42. # if the compiler liked the flag then set CMAKE_ANSI_CXXFLAGS
  43. # to the flag
  44. if(CMAKE_CXX_ACCEPTS_FLAGS)
  45. set(CMAKE_ANSI_CXXFLAGS ${CMAKE_TRY_ANSI_CXX_FLAGS} CACHE INTERNAL
  46. "What flags are required by the c++ compiler to make it ansi." )
  47. endif()
  48. endif()
  49. endif()
  50. set(CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS})
  51. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}")
  52. include(TestForANSIStreamHeaders)
  53. include(CheckIncludeFileCXX)
  54. include(TestForSTDNamespace)
  55. include(TestForANSIForScope)
  56. include(TestForSSTREAM)
  57. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_SAVE}")
  58. endif()