CMakeBackwardCompatibilityCXX.cmake 2.3 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 distributed 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(CMAKE_SYSTEM MATCHES "IRIX.*")
  28. IF(CMAKE_SYSTEM MATCHES "OSF.*")
  29. SET(CMAKE_TRY_ANSI_CXX_FLAGS "-std strict_ansi -nopure_cname")
  30. ENDIF(CMAKE_SYSTEM MATCHES "OSF.*")
  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(CMAKE_CXX_ACCEPTS_FLAGS)
  41. ENDIF( CMAKE_TRY_ANSI_CXX_FLAGS MATCHES ".+")
  42. ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX)
  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(NOT CMAKE_SKIP_COMPATIBILITY_TESTS)