forked from GEOS-ESM/ESMA_cmake
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathesma.cmake
125 lines (94 loc) · 4.29 KB
/
esma.cmake
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Most users of this software do not (should not?) have permissions to
# install in the cmake default of /usr/local (or equiv on other os's).
# Below, the default is changed to a directory within the build tree
# unless the user explicitly sets CMAKE_INSTALL_PREFIX in the cache.
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "default install path" FORCE )
message(STATUS "*** Setting default install prefix to ${CMAKE_INSTALL_PREFIX}.")
message(STATUS "*** Override with -DCMAKE_INSTALL_PREFIX=<path>.")
endif()
# There is an issue with CMake, make, and directories with commas
# in the path. CMake can add -Wl linker options to the makefiles and
# Wl options take comma-separated lists. Until it can be figured out
# how (or if) CMake can generate quoted arguments to -Wl, we prevent
# either build or install directories with a comma in the path
if ("${CMAKE_BINARY_DIR}" MATCHES "^.*[,].*$")
message(FATAL_ERROR
"CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}\n"
"GEOS does not allow directory paths with commas. Please change your build path"
)
endif ()
if ("${CMAKE_INSTALL_PREFIX}" MATCHES "^.*[,].*$")
message(FATAL_ERROR
"CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}\n"
"GEOS does not allow directory paths with commas. Please change your install path"
)
endif ()
### ecbuild Support ###
# Bring in ecbuild
if (IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/ecbuild")
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/ecbuild/cmake")
elseif (IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/@ecbuild")
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/@ecbuild/cmake")
elseif (IS_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/ecbuild@")
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/ecbuild@/cmake")
else ()
find_package(ecbuild REQUIRED)
endif()
option(BUILD_SHARED_LIBS "Build the shared library" OFF)
set (ECBUILD_2_COMPAT_VALUE OFF)
include (ecbuild_system NO_POLICY_SCOPE)
### Compiler Support ###
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/compiler")
include (esma_compiler)
### OpenMP ###
find_package (OpenMP)
### Position independent code ###
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
### MPI Support ###
# Only invoked from Fortran sources in GEOS-5, But some BASEDIR packages use MPI from C/C++.
set(MPI_DETERMINE_LIBRARY_VERSION TRUE)
find_package (MPI REQUIRED)
### Threading ###
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
## Turns out with NAG on Linux, this generates '-pthread' which
## NAG cannot handle. So we set to FALSE in that case
if(UNIX AND CMAKE_Fortran_COMPILER_ID MATCHES "NAG")
set(THREADS_PREFER_PTHREAD_FLAG FALSE)
else()
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
endif()
find_package(Threads REQUIRED)
### External Libraries Support ###
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/external_libraries")
include(math_libraries)
include(FindBaselibs)
find_package(GitInfo)
### ESMA Support ###
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/esma_support")
include (esma_support)
### Python ###
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/python")
include(esma_python)
### LaTeX ###
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/latex")
include(esma_latex)
### macOS ###
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/operating_system")
if (APPLE)
include(osx_extras)
endif ()
option (ESMA_ALLOW_DEPRECATED "suppress warnings about deprecated features" ON)
# Temporary option for transition purposes.
option (ESMA_USE_GFE_NAMESPACE "use cmake namespace with GFE projects" ON)
set (XFLAGS "" CACHE STRING "List of extra FPP options that will be passed to select source files.")
set (XFLAGS_SOURCES "" CACHE STRING "List of sources to which XFLAGS will be applied.")
# On install, print 'Installing' but not 'Up-to-date' messages.
set (CMAKE_INSTALL_MESSAGE LAZY)
# This is a "stub" macro to detect building within an ESMA project (for MAPL standalone)
macro (esma)
endmacro ()
# ecbuild by default puts modules in build-dir/module. This can cause issues if same-named modules
# are in two directories that aren't using esma_add_library(). This sets the the value to
# nothing with puts modules in the build directory equivalent of the source directory
set(CMAKE_Fortran_MODULE_DIRECTORY "" CACHE PATH "Fortran module directory default" FORCE)