forked from AMReX-Codes/amrex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
100 lines (83 loc) · 2.48 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
cmake_minimum_required (VERSION 3.11)
project (AMReX)
enable_language (C)
enable_language (CXX)
enable_language (Fortran)
#
# 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_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
set ( CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/installdir"
CACHE PATH "AMReX installation directory" FORCE)
endif ()
#
# Include options, utilities and other stuff we need
#
include( AMReX_Utils )
include( AMReX_Options )
include( AMReX_Machines )
#
# Enable CUDA if requested
#
# CMake let you decide which host compiler to use
# via the env variable CUDAHOSTCXX and the CMake
# variable CMAKE_CUDA_HOST_COMPILER.
# For the time being we force the CUDA host compiler
# to be the C++ compiler.
#
if ( (CMAKE_CUDA_HOST_COMPILER) OR
NOT ("$ENV{CUDAHOSTCXX}" STREQUAL "") )
message(WARNING
"User-defined CUDA host compiler does not match C++ compiler: overwriting user setting.")
endif ()
unset(ENV{CUDAHOSTCXX})
set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER})
if (ENABLE_CUDA)
enable_language(CUDA)
print(CMAKE_CUDA_COMPILER_VERSION)
print(CMAKE_CUDA_COMPILER_ID)
print(CMAKE_CUDA_HOST_COMPILER)
# For now we require C++ to be the same as
#find is deprecated for CUDA but currently
#it still provides some features not yet implemented
# natively. Remove this part when native support is complete
#find_package(CUDA 8.0 REQUIRED QUIET)
endif ()
#
# Set CMAKE_<LANG>_FLAGS_<CONFIG> if not already defined
#
set_default_config_flags ()
#
# Set variable for AMReX versioning
#
find_package (Git QUIET)
set ( TMP "" )
if ( EXISTS ${CMAKE_SOURCE_DIR}/.git AND ${GIT_FOUND} )
execute_process ( COMMAND git describe --abbrev=12 --dirty --always --tags
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE TMP )
string ( STRIP ${TMP} TMP )
else ()
# Grep first line from file CHANGES if AMREX_GIT_VERSION is not
# provided
file(STRINGS ${PROJECT_SOURCE_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)
#
# Source files for all binaries and libraries found under src
#
add_subdirectory (Src)
#
# Tutorials and "test_install" target)
#
add_subdirectory (Tutorials)