-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
110 lines (98 loc) · 2.83 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
105
106
107
108
109
110
cmake_minimum_required(VERSION 3.16)
project(cost733class
HOMEPAGE_URL https://github.com/lochbika/cost733class
VERSION 1.4.0
)
enable_language (Fortran)
include(CheckFortranCompilerFlag)
# make sure that the default is a RELEASE
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE RELEASE CACHE STRING
"Choose the type of build, options are: None Debug Release."
FORCE)
endif ()
# FFLAGS depend on the compiler
get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
if (Fortran_COMPILER_NAME MATCHES "gfortran.*")
# gfortran
set (CMAKE_Fortran_FLAGS_RELEASE "-funroll-loops -fforce-addr -O3")
set (CMAKE_Fortran_FLAGS_DEBUG "-fbounds-check -fbacktrace -Wall -Wextra -ggdb -fcheck=all")
message ("CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
check_fortran_compiler_flag("-fallow-invalid-boz" FCNEW)
if (FCNEW)
message (STATUS "gfortran version > 10 detected")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-invalid-boz")
endif ()
check_fortran_compiler_flag("-fallow-argument-mismatch" FCNEW)
if (FCNEW)
message (STATUS "gfortran version > 10 detected")
set (CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fallow-argument-mismatch")
endif ()
else ()
message (FATAL_ERROR "Compiler gfortran not found! Stop!")
endif ()
# options for external library support
option(NCDF "Enable NetCDF file support" ON)
option(OPENGL "Enable OpenGL support" OFF)
option(GRIB "Enable grib file support" OFF)
# check and set NetCDF requirements if enabled
if (NCDF)
FIND_PATH(NCDF_INCLUDE
NAMES
netcdf.mod
PATHS
$ENV{NCDF_INCLUDE_PATH}
/usr/include
$ENV{HOME}/include
DOC "NetCDF include directory (must contain netcdf.mod)"
)
FIND_LIBRARY(NCDF_LIB
NAMES
libnetcdff.so
PATHS
$ENV{NCDF_LIB_PATH}
/usr/lib
/usr/lib64
$ENV{HOME}/lib
$ENV{HOME}/lib64
DOC "NetCDF fortran library"
)
endif ()
# check for OpenGL support (f03gl)
if (OPENGL)
add_subdirectory(f03gl)
else ()
endif ()
# check for Grib api (ecCodes)
if (GRIB)
FIND_PATH(GRIB_INCLUDE
NAMES
eccodes.mod
PATHS
$ENV{GRIB_INCLUDE_PATH}
/usr/include
/usr/lib/x86_64-linux-gnu/fortran/gfortran-mod-15
$ENV{HOME}/include
DOC "ecCodes include directory (must contain eccodes.mod)"
)
FIND_LIBRARY(GRIB_LIB
NAMES
libeccodes_f90.so
PATHS
$ENV{GRIB_LIB_PATH}
/usr/lib
/usr/lib64
$ENV{HOME}/lib
$ENV{HOME}/lib64
DOC "ecCodes fortran library"
)
endif ()
add_subdirectory(src)
install(TARGETS cost733class
)
SET(CPACK_GENERATOR "DEB")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Kai Lochbihler <kai.lochbihler@gmx.de>")
SET(CPACK_PACKAGE_NAME "cost733class")
# dependencies for Ubuntu 20.04
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libnetcdf15, libnetcdff7, libeccodes0")
INCLUDE(CPack)