forked from NCAR/aerosol-workshop-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
104 lines (87 loc) · 3.06 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
cmake_minimum_required(VERSION 3.12)
project(aerosol-radiation)
enable_language(Fortran)
enable_language(CXX)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
################################################################################
# options
option(AERO_TESTS_ONLY "Build only tests (ignores code in src/)" OFF)
option(AERO_ENABLE_NETCDF "Enable NetCDF support" ON)
################################################################################
# NetCDF library
if(AERO_ENABLE_NETCDF)
find_path(NETCDF_INCLUDE_DIR netcdf.mod NETCDF.mod
DOC "NetCDF include directory (must contain netcdf.mod)"
PATHS
$ENV{NETCDF_HOME}/include
/usr/lib/gfortran/modules
/usr/lib64/gfortran/modules
/opt/local/include)
find_library(NETCDF_C_LIB netcdf
DOC "NetCDF C library"
PATHS
$ENV{NETCDF_HOME}/lib
$ENV{NETCDF_HOME}/lib64
/usr/lib
/usr/lib64
/opt/local/lib)
find_library(NETCDF_FORTRAN_LIB netcdff
DOC "NetCDF Fortran library"
PATHS
$ENV{NETCDF_HOME}/lib
$ENV{NETCDF_HOME}/lib64
/opt/local/lib)
set(NETCDF_LIBS ${NETCDF_C_LIB})
if(NETCDF_FORTRAN_LIB)
set(NETCDF_LIBS ${NETCDF_LIBS} ${NETCDF_FORTRAN_LIB})
endif()
include_directories(${NETCDF_INCLUDE_DIR})
add_definitions(-DAERO_USE_NETCDF)
endif()
################################################################################
# floating point precision
if (NOT AERO_PRECISION)
# double precision by default
set(AERO_PRECISION "double")
else()
if (NOT AERO_PRECISION STREQUAL "single" AND
NOT AERO_PRECISION STREQUAL "double")
message(FATAL_ERROR "Invalid AERO_PRECISION: ${AERO_PRECISION} (must be single or double)")
endif()
endif()
if (AERO_PRECISION STREQUAL "single")
set(AERO_REAL_TYPE "float")
set(AERO_REAL_KIND "kind(1.0)")
set(AERO_C_EPSILON "FLT_EPSILON")
else() # double precision
set(AERO_REAL_TYPE "double")
set(AERO_REAL_KIND "kind(1.d0)")
set(AERO_C_EPSILON "DBL_EPSILON")
endif()
message(STATUS "Using ${AERO_PRECISION} precision")
################################################################################
# Copy input data
add_custom_target(copy_input_data ALL ${CMAKE_COMMAND} -E copy_directory
${CMAKE_CURRENT_SOURCE_DIR}/data ${CMAKE_BINARY_DIR}/data)
################################################################################
# aerosol model source
# Project-wide include directories
include_directories(${PROJECT_SOURCE_DIR}/include)
include_directories(${PROJECT_BINARY_DIR}/include)
include_directories(${PROJECT_BINARY_DIR}/src)
if (NOT AERO_TESTS_ONLY)
add_subdirectory(my_model)
else ()
add_subdirectory(my_model/template)
endif ()
################################################################################
# aerosol interface library
add_subdirectory(include)
add_subdirectory(src)
################################################################################
# mock model driver and tests
enable_testing()
add_subdirectory(driver)
add_subdirectory(tests)