From: Matthias Maier <tamiko@kyomu.43-1.org>
Date: Thu, 31 Oct 2013 10:41:10 +0000 (+0000)
Subject: Try to fix the compilation problems under Windows
X-Git-Tag: v8.1.0~443
X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08135da6eb4e8e2f9c3892576651713ef4a3e04a;p=dealii.git

Try to fix the compilation problems under Windows

git-svn-id: https://svn.dealii.org/trunk@31494 0785d39b-7218-0410-832d-ea1e28bc413d
---

diff --git a/deal.II/cmake/checks/check_02_system_features.cmake b/deal.II/cmake/checks/check_02_system_features.cmake
index 7980378ed2..e0329dbd27 100644
--- a/deal.II/cmake/checks/check_02_system_features.cmake
+++ b/deal.II/cmake/checks/check_02_system_features.cmake
@@ -109,7 +109,54 @@ ENDIF()
 #                                                                      #
 ########################################################################
 
+
+IF( CMAKE_SYSTEM_NAME MATCHES "CYGWIN"
+    OR CMAKE_SYSTEM_NAME MATCHES "Windows" )
+  IF( CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND
+      CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8" )
+
+    #
+    # Print a warning if we have a gcc port that is older than gcc-4.8:
+    #
+
+    MESSAGE(WARNING "\n"
+      "GCC ports (Cygwin or MinGW) older than version 4.8 are unsupported on Windows\n\n"
+      )
+
+  ELSE()
+
+    #
+    # Workaround for a compiler bug on Windows platforms with modern gcc:
+    #
+    # GCC seems to have a hard time with
+    #
+    #   next_free_pair_object and next_free_single_object
+    #
+    # defined in tria_objects.h. It might explode in one ot the following ways:
+    #  a) Internal compiler error
+    #  b) emition of a truncated external symbol
+    #  c) "template <...>::dimension could not be converted to 'int'"
+    #
+    # It seems to help to specify "-ggdb" also for optimized mode.
+    #
+    # TODO: Track down bug and fix properly (just kidding).
+    #
+    # Maier, 2013
+    #
+
+    ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_RELEASE "-ggdb")
+    ENABLE_IF_SUPPORTED(DEAL_II_LINKER_FLAGS_RELEASE "-ggdb")
+    IF(NOT DEAL_II_HAVE_FLAG_ggdb)
+      ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_RELEASE "-g")
+      ENABLE_IF_SUPPORTED(DEAL_II_LINKER_FLAGS_RELEASE "-g")
+    ENDIF()
+
+  ENDIF()
+ENDIF()
+
+
 IF(CMAKE_SYSTEM_NAME MATCHES "Windows")
+
   #
   # Export DEAL_II_MSVC if we are on a Windows platform:
   #
@@ -118,6 +165,7 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Windows")
   #
   # Shared library handling:
   #
+
   IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
     # With MinGW we're lucky:
     ENABLE_IF_LINKS(DEAL_II_LINKER_FLAGS "-Wl,--export-all-symbols")
@@ -132,9 +180,3 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Windows")
   ENDIF()
 
 ENDIF()
-
-
-IF( CMAKE_SYSTEM_NAME MATCHES "CYGWIN"
-    OR CMAKE_SYSTEM_NAME MATCHES "Windows" )
-  # TODO: Bailout if current compiler is not gcc-4.8.1 or newer
-ENDIF()
diff --git a/deal.II/doc/developers/Toolchain-x86_64-w64-mingw32.sample b/deal.II/doc/developers/Toolchain-x86_64-w64-mingw32.sample
index 68e826f9e3..a26bf5a609 100644
--- a/deal.II/doc/developers/Toolchain-x86_64-w64-mingw32.sample
+++ b/deal.II/doc/developers/Toolchain-x86_64-w64-mingw32.sample
@@ -8,7 +8,7 @@ SET(CMAKE_SYSTEM_PROCESSOR "x86_64")
 SET(CMAKE_RC_COMPILER "x86_64-w64-mingw32-windres")
 SET(CMAKE_CXX_COMPILER "x86_64-w64-mingw32-g++")
 SET(CMAKE_C_COMPILER "x86_64-w64-mingw32-gcc")
-SET(CMAKE_Fortran_COMPILER "x86_64-w64-mingw32-gfortran") # alternatively set to '/bin/false'
+SET(CMAKE_Fortran_COMPILER "x86_64-w64-mingw32-gfortran")
 
 SET(CMAKE_FIND_ROOT_PATH "/usr/x86_64-w64-mingw32/")
 SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)