forked from AMReX-Codes/amrex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
171 lines (144 loc) · 4.52 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
cmake_minimum_required(VERSION 3.14)
########################################################################
#
# Set variables for AMReX versioning
#
########################################################################
find_package (Git QUIET)
set( _tmp "" )
# Try to inquire software version from git
if ( EXISTS ${CMAKE_CURRENT_LIST_DIR}/.git AND ${GIT_FOUND} )
execute_process ( COMMAND git describe --abbrev=12 --dirty --always --tags
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE _tmp )
string( STRIP ${_tmp} _tmp )
# filter invalid descriptions in shallow git clones
if (NOT _tmp MATCHES "^([0-9]+)\\.([0-9]+)(\\.([0-9]+))*(-.*)*$")
set( _tmp "")
endif ()
endif()
# Grep first line from file CHANGES if cannot find version from Git
if (NOT _tmp)
file(STRINGS ${CMAKE_CURRENT_LIST_DIR}/CHANGES ALL_VERSIONS REGEX "#")
list(GET ALL_VERSIONS 0 _tmp)
string(REPLACE "#" "" _tmp "${_tmp}")
string(STRIP "${_tmp}" _tmp )
set(_tmp "${_tmp}.0")
endif ()
set( AMREX_GIT_VERSION "${_tmp}" CACHE INTERNAL "" )
unset(_tmp)
# Package version is a modified form of AMREX_GIT_VERSION
if (AMREX_GIT_VERSION)
string(FIND "${AMREX_GIT_VERSION}" "-" _idx REVERSE)
string(SUBSTRING "${AMREX_GIT_VERSION}" 0 "${_idx}" _pkg_version )
string(FIND "${_pkg_version}" "-" _idx REVERSE)
string(SUBSTRING "${_pkg_version}" 0 "${_idx}" _pkg_version )
string(REPLACE "-" "." _pkg_version "${_pkg_version}")
endif ()
set( AMREX_PKG_VERSION "${_pkg_version}" CACHE INTERNAL "" )
unset(_pkg_version)
#
# For the time being, set this option here.
# We must do this because we need to provide a default for CMAKE_CXX_COMPILER
#
option( ENABLE_DPCPP "Enable DPCPP support" OFF )
if (ENABLE_DPCPP)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
# Set default for CMAKE_CXX_COMPILER only if amrex
# is not a subproject
set(CMAKE_CXX_COMPILER dpcpp)
endif ()
message(STATUS "Enabling experimental support for dpc++")
endif ()
########################################################################
#
# AMReX project
#
########################################################################
project( AMReX
DESCRIPTION "A software framework for massively parallel, block-structured adaptive mesh refinement (AMR) applications"
VERSION ${AMREX_PKG_VERSION}
HOMEPAGE_URL "https://amrex-codes.github.io/amrex/"
LANGUAGES C CXX
)
message(STATUS "CMake version: ${CMAKE_VERSION}")
#
# Load required modules
#
set( AMREX_CMAKE_MODULES_PATH "${CMAKE_CURRENT_LIST_DIR}/Tools/CMake" CACHE INTERNAL "" )
set( CMAKE_MODULE_PATH ${AMREX_CMAKE_MODULES_PATH} )
#
# Provide a default install directory
#
if ( CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR AND CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
set ( CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/installdir"
CACHE PATH "AMReX installation directory" FORCE)
endif ()
message(STATUS "AMReX installation directory: ${CMAKE_INSTALL_PREFIX}")
#
# Check if CMAKE_BUILD_TYPE is given. If not, use default
#
if ( NOT CMAKE_BUILD_TYPE )
set(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo")
set(CMAKE_BUILD_TYPE Release
CACHE STRING
"Choose the build type, e.g. Release, Debug, or RelWithDebInfo." FORCE)
else ()
message(STATUS "Build type set by user to '${CMAKE_BUILD_TYPE}'.")
endif()
#
# Include options, utilities and other stuff we need
#
include( AMReX_Utils )
include( AMReX_Options )
#
# Enable Fortran if requested
#
if(ENABLE_FORTRAN)
enable_language(Fortran)
endif ()
#
# Enable CUDA if requested
#
if (ENABLE_CUDA)
enable_language(CUDA)
include(AMReX_SetupCUDA)
endif ()
#
# Check compiler version
#
set_mininum_cxx_compiler_version(GNU 4.8)
set_mininum_cxx_compiler_version(MSVC 19.23)
#
# Set CMAKE_<LANG>_FLAGS_<CONFIG> if not already defined
#
set_default_config_flags ()
#
# Source files for all binaries and libraries found under src
#
add_subdirectory(Src)
#
# Tutorials and "test_install" target
#
option(AMReX_BUILD_TUTORIALS "Build tutorials" NO)
if (AMReX_BUILD_TUTORIALS)
message(STATUS "Enabling Tutorials")
add_subdirectory(Tutorials)
endif ()
#
# Plotfile tools
#
option(ENABLE_PLOTFILE_TOOLS "Enable Plotfile tools" NO)
if (ENABLE_PLOTFILE_TOOLS)
# If this get executed, it cannot be EXCLUDED_FROM_ALL
# because it needs to get installed
add_subdirectory(Tools/Plotfile)
endif ()
#
# Enable CTests
#
option(AMReX_ENABLE_TESTS "Enable CTest suite for AMReX" NO)
if (AMReX_ENABLE_TESTS)
enable_testing()
add_subdirectory(Tests)
endif ()