forked from AMReX-Codes/amrex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
136 lines (112 loc) · 3.19 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
cmake_minimum_required(VERSION 3.14)
#
# 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( AMReX_Utils )
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 )
#
# Enable Fortran if requested
#
if(AMReX_FORTRAN)
enable_language(Fortran)
endif ()
#
# Enable CUDA if requested
#
if (AMReX_CUDA)
# CMake 3.18+: CMAKE_CUDA_ARCHITECTURES
# https://cmake.org/cmake/help/latest/policy/CMP0104.html
if(POLICY CMP0104)
cmake_policy(SET CMP0104 OLD)
endif()
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(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)
endif ()
#
# Enable CTests
#
option(AMReX_ENABLE_TESTS "Enable CTest suite for AMReX" NO)
if (AMReX_ENABLE_TESTS)
enable_testing()
add_subdirectory(Tests)
endif ()