-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
87 lines (68 loc) · 3.37 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
cmake_minimum_required (VERSION 3.14)
project (libstell C Fortran)
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake)
find_package (NetCDF MODULE REQUIRED)
find_package (SCALAPACK MODULE REQUIRED)
find_package (MPI REQUIRED)
find_package (BLAS REQUIRED)
find_package (LAPACK REQUIRED)
add_library (stell STATIC)
add_subdirectory (Sources)
OPTION (USE_PROFILER "Activate code profiling." OFF)
# Activate or Deactivate fast copies. The fast copies maybe activated by setting
# -DUSE_FAST_COPY=ON on the cmake command line.
OPTION (USE_FAST_COPY "Activate code fast copies." OFF)
# Fortran specific settings. The first setting tells the compiler to use the C
# preprocessor.
target_compile_options (stell
PUBLIC
$<$<COMPILE_LANGUAGE:Fortran>:-cpp>
$<$<AND:$<Fortran_COMPILER_ID:Intel>,$<COMPILE_LANGUAGE:Fortran>>:-assume byterecl>
)
target_compile_definitions (stell
PUBLIC
$<$<PLATFORM_ID:Darwin>:DARWIN>
$<$<PLATFORM_ID:Linux>:LINUX>
$<$<PLATFORM_ID:Windows>:WIN32>
$<$<BOOL:${USE_FAST_COPY}>:FAST_COPY>
$<$<BOOL:${USE_PROFILER}>:PROFILE_ON>
$<$<BOOL:${NetCDF_FOUND}>:NETCDF>
$<$<BOOL:${MPI_Fortran_FOUND}>:MPI_OPT>
)
# FIXME: Remove Conditional on 3.18 check once minimum cmake version is above
# 3.18. The findBLAS and findLAPACK libraries changed the target name after
# this version to include the :: variants.
target_link_libraries (stell
PUBLIC
$<$<BOOL:${NetCDF_FOUND}>:NetCDF::NetCDF>
$<$<BOOL:${SCALAPACK_FOUND}>:SCALAPACK::SCALAPACK>
$<$<BOOL:${MPI_Fortran_FOUND}>:MPI::MPI_Fortran>
$<$<AND:$<BOOL:${BLAS_FOUND}>,$<VERSION_GREATER_EQUAL:${CMAKE_VERSION},3.18>>:BLAS::BLAS>
$<$<AND:$<BOOL:${LAPACK_FOUND}>,$<VERSION_GREATER_EQUAL:${CMAKE_VERSION},3.18>>:LAPACK::LAPACK>
$<$<AND:$<BOOL:${BLAS_FOUND}>,$<VERSION_LESS:${CMAKE_VERSION},3.18>>:${BLAS_LIBRARIES}>
$<$<AND:$<BOOL:${LAPACK_FOUND}>,$<VERSION_LESS:${CMAKE_VERSION},3.18>>:${LAPACK_LIBRARIES}>
sanitizer
traps
checks
)
target_include_directories (stell
PUBLIC
$<TARGET_PROPERTY:stell,BINARY_DIR>
)
if (MPI_Fortran_FOUND)
set_target_properties (stell PROPERTIES
MPIEXEC_EXECUTABLE "${MPIEXEC_EXECUTABLE}"
MPIEXEC_NUMPROC_FLAG "${MPIEXEC_NUMPROC_FLAG}"
MPIEXEC_MAX_NUMPROCS "${MPIEXEC_MAX_NUMPROCS}"
)
endif ()
################################################################################
# Testing #
################################################################################
# Build test utilities.
add_executable (xstell_unit_test_runner)
target_link_libraries (xstell_unit_test_runner PUBLIC stell)
# Build file_opts testers
add_executable (xstell_file_opts_runner)
target_link_libraries (xstell_file_opts_runner PUBLIC stell)
add_subdirectory (Testing)