1# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2# file Copyright.txt or https://cmake.org/licensing for details.
3
4#[=======================================================================[.rst:
5CMakeBackwardCompatibilityCXX
6-----------------------------
7
8define a bunch of backwards compatibility variables
9
10::
11
12  CMAKE_ANSI_CXXFLAGS - flag for ansi c++
13  CMAKE_HAS_ANSI_STRING_STREAM - has <strstream>
14  include(TestForANSIStreamHeaders)
15  include(CheckIncludeFileCXX)
16  include(TestForSTDNamespace)
17  include(TestForANSIForScope)
18#]=======================================================================]
19
20if(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_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}")
48endif()
49
50