forked from AMReX-Codes/amrex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
170 lines (144 loc) · 4.07 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
cmake_minimum_required(VERSION 3.17)
#
# Allow for MSVC Runtime library controls
#
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()
#
# We use simple syntax in cmake_dependent_option, so we are compatible with the
# extended syntax in CMake 3.22+
# https://cmake.org/cmake/help/v3.22/policy/CMP0127.html
#
if(POLICY CMP0127)
cmake_policy(SET CMP0127 NEW)
endif()
#
# Prevent in-source builds
#
if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR
"\nin-source builds are not allowed: "
"build directory cannot be in the source directory path!\n"
"You MUST remove the file ${CMAKE_BINARY_DIR}/CMakeCache.txt and "
" the directory ${CMAKE_BINARY_DIR}/CMakeFiles/ to be able to build again.")
endif ()
#
# Set search path for AMReX-specific CMake modules
#
set( AMREX_CMAKE_MODULES_PATH "${CMAKE_CURRENT_LIST_DIR}/Tools/CMake" CACHE INTERNAL "" )
set( CMAKE_MODULE_PATH ${AMREX_CMAKE_MODULES_PATH} )
#
# Retrieve amrex version
#
include( AMReXUtils )
get_amrex_version()
########################################################################
#
# 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}")
#
# 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( AMReXOptions )
if (AMReX_GPU_BACKEND STREQUAL "CUDA")
include(AMReXCUDAOptions)
endif ()
#
# Enable Fortran if requested
#
if(AMReX_FORTRAN)
enable_language(Fortran)
endif ()
#
# Enable CUDA if requested
#
if (AMReX_CUDA)
if(CMAKE_VERSION VERSION_LESS 3.20)
# CMake 3.18+: CMAKE_CUDA_ARCHITECTURES
# https://cmake.org/cmake/help/latest/policy/CMP0104.html
if(POLICY CMP0104)
cmake_policy(SET CMP0104 OLD)
endif()
endif()
enable_language(CUDA)
if(CMAKE_VERSION VERSION_LESS 3.20)
include(AMReX_SetupCUDA)
endif()
endif ()
#
# Check compiler version
#
set_mininum_compiler_version(CXX GNU 5.1)
set_mininum_compiler_version(CXX 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)
get_property(_amrex_targets
DIRECTORY Src
PROPERTY BUILDSYSTEM_TARGETS)
#
# Plotfile tools
#
option(AMReX_PLOTFILE_TOOLS "Enable Plotfile tools" NO)
if (AMReX_PLOTFILE_TOOLS)
# If this get executed, it cannot be EXCLUDED_FROM_ALL
# because it needs to get installed
add_subdirectory(Tools/Plotfile)
get_property(_plotfile_targets
DIRECTORY Tools/Plotfile
PROPERTY BUILDSYSTEM_TARGETS)
list(APPEND _amrex_targets ${_plotfile_targets})
endif ()
#
# Install amrex -- Export
#
if(AMReX_INSTALL)
include(AMReXInstallHelpers)
install_amrex_targets(${_amrex_targets})
# Add a test_install target to smoke-test
# the installation
add_test_install_target(
${CMAKE_CURRENT_LIST_DIR}/Tests/CMakeTestInstall
${CMAKE_INSTALL_PREFIX})
endif()
#
# Enable CTests
#
option(AMReX_ENABLE_TESTS "Enable CTest suite for AMReX" NO)
if (AMReX_ENABLE_TESTS)
enable_testing()
add_subdirectory(Tests)
endif ()