3535 )
3636endif ()
3737
38+
3839if (CMAKE_VERSION VERSION_GREATER 3.2.3)
3940 # Detect Fortran compiler version directly
4041 if (gfortran_compiler AND (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER 5.0.0))
@@ -44,6 +45,17 @@ if (CMAKE_VERSION VERSION_GREATER 3.2.3)
4445 set (opencoarrays_aware_compiler false )
4546 add_definitions (-DPREFIX_NAME=_caf_extensions_)
4647 endif ()
48+ if (gfortran_compiler AND (CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 5.4))
49+ # GCC patch to fix issue accepted for 5.4 release
50+ # See https://github.com/sourceryinstitute/opencoarrays/issues/28 and
51+ # https://groups.google.com/forum/#!msg/opencoarrays/RZOwwYTqG80/46S9eL696dgJ
52+ message ( STATUS "Disabling optimization flags due to GCC < 5.4 bug" )
53+ set (CMAKE_Fortran_FLAGS_RELEASE -O0
54+ CACHE STRING "Flags used by the compiler during release builds." FORCE)
55+ set (CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -DNDEBUG -O0"
56+ CACHE STRING "Flags used by the compiler during release builds with debug info" FORCE)
57+ set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O0" )
58+ endif ()
4759else ()
4860 # Use the C compiler version as a proxy for the Fortran compiler version (won't work with NAG)
4961 if (gfortran_compiler AND (CMAKE_C_COMPILER_VERSION VERSION_GREATER 5.0.0))
@@ -53,6 +65,17 @@ else()
5365 set (opencoarrays_aware_compiler false )
5466 add_definitions (-DPREFIX_NAME=_caf_extensions_)
5567 endif ()
68+ if (gfortran_compiler AND (CMAKE_C_COMPILER_VERSION VERSION_LESS 5.4))
69+ # GCC patch to fix issue accepted for the 5.4 release
70+ # See https://github.com/sourceryinstitute/opencoarrays/issues/28 and
71+ # https://groups.google.com/forum/#!msg/opencoarrays/RZOwwYTqG80/46S9eL696dgJ
72+ message ( STATUS "Disabling optimization flags due to GCC < 5.4 bug" )
73+ set (CMAKE_Fortran_FLAGS_RELEASE -O0
74+ CACHE STRING "Flags used by the compiler during release builds." FORCE)
75+ set (CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -DNDEBUG -O0"
76+ CACHE STRING "Flags used by the compiler during release builds with debug info" FORCE)
77+ set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O0" )
78+ endif ()
5679endif ()
5780
5881
0 commit comments