forked from sandialabs/omega_h
-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
180 lines (156 loc) · 5.63 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
172
173
174
175
176
177
178
179
180
cmake_minimum_required(VERSION 3.18.0...${CMAKE_VERSION})
project(Omega_h VERSION 9.33.0 LANGUAGES CXX)
set(Omega_h_USE_DOLFIN_DEFAULT OFF)
option(Omega_h_USE_DOLFIN "Whether to build the DOLFIN interface" ${Omega_h_USE_DOLFIN_DEFAULT})
if (Omega_h_USE_DOLFIN)
# The FindPETSc module will use try_compile with a C code file
enable_language(C)
endif()
include(cmake/bob.cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
set(CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
bob_begin_package()
bob_option(Omega_h_CHECK_BOUNDS "Check array bounds (makes code slow too)" OFF)
bob_option(Omega_h_THROW "Errors throw exceptions instead of abort" ${USE_XSDK_DEFAULTS})
bob_input(Omega_h_DATA "" PATH "Path to omega_h-data test files")
bob_option(Omega_h_USE_EGADS "Use EGADS from ESP for geometry" OFF)
bob_input(EGADS_PREFIX "" PATH "EGADS (or ESP) installation directory")
bob_option(Omega_h_USE_Kokkos "Use Kokkos as a backend" OFF)
bob_input(Kokkos_PREFIX "" PATH "Path to Kokkos install")
bob_option(Omega_h_USE_CUDA_AWARE_MPI "Assume MPI is CUDA-aware, make use of that" OFF)
bob_option(Omega_h_USE_SimModSuite "Enable reading Simmetrix MeshSim meshes" OFF)
bob_input(Omega_h_VALGRIND "" STRING "Valgrind plus arguments for testing")
bob_option(Omega_h_EXAMPLES "Compile examples" OFF)
set(Omega_h_USE_ZLIB_DEFAULT ON)
bob_add_dependency(PUBLIC NAME ZLIB TARGETS ZLIB::ZLIB)
set(Omega_h_USE_Kokkos_DEFAULT OFF)
set(KokkosCore_PREFIX_DEFAULT ${Kokkos_PREFIX})
bob_add_dependency(PUBLIC NAME Kokkos TARGETS Kokkos::kokkos)
if (Omega_h_USE_Kokkos)
set_target_properties(Kokkos::kokkos PROPERTIES INTERFACE_COMPILE_OPTIONS "")
endif()
set(libMeshb_REQUIRED_VERSION 7.24)
set(Omega_h_USE_libMeshb_DEFAULT OFF)
bob_add_dependency(PUBLIC NAME libMeshb TARGETS libMeshb::Meshb.7)
set(Omega_h_USE_Gmsh_DEFAULT OFF)
bob_add_dependency(PUBLIC NAME Gmsh
INCLUDE_DIR_VARS Gmsh_INCLUDE_DIRS
LIBRARY_VARS Gmsh_LIBRARIES)
if(Omega_h_USE_Gmsh)
if(Gmsh_VERSION_STRING VERSION_LESS 4.4.1)
message(SEND_ERROR "Gmsh minimum version is 4.4.1 but found version ${Gmsh_VERSION_STRING}")
endif()
endif()
set(Gmodel_REQUIRED_VERSION 2.1.0)
set(Omega_h_USE_Gmodel_DEFAULT OFF)
bob_add_dependency(PRIVATE NAME Gmodel TARGETS gmodel)
set(Omega_h_USE_SEACASExodus_DEFAULT OFF)
set(SEACASExodus_PREFIX_DEFAULT ${Trilinos_PREFIX})
bob_add_dependency(PUBLIC NAME SEACASExodus
TARGETS exodus
INCLUDE_DIR_VARS
SEACASExodus_INCLUDE_DIRS
SEACASExodus_TPL_INCLUDE_DIRS
LIBRARY_VARS SEACASExodus_TPL_LIBRARIES)
if (Omega_h_USE_SEACASExodus)
# On Windows, we must find hdf5 targets since
# it is linked PUBLIC
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(Omega_h_USE_HDF5_DEFAULT ON)
bob_add_dependency(PUBLIC NAME HDF5)
endif()
endif()
set(Omega_h_USE_pybind11_DEFAULT OFF)
bob_public_dep(pybind11)
if(Omega_h_USE_Kokkos)
if ("CUDA" IN_LIST Kokkos_DEVICES)
bob_option(Omega_h_USE_CUDA "Whether to use CUDA" "ON")
endif()
if ("OPENMP" IN_LIST Kokkos_DEVICES)
bob_option(Omega_h_USE_OpenMP "Whether to use OpenMP" "ON")
endif()
if (Omega_h_USE_CUDA AND (NOT "CUDA_LAMBDA" IN_LIST Kokkos_OPTIONS))
message(FATAL_ERROR
"Please reconfigure Kokkos with -DKokkos_ENABLE_Cuda_Lambda:BOOL=ON")
endif()
endif()
bob_option(Omega_h_USE_MPI "Use MPI for parallelism" OFF)
if(Omega_h_USE_MPI)
set(MPI_CXX_SKIP_MPICXX ON) #don't need MPI C++ bindings
bob_add_dependency(PUBLIC NAME MPI
INCLUDE_DIR_VARS MPI_CXX_INCLUDE_DIRS
LIBRARY_VARS MPI_CXX_LIBRARIES)
get_target_property(mpiLibs ${PROJECT_NAME}-MPI INTERFACE_LINK_LIBRARIES)
if(NOT mpiLibs)
message(WARNING "MPI Libraries not found, there may be linking errors! "
"Try enabling shared libraries \'-DBUILD_SHARED_LIBS=ON\'.")
else()
message(STATUS "Found MPI libraries: ${mpiLibs}")
endif()
endif()
bob_option(Omega_h_USE_OpenMP "Whether to use OpenMP" "${Kokkos_HAS_OpenMP}")
bob_option(Omega_h_USE_CUDA "Whether to use CUDA" "${Kokkos_HAS_CUDA}")
if (Omega_h_USE_CUDA)
enable_language(CUDA)
#check for versions of cuda/thrust that dont't work with omegah
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.2
AND CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 11.3)
message(FATAL_ERROR "CUDA 11.2 does not support Omega_h, "
"use an older or newer version")
endif()
endif()
include(cmake/osh_use_dolfin.cmake)
osh_use_dolfin()
set(Omega_h_KEY_BOOLS
Omega_h_USE_MPI
Omega_h_USE_Kokkos
Omega_h_USE_OpenMP
Omega_h_USE_CUDA
Omega_h_USE_ZLIB
Omega_h_USE_libMeshb
Omega_h_USE_EGADS
Omega_h_USE_SEACASExodus
Omega_h_USE_SimModSuite
Omega_h_USE_DOLFIN
Omega_h_USE_dwarf
Omega_h_CHECK_BOUNDS
Omega_h_THROW
Omega_h_USE_CUDA_AWARE_MPI
Omega_h_USE_Gmsh
)
set(Omega_h_KEY_INTS
Omega_h_VERSION_MAJOR
Omega_h_VERSION_MINOR
Omega_h_VERSION_PATCH
)
set(Omega_h_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(Omega_h_KEY_STRINGS
Omega_h_SEMVER
Omega_h_COMMIT
Omega_h_CXX_FLAGS
Omega_h_CMAKE_ARGS
)
bob_get_commit()
bob_get_semver()
if(Omega_h_EXAMPLES)
find_program(GMSH_EXECUTABLE gmsh REQUIRED)
add_subdirectory(example/field_on_square)
add_subdirectory(example/castle)
add_subdirectory(example/gradient)
add_subdirectory(example/laplacian)
if(Omega_h_USE_DOLFIN)
set(SAVED_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE " -Werror" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
add_subdirectory(example/fenics/cpp)
set(CMAKE_CXX_FLAGS "${SAVED_CXX_FLAGS}")
endif()
endif()
add_subdirectory(src)
if (Omega_h_USE_CUDA)
install(PROGRAMS
${CMAKE_CURRENT_SOURCE_DIR}/bin/nvcc_wrapper
DESTINATION bin)
endif()
bob_end_package()