@@ -6,8 +6,13 @@ set ( CMAKE_BUILD_TYPE "Release"
66 CACHE STRING "Select which configuration to build." )
77set_property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES} )
88
9- #Name project and specify source languages
10- project (opencoarrays VERSION 1.8.3 LANGUAGES C Fortran)
9+ # Name project and specify source languages
10+ # Parse version from .VERSION file so that more info can be added and easier to get from scripts
11+ file ( STRINGS ".VERSION" OpenCoarraysVersion
12+ REGEX "[0-9]+\\ .[0-9]+\\ .[0-9]+"
13+ )
14+ project (opencoarrays VERSION "${OpenCoarraysVersion} " LANGUAGES C Fortran)
15+ message ( STATUS "Building OpenCoarrays version: ${OpenCoarraysVersion} " )
1116
1217#Print an error message on an attempt to build inside the source directory tree:
1318if ("${CMAKE_CURRENT_SOURCE_DIR} " STREQUAL "${CMAKE_CURRENT_BINARY_DIR} " )
@@ -45,8 +50,48 @@ else()
4550 )
4651endif ()
4752
48- if (NOT (CMAKE_VERSION VERSION_LESS 3.3.1))
49- # Detect Fortran compiler version directly
53+ #-----------------------------------------------------------------
54+ # Set CMAKE_Fortran_COMPILER_VERSION if CMake doesn't do it for us
55+ #-----------------------------------------------------------------
56+ if ( NOT CMAKE_Fortran_COMPILER_VERSION )
57+ if ( NOT (CMAKE_VERSION VERSION_LESS 3.3.1) )
58+ message ( AUTHOR_WARNING
59+ "CMake ${CMAKE_VERSION} should know about Fortran compiler versions but is missing CMAKE_Fortran_COMPILER_VERSION variable."
60+ )
61+ endif ()
62+ # No CMAKE_Fortran_COMPILER_VERSION set, build our own
63+ # Try extracting it directly from ISO_FORTRAN_ENV's compiler_version
64+ # Write program for introspection
65+ file ( WRITE "${CMAKE_BINARY_DIR} /get_compiler_ver.f90"
66+ "program main
67+ use iso_fortran_env, only: compiler_version, output_unit
68+ write(output_unit,'(a)') compiler_version()
69+ end program"
70+ )
71+ try_run ( PROG_RAN COMPILE_SUCCESS
72+ "${CMAKE_BINARY_DIR} " "${CMAKE_BINARY_DIR} /get_compiler_ver.f90"
73+ RUN_OUTPUT_VARIABLE VER_STRING
74+ )
75+ if ( COMPILE_SUCCESS )
76+ string ( REGEX MATCH "[0-9]+\\ .[0-9]+(\\ .[0-9]+)?"
77+ DETECTED_VER "${VER_STRING} "
78+ )
79+ message ( STATUS "Detected Fortran compiler as ${VER_STRING} " )
80+ message ( STATUS "Extracted version number: ${DETECTED_VER} " )
81+ endif ()
82+ if ( ( NOT COMPILE_SUCCESS ) OR ( NOT DETECTED_VER ) )
83+ message ( WARNING "Could not reliably detect Fortran compiler version. We'll infer it from
84+ the C compiler if it matches the Fortran compiler ID." )
85+ endif ()
86+ if ( "${CMAKE_C_COMPILER_ID} " MATCHES "${CMAKE_Fortran_COMPILER_ID} " )
87+ set ( DETECTED_VER "${CMAKE_C_COMPILER_VERSION} " )
88+ else ()
89+ message ( FATAL_ERROR "Exhausted all possible means of detecting the Fortran compiler version, cannot proceed!" )
90+ endif ()
91+ set ( CMAKE_Fortran_COMPILER_VERSION "${DETECTED_VER} " )
92+ endif ()
93+
94+ # We have populated CMAKE_Fortran_COMPILER_VERSION if it was missing
5095 if (gfortran_compiler AND (CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER 5.0.0))
5196 set (opencoarrays_aware_compiler true )
5297 add_definitions (-DPREFIX_NAME=_gfortran_caf_)
@@ -65,27 +110,9 @@ if (NOT (CMAKE_VERSION VERSION_LESS 3.3.1))
65110 CACHE STRING "Flags used by the compiler during release builds with debug info" FORCE)
66111 set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O0" )
67112 endif ()
68- else ()
69- # Use the C compiler version as a proxy for the Fortran compiler version (won't work with NAG)
70- if (gfortran_compiler AND (CMAKE_C_COMPILER_VERSION VERSION_GREATER 5.0.0))
71- set (opencoarrays_aware_compiler true )
72- add_definitions (-DPREFIX_NAME=_gfortran_caf_)
73- else ()
74- set (opencoarrays_aware_compiler false )
75- add_definitions (-DPREFIX_NAME=_caf_extensions_)
113+ if ( gfortran_compiler AND ( NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0.0 ) )
114+ add_definitions (-DGCC_GE_7) # Tell library to build against GFortran 7.x bindings b/c we might be using clang for C
76115 endif ()
77- if (gfortran_compiler AND (CMAKE_C_COMPILER_VERSION VERSION_LESS 5.4))
78- # GCC patch to fix issue accepted for the 5.4 release
79- # See https://github.com/sourceryinstitute/opencoarrays/issues/28 and
80- # https://groups.google.com/forum/#!msg/opencoarrays/RZOwwYTqG80/46S9eL696dgJ
81- message ( STATUS "Disabling optimization flags due to GCC < 5.4 bug" )
82- set (CMAKE_Fortran_FLAGS_RELEASE -O0
83- CACHE STRING "Flags used by the compiler during release builds." FORCE)
84- set (CMAKE_Fortran_FLAGS_RELWITHDEBINFO "-g -DNDEBUG -O0"
85- CACHE STRING "Flags used by the compiler during release builds with debug info" FORCE)
86- set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -O0" )
87- endif ()
88- endif ()
89116
90117if (gfortran_compiler)
91118 set (OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} )
@@ -119,10 +146,10 @@ get_filename_component( FTN_COMPILER_DIR "${CMAKE_Fortran_COMPILER}"
119146get_filename_component ( C_COMPILER_DIR "${CMAKE_C_COMPILER} "
120147 REALPATH )
121148
122- if (FTN_COMPILER_NAME MATCHES ' ^[mM][pP][iI]' )
149+ if (FTN_COMPILER_NAME MATCHES " ^[mM][pP][iI]" )
123150 set (MPI_Fortran_COMPILER "${CMAKE_Fortran_COMPILER} " )
124151endif ()
125- if (C_COMPILER_NAME MATCHES ' ^[mM][pP][iI]' )
152+ if (C_COMPILER_NAME MATCHES " ^[mM][pP][iI]" )
126153 set (MPI_C_COMPILER "${CMAKE_C_COMPILER} " )
127154endif ()
128155
@@ -271,6 +298,11 @@ set(CMAKE_Fortran_COMPILE_FLAGS ${CMAKE_Fortran_COMPILE_FLAGS} ${MPI_Fortran_COM
271298set (CMAKE_Fortran_LINK_FLAGS ${CMAKE_Fortran_LINK_FLAGS} ${MPI_Fortran_LINK_FLAGS} )
272299include_directories (BEFORE ${MPI_C_INCLUDE_PATH} ${MPI_Fortran_INCLUDE_PATH} )
273300
301+ #---------------------------------------------------
302+ # Use standardized GNU install directory conventions
303+ #---------------------------------------------------
304+ include (GNUInstallDirs)
305+
274306#-------------------------------
275307# Recurse into the src directory
276308#-------------------------------
@@ -285,7 +317,7 @@ install(EXPORT OpenCoarraysTargets
285317 NAMESPACE
286318 OpenCoarrays::
287319 DESTINATION
288- lib /cmake/opencoarrays
320+ " ${CMAKE_INSTALL_LIBDIR} /cmake/opencoarrays"
289321)
290322include (CMakePackageConfigHelpers) # standard CMake module
291323write_basic_package_version_file(
@@ -301,15 +333,13 @@ install(
301333 "${CMAKE_CURRENT_BINARY_DIR} /CMakeFiles/OpenCoarraysConfig.cmake"
302334 "${CMAKE_CURRENT_BINARY_DIR} /OpenCoarraysConfigVersion.cmake"
303335 DESTINATION
304- lib /cmake/opencoarrays
336+ " ${CMAKE_INSTALL_LIBDIR} /cmake/opencoarrays"
305337)
306338
307339add_library (OpenCoarrays INTERFACE )
308340target_compile_options (OpenCoarrays INTERFACE -fcoarray=lib)
309341target_link_libraries (OpenCoarrays INTERFACE caf_mpi)
310342
311- install (DIRECTORY ${CMAKE_BINARY_DIR} /mod DESTINATION .)
312-
313343#------------------------------------------
314344# Add portable unistall command to makefile
315345#------------------------------------------
@@ -390,6 +420,7 @@ if(opencoarrays_aware_compiler)
390420 add_mpi_test(syncimages2 32 ${tests_root} /unit/sync/syncimages2)
391421 add_mpi_test(duplicate_syncimages 8 ${tests_root} /unit/sync/duplicate_syncimages)
392422 add_mpi_test(co_reduce 4 ${tests_root} /unit/collectives/co_reduce_test)
423+ add_mpi_test(co_reduce_res_im 4 ${tests_root} /unit/collectives/co_reduce_res_im)
393424 add_mpi_test(syncimages_status 32 ${tests_root} /unit/sync/syncimages_status)
394425 add_mpi_test(sync_ring_abort_np3 3 ${tests_root} /unit/sync/sync_image_ring_abort_on_stopped_image)
395426 add_mpi_test(sync_ring_abort_np7 7 ${tests_root} /unit/sync/sync_image_ring_abort_on_stopped_image)
@@ -402,16 +433,17 @@ if(opencoarrays_aware_compiler)
402433 add_mpi_test(coarray_burgers_pde 2 ${tests_root} /integration/pde_solvers/coarrayBurgers/coarray_burgers_pde)
403434 add_mpi_test(co_heat 2 ${tests_root} /integration/pde_solvers/coarrayHeatSimplified/co_heat)
404435 add_mpi_test(asynchronous_hello_world 3 ${tests_root} /integration/events/asynchronous_hello_world)
405- if ( ("${CMAKE_SYSTEM_PROCESSOR} " MATCHES "x86_64" ) AND ("${CMAKE_SYSTEM_NAME} " MATCHES "Linux" ) )
406- if ( (NOT (DEFINED ENV{TRAVIS})) AND (NOT SKIP_ASSEMBLY_DEPS) )
407- add_mpi_test(coarray_navier_stokes 2 ${tests_root} /integration/pde_solvers/navier-stokes/coarray_navier_stokes)
408- set_property (TEST coarray_navier_stokes PROPERTY PASS_REGULAR_EXPRESSION "Test passed." )
409- endif ()
410- endif ()
411436
412437 # Regression tests based on reported issues
438+ if (gfortran_compiler AND (NOT CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 7.0.0))
439+ # GFortran PR 78505 only fixed on trunk/gcc 7
440+ add_mpi_test(source -alloc-no -sync 8 ${tests_root} /regression/reported/source -alloc-sync)
441+ endif ()
413442 add_mpi_test(convert-before-put 3 ${tests_root} /regression/reported/convert-before-put)
414443 add_mpi_test(event-post 3 ${tests_root} /regression/reported/event-post)
444+ add_mpi_test(co_reduce-factorial 4 ${tests_root} /regression/reported/co_reduce-factorial)
445+ # remove this before merging into master
446+ set_property (TEST co_reduce-factorial PROPERTY WILL_FAIL TRUE )
415447else ()
416448 add_test (co_sum_extension ${tests_root} /unit/extensions/test -co_sum-extension.sh)
417449 set_property (TEST co_sum_extension PROPERTY PASS_REGULAR_EXPRESSION "Test passed." )
0 commit comments