forked from StanfordLegion/legion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
268 lines (231 loc) · 10.2 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
#------------------------------------------------------------------------------#
# Copyright 2017 Kitware, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#------------------------------------------------------------------------------#
cmake_minimum_required(VERSION 3.1)
project(Legion)
#------------------------------------------------------------------------------#
# Some boilerplate to setup nice output directories
#------------------------------------------------------------------------------#
#for multilib distros
include(GNUInstallDirs)
list(INSERT CMAKE_MODULE_PATH 0 "${Legion_SOURCE_DIR}/cmake")
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${Legion_BINARY_DIR}/lib)
endif()
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${Legion_BINARY_DIR}/lib)
endif()
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Legion_BINARY_DIR}/bin)
endif()
#library api version, bump from time to time
set(SOVERSION 1)
#------------------------------------------------------------------------------#
# More boilerplate to deal with build type and lib type
#------------------------------------------------------------------------------#
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build" FORCE)
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Whether or not to build shared libraries instead of static")
add_definitions(-DLEGION_CMAKE)
#https://github.com/StanfordLegion/legion/issues/168#issuecomment-244582958
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-fno-strict-aliasing" COMPILER_SUPPORTS_NO_STRICT_ALIASING)
if(COMPILER_SUPPORTS_NO_STRICT_ALIASING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
endif()
if (${CMAKE_BUILD_TYPE} EQUAL "Debug")
set(DEBUG_REALM ON)
set(DEBUG_LEGION ON)
endif()
#------------------------------------------------------------------------------#
# Minimum log level
#------------------------------------------------------------------------------#
set(Legion_OUTPUT_LEVEL "DEBUG" CACHE STRING "Compile time logging level")
set_property(CACHE Legion_OUTPUT_LEVEL PROPERTY STRINGS SPEW DEBUG INFO PRINT WARNING ERROR FATAL NONE)
#------------------------------------------------------------------------------#
# HWLOC configuration
#------------------------------------------------------------------------------#
option(Legion_USE_HWLOC "Use hwloc for topology awareness" OFF)
if(Legion_USE_HWLOC)
find_package(HWLOC REQUIRED)
install(FILES ${Legion_SOURCE_DIR}/cmake/FindHWLOC.cmake
DESTINATION ${CMAKE_INSTALL_DATADIR}/Legion/cmake
)
endif()
#------------------------------------------------------------------------------#
# GASNet configuration
#------------------------------------------------------------------------------#
option(Legion_USE_GASNet "Enable the distributed GASNet backend" OFF)
if(Legion_USE_GASNet)
set(GASNet_THREADING par)
set(GASNet_PREFERRED_CONDUITS aries gemini ibv)
find_package(GASNet REQUIRED)
if(NOT GASNet_THREADING STREQUAL "par")
message(FATAL_ERROR "GASNet threading mode \"${GASNet_THREADING}\" is not currently supported by Legion")
endif()
install(FILES ${Legion_SOURCE_DIR}/cmake/FindGASNet.cmake
DESTINATION ${CMAKE_INSTALL_DATADIR}/Legion/cmake
)
set (GASNETI_BUG1389_WORKAROUND "1")
string(TOUPPER ${GASNet_CONDUIT} CONDUIT)
set (GASNET_CONDUIT_${CONDUIT} ON)
endif()
#------------------------------------------------------------------------------#
# LLVM configuration
#------------------------------------------------------------------------------#
option(Legion_USE_LLVM "Use LLVM JIT oerations" OFF)
if(Legion_USE_LLVM)
set(Legion_LLVM_COMPONENTS irreader jit mcjit x86)
find_package(LLVM REQUIRED COMPONENTS ${Legion_LLVM_COMPONENTS})
install(FILES ${Legion_SOURCE_DIR}/cmake/FindLLVM.cmake
DESTINATION ${CMAKE_INSTALL_DATADIR}/Legion/cmake
)
endif()
#------------------------------------------------------------------------------#
# CUDA configuration
#------------------------------------------------------------------------------#
option(Legion_USE_CUDA "Enable support for the CUDA runtime" OFF)
if(Legion_USE_CUDA)
if(NOT BUILD_SHARED_LIBS)
set(CUDA_USE_STATIC_CUDA_RUNTIME ON)
else()
set(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
endif()
find_package(CUDA REQUIRED)
install(FILES ${Legion_SOURCE_DIR}/cmake/FindCUDA.cmake
DESTINATION ${CMAKE_INSTALL_DATADIR}/Legion/cmake
)
install(FILES ${Legion_SOURCE_DIR}/cmake/newcmake/FindCUDA.cmake
DESTINATION ${CMAKE_INSTALL_DATADIR}/Legion/cmake/newcmake
)
set (USE_CUDA ON)
endif()
#------------------------------------------------------------------------------#
# HDF5 configuration
#------------------------------------------------------------------------------#
option(Legion_USE_HDF5 "Enable support for HDF5" OFF)
if(Legion_USE_HDF5)
find_package(HDF5 REQUIRED COMPONENTS C)
endif()
#------------------------------------------------------------------------------#
# Miscelaneous other options
#------------------------------------------------------------------------------#
set(Legion_MAX_FIELDS 512 CACHE STRING "Maximum number of fields allocated to a single field space")
set_property(CACHE Legion_MAX_FIELDS PROPERTY STRINGS 32 64 128 256 512 1024)
mark_as_advanced(Legion_MAX_FIELDS)
#------------------------------------------------------------------------------#
# Runtime library targets
#------------------------------------------------------------------------------#
add_subdirectory(runtime)
#------------------------------------------------------------------------------#
# configure header
#------------------------------------------------------------------------------#
# Checking for all defines in the CXX Flags
add_definitions(-D__STDC_FORMAT_MACROS)
set (__STDC_FORMAT_MACROS ON)
string(REPLACE " " ";" FLAGS_LIST ${CMAKE_CXX_FLAGS})
FOREACH(FLAG ${FLAGS_LIST})
string (FIND ${FLAG} "-D" START_STR)
if (${START_STR} EQUAL "0")
string(REPLACE "-D" "" NEW_DEFINE ${FLAG})
set (${NEW_DEFINE} ON)
endif()
endforeach()
#------------------------------------------------------------------------------#
# Build-tree package generation
#------------------------------------------------------------------------------#
export(EXPORT LegionTargets
NAMESPACE Legion::
FILE ${Legion_BINARY_DIR}/LegionTargets.cmake
)
install(EXPORT LegionTargets
NAMESPACE Legion::
FILE LegionTargets.cmake
DESTINATION ${CMAKE_INSTALL_DATADIR}/Legion/cmake
)
configure_file(
cmake/LegionConfigCommon.cmake.in
${Legion_BINARY_DIR}/LegionConfigCommon.cmake
@ONLY
)
install(FILES ${Legion_BINARY_DIR}/LegionConfigCommon.cmake
DESTINATION ${CMAKE_INSTALL_DATADIR}/Legion/cmake
)
configure_file(
cmake/LegionConfig-build.cmake.in
${Legion_BINARY_DIR}/LegionConfig.cmake
@ONLY
)
install(FILES cmake/LegionConfig-install.cmake
DESTINATION ${CMAKE_INSTALL_DATADIR}/Legion/cmake
RENAME LegionConfig.cmake
)
#------------------------------------------------------------------------------#
# Install into the CMake pacakge registry if explicitly selected to do so
#------------------------------------------------------------------------------#
set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY ON CACHE INTERNAL "Disable the export(PACKAGE) command.")
option(Legion_USE_PACKAGE_REGISTRY "Register the build tree with the CMake package registry" OFF)
mark_as_advanced(Legion_USE_PACKAGE_REGISTRY)
if(Legion_USE_PACKAGE_REGISTRY)
set(CMAKE_EXPORT_NO_PACKAGE_REGISTRY OFF)
endif()
export(PACKAGE Legion)
#------------------------------------------------------------------------------#
# Examples and Applications
#------------------------------------------------------------------------------#
option(Legion_BUILD_APPS "Build Legion sample applications" OFF)
option(Legion_BUILD_EXAMPLES "Build Legion examples" OFF)
option(Legion_BUILD_TUTORIAL "Build Legion tutorial" OFF)
option(Legion_BUILD_TESTS "Build Legion tests" OFF)
option(Legion_ENABLE_TESTING "Build and copy testing stuff" OFF)
if(Legion_ENABLE_TESTING)
enable_testing()
endif()
if(Legion_BUILD_APPS OR Legion_BUILD_EXAMPLES OR Legion_BUILD_TUTORIAL OR Legion_BUILD_TESTS)
# Make a namespaced alias so in-build examples can use it the same way as if
# it were imported
add_library(Legion::Legion ALIAS Legion)
if(Legion_USE_CUDA)
# CUDA has some issues propogating target interface properties so we
# have to extract them from the target and manually add them to the nvcc
# flags
set(PROP $<TARGET_PROPERTY:Legion::Legion,INTERFACE_COMPILE_OPTIONS>)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} ${PROP}")
set(PROP $<TARGET_PROPERTY:Legion::Legion,INTERFACE_COMPILE_DEFINITIONS>)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} $<$<BOOL:${PROP}>:-D$<JOIN:${PROP}, -D>>")
set(PROP $<TARGET_PROPERTY:Legion::Legion,INTERFACE_INCLUDE_DIRECTORIES>)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} $<$<BOOL:${PROP}>:-I$<JOIN:${PROP}, -I>>")
endif()
if(Legion_BUILD_APPS)
add_subdirectory(apps)
endif()
if(Legion_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
if(Legion_BUILD_TUTORIAL)
add_subdirectory(tutorial)
endif()
if(Legion_BUILD_TESTS)
add_subdirectory(test)
endif()
endif()
#------------------------------------------------------------------------------#
# configure header
#------------------------------------------------------------------------------#
configure_file(${PROJECT_SOURCE_DIR}/cmake/legion_defines.h.in ${PROJECT_SOURCE_DIR}/runtime/legion_defines.h @ONLY)
include_directories(${PROJECT_SOURCE_DIR}/runtime)
install(FILES ${PROJECT_SOURCE_DIR}/runtime/legion_defines.h DESTINATION include)
#------------------------------------------------------------------------------#
# vim: set tabstop=2 shiftwidth=2 expandtab :
#------------------------------------------------------------------------------#