-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
83 lines (72 loc) · 2.95 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
## CMakeLists.txt
#
## Description
#
## LICENSE
#
# SPDX-License-Identifier: BSD-3-Clause
#
## Basic configuration
cmake_minimum_required(VERSION 3.16)
project(NuCFD)
enable_language(Fortran)
include(GNUInstallDirs)
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_SOURCE_DIR}/${CMAKE_INSTALL_INCLUDEDIR})
## Set compiler flags using interface libraries
set(gcc_like_fc "$<COMPILE_LANG_AND_ID:Fortran,GNU>")
set(icc_like_fc "$<COMPILE_LANG_AND_ID:Fortran,Intel>")
set(cray_like_fc "$<COMPILE_LANG_AND_ID:Fortran,Cray>")
add_library(nucfd_compiler_flags INTERFACE)
target_compile_options(nucfd_compiler_flags INTERFACE
"$<${gcc_like_fc}:-std=f2008;-Wall;-Wextra;-Wpedantic;-Warray-bounds;-Wimplicit-interface;-Wimplicit-procedure;-fimplicit-none>"
"$<${icc_like_fc}:-std08;-warn;all>"
"$<${cray_like_fc}:-en;-emf;-eI>")
add_library(nucfd_debug_flags INTERFACE)
target_compile_options(nucfd_debug_flags INTERFACE
"$<${gcc_like_fc}:-g;-Og;-ffpe-trap=invalid,zero;-fcheck=bounds;-fbacktrace>"
"$<${icc_like_fc}:-g;-O0;-check;all;-fpe0;-traceback;-init:snan,arrays>"
"$<${cray_like_fc}:-G2;-O0;-R;bc;-ei>")
add_library(nucfd_strict_flags INTERFACE)
target_compile_options(nucfd_strict_flags INTERFACE
"$<${gcc_like_fc}:-Werror;-Wno-error=integer-division>"
"$<${cray_like_fc}:-eN>")
## Build nucfd library
add_library(nucfd
src/nucfd_trid_solver_mod.f90
src/nucfd_coeffs_mod.f90)
target_link_libraries(nucfd nucfd_compiler_flags)
## Testing
enable_testing()
add_library(nucfd_test_flags INTERFACE)
target_link_libraries(nucfd_test_flags INTERFACE
nucfd_compiler_flags
nucfd_debug_flags
nucfd_strict_flags)
add_library(nucfd_test_framework tests/nucfd_tests_mod.f90)
target_link_libraries(nucfd_test_framework nucfd_test_flags)
function(define_test suite test_name)
add_executable(${test_name} tests/${suite}/${test_name}.f90)
target_link_libraries(${test_name} nucfd)
target_link_libraries(${test_name} nucfd_test_framework)
target_link_libraries(${test_name} nucfd_test_flags)
add_test(NAME ${suite}:${test_name} COMMAND ${test_name})
endfunction()
function(add_test_libs suite test_name lib)
target_link_libraries(${test_name} ${lib})
endfunction()
# Tidiagonal solver test suite
add_library(trid_test_utils tests/tridsolver/tridsol_test_utils_mod.f90)
target_link_libraries(trid_test_utils nucfd_test_flags)
define_test(tridsolver system_11_symm nucfd_test_framework)
define_test(tridsolver system_11_anti-symm)
add_test_libs(tridsolver system_11_symm trid_test_utils)
add_test_libs(tridsolver system_11_anti-symm trid_test_utils)
define_test(tridsolver system_00_symm nucfd_test_framework)
define_test(tridsolver system_00_anti-symm)
add_test_libs(tridsolver system_00_symm trid_test_utils)
add_test_libs(tridsolver system_00_anti-symm trid_test_utils)
## Documentation
add_custom_target(doc ford
${CMAKE_SOURCE_DIR}/NuCFD.md)