CMakeBackwardCompatibilityCXX.cmake 2.1 KB

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