-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
61 lines (49 loc) · 1.97 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#-- require at least cmake version 3.8
cmake_minimum_required (VERSION 3.8)
#-- specify configuration options
option (USE_MPI "USE_MPI" ON)
option (USE_OPENMP "USE_OPENMP" ON)
#-- name the project and set the language
project (SuperNu)
set (SuperNu_VERSION_MAJOR 4)
set (SuperNu_VERSION_MINOR "x")
enable_language (Fortran)
#-- add the build directory to the include-file search path
include_directories(${PROJECT_BINARY_DIR})
#-- copy dummy commit version file, for now
configure_file(version_dummy.inc version.inc COPYONLY)
#-- find MPI (cmake -DUSE_MPI=ON <src dir>)
find_package (MPI)
if (MPI_Fortran_FOUND AND USE_MPI)
configure_file (mpimod_mpi.f mpimod.f COPYONLY)
else ()
configure_file (mpimod_ser.f mpimod.f COPYONLY)
endif ()
#-- find OpenMP (cmake -DUSE_OPENMP=ON <src dir>)
find_package (OpenMP)
if (OPENMP_FOUND AND USE_OPENMP)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif ()
#-- set the Fortran module directory
set (CMAKE_Fortran_MODULE_DIRECTORY ${PROJECT_BINARY_DIR})
#-- create lists of top-level source files
file (GLOB_RECURSE SuperNu_FILES "*.f" "*.f90")
#-- remove versions of mpimod from .f list
file (GLOB MPIMOD "mpimod_mpi.f" "mpimod_ser.f")
list (REMOVE_ITEM SuperNu_FILES ${MPIMOD})
list (APPEND SuperNu_FILES "${PROJECT_BINARY_DIR}/mpimod.f")
#-- add the executable and link MPI libraries
add_executable (supernu ${SuperNu_FILES})
#-- link library and include header for MPI
if (MPI_Fortran_FOUND AND USE_MPI)
target_link_libraries (supernu PRIVATE ${MPI_C_LIBRARIES})
target_include_directories (supernu PRIVATE ${MPI_C_INCLUDE_PATH})
target_link_libraries (supernu PRIVATE ${MPI_Fortran_LIBRARIES})
target_include_directories (supernu PRIVATE ${MPI_Fortran_INCLUDE_PATH})
endif ()
#-- indicate successful configuration
message ("")
message ("SuperNu Version " ${SuperNu_VERSION_MAJOR} "."
${SuperNu_VERSION_MINOR} " configured.")
message ("")