forked from scivision/fortran2018-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
47 lines (39 loc) · 1.72 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
cmake_minimum_required(VERSION 3.14...3.20)
project(F18coarray Fortran)
enable_testing()
# Coarrays are easier to use than MPI and more general as an intrinsic part of Fortran 2008.
# Linux: apt install libcoarrays-dev open-coarrays-bin
# Mac: brew install opencoarrays
get_directory_property(hasParent PARENT_DIRECTORY)
if(NOT hasParent)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/Modules)
find_package(MPI COMPONENTS Fortran)
endif()
find_package(Coarray)
if(NOT (Coarray_FOUND AND MPI_Fortran_FOUND))
message(STATUS "SKIP: Coarray")
return()
endif()
# # "sync all" call is necessary to actually verify dynamically linked MPI stack works.
# include(CheckFortranSourceRuns)
# set(CMAKE_REQUIRED_FLAGS ${Coarray_COMPILE_OPTIONS})
# set(CMAKE_REQUIRED_INCLUDES ${Coarray_INCLUDE_DIRS})
# set(CMAKE_REQUIRED_LIBRARIES ${Coarray_LIBRARIES})
# check_fortran_source_runs("sync all; end"
# f08coarray SRC_EXT f90)
# if(NOT f08coarray)
# message(STATUS "SKIP: Coarray")
# return()
# endif()
# check_fortran_source_runs("real :: x[*]; call co_sum(x); sync all; end"
# f18coarray SRC_EXT f90)
add_executable(coarray_hello helloworld.f90)
target_link_libraries(coarray_hello PRIVATE Coarray::Coarray)
add_test(NAME coarray:Hello
COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} $<TARGET_FILE:coarray_hello>)
set_tests_properties(coarray:Hello PROPERTIES RESOURCE_LOCK cpu_mpi)
add_executable(coarray_pi pi.f90)
target_link_libraries(coarray_pi PRIVATE Coarray::Coarray)
add_test(NAME coarray:pi_sum
COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} $<TARGET_FILE:coarray_pi>)
set_tests_properties(coarray:pi_sum PROPERTIES RESOURCE_LOCK cpu_mpi)