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