Commits

Anonymous committed 84c459d

ENH: Added automatic inclusion of ANSI C++ flags.

  • Participants
  • Parent commits 3d60535
  • Branches gccxml-0-6
  • Tags gccxml-0-6-0

Comments (0)

Files changed (1)

GCC_XML/CMakeLists.txt

                ${GCCXML_BINARY_DIR}/GXFront/gxConfigure.h)
 INCLUDE_DIRECTORIES(${GCCXML_BINARY_DIR}/GXFront)
 
-# Be sure to use ANSI compiler flags.
-IF(CMAKE_ANSI_CXXFLAGS)
-  SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}")
-ENDIF(CMAKE_ANSI_CXXFLAGS)
+# Check for ANSI flags on non-GNU compilers.
+IF(NOT CMAKE_COMPILER_IS_GNUCXX)
+  SET(CMAKE_TRY_ANSI_CXX_FLAGS "")
+  IF(CMAKE_SYSTEM MATCHES "IRIX.*")
+    SET(CMAKE_TRY_ANSI_CXX_FLAGS "-LANG:std")
+  ENDIF(CMAKE_SYSTEM MATCHES "IRIX.*")
+  IF(CMAKE_SYSTEM MATCHES "OSF.*")
+    SET(CMAKE_TRY_ANSI_CXX_FLAGS "-std strict_ansi -nopure_cname")
+  ENDIF(CMAKE_SYSTEM MATCHES "OSF.*")
+  IF(CMAKE_CXX_ACCEPTS_FLAGS MATCHES "^CMAKE_CXX_ACCEPTS_FLAGS$")
+    INCLUDE(${CMAKE_ROOT}/Modules/TestCXXAcceptsFlag.cmake)
+    # if CMAKE_TRY_ANSI_CXX_FLAGS has something in it, see
+    # if the compiler accepts it
+    IF(CMAKE_TRY_ANSI_CXX_FLAGS MATCHES ".+")
+      CHECK_CXX_ACCEPTS_FLAG("${CMAKE_TRY_ANSI_CXX_FLAGS}" CMAKE_CXX_ACCEPTS_FLAGS)
+      # if the compiler liked the flag then set CMAKE_ANSI_CXXFLAGS
+      # to the flag
+    ELSE(CMAKE_TRY_ANSI_CXX_FLAGS MATCHES ".+")
+      SET(CMAKE_CXX_ACCEPTS_FLAGS 0)
+    ENDIF(CMAKE_TRY_ANSI_CXX_FLAGS MATCHES ".+")
+  ENDIF(CMAKE_CXX_ACCEPTS_FLAGS MATCHES "^CMAKE_CXX_ACCEPTS_FLAGS$")
+  IF(CMAKE_CXX_ACCEPTS_FLAGS)
+    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_TRY_ANSI_CXX_FLAGS}")
+  ENDIF(CMAKE_CXX_ACCEPTS_FLAGS)
+ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX)
 
 # Figure out what is being used to build GCC-XML.
 SET(GCCXML_CXX_COMPILER "${CMAKE_CXX_COMPILER}")