-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
executable file
·235 lines (207 loc) · 8.35 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
# CircusTent Top-Level CMake
#
# Copyright (C) 2017-2021 Tactical Computing Laboratories, LLC
# All Rights Reserved
#
# See LICENSE in the top level directory for licensing details
#
cmake_minimum_required(VERSION 3.4.3)
project(CircusTent)
set(VERSION "0.2.0")
#------------------------------------------------------------------------
#-- EXTERNAL CMAKE SCRIPTS
#------------------------------------------------------------------------
set(CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/cmake"
${CMAKE_MODULE_PATH}
)
include(UseLATEX OPTIONAL)
#------------------------------------------------------------------------
#-- DERIVE THE RELEASE CODENAME
#------------------------------------------------------------------------
execute_process(COMMAND lsb_release -cs
OUTPUT_VARIABLE CT_RELEASE_CODENAME
OUTPUT_STRIP_TRAILING_WHITESPACE)
#------------------------------------------------------------------------
#-- COMPILER OPTIONS
#------------------------------------------------------------------------
if( CT_CFLAGS )
message(STATUS "USING MACHINE-SPECIFIC C_FLAGS: ${CT_CFLAGS}")
endif()
if( CT_CXXFLAGS )
message(STATUS "USING MACHINE-SPECIFIC CXX_FLAGS: ${CT_CXXFLAGS}")
endif()
if( CT_LINKER_FLAGS )
message(STATUS "USING MACHINE-SPECIFIC LINKER_FLAGS: ${CT_LINKER_FLAGS}")
endif()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -std=c99 ${CT_CFLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++11 ${CT_CXXFLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -Wall -g ${CT_CXXFLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -std=c++11 ${CT_CXXFLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CT_LINKER_FLAGS}")
#------------------------------------------------------------------------
#-- IMPLEMENTATION-SPECIFIC FLAGS
#------------------------------------------------------------------------
if (ENABLE_OMP)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_ENABLE_OMP_")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_ENABLE_OMP_")
message(STATUS "ENABLING OpenMP Implementation")
else()
message(STATUS "DISABLING OpenMP Implementation")
endif()
if (ENABLE_OMP_TARGET)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_ENABLE_OMP_TARGET_")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_ENABLE_OMP_TARGET_")
message(STATUS "ENABLING OpenMP Target Implementation")
else()
message(STATUS "DISABLING OpenMP Target Implementation")
endif()
if (ENABLE_OPENSHMEM)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_ENABLE_OPENSHMEM_")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_ENABLE_OPENSHMEM_")
message(STATUS "ENABLING OpenSHMEM Implementation")
else()
message(STATUS "DISABLING OpenSHMEM Implementation")
endif()
if (ENABLE_MPI)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_ENABLE_MPI_")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_ENABLE_MPI_")
message(STATUS "ENABLING MPI Implementation")
else()
message(STATUS "DISABLING MPI Implementation")
endif()
if (ENABLE_XBGAS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_ENABLE_XBGAS_")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_ENABLE_XBGAS_")
message(STATUS "ENABLING XBGAS Implementation")
else()
message(STATUS "DISABLING XBGAS Implementation")
endif()
if (ENABLE_PTHREADS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_ENABLE_PTHREADS_")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_ENABLE_PTHREADS_")
message(STATUS "ENABLING Pthreads Implementation")
else()
message(STATUS "DISABLING Pthreads Implementation")
endif()
if (ENABLE_OPENACC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_ENABLE_OPENACC_")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_ENABLE_OPENACC_")
message(STATUS "ENABLING OpenACC Implementation")
else()
message(STATUS "DISABLING OpenACC Implementation")
endif()
if (ENABLE_OPENCL)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_ENABLE_OPENCL_")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_ENABLE_OPENCL_")
message(STATUS "ENABLING OpenCL Implementation")
else()
message(STATUS "DISABLING OpenCL Implementation")
endif()
if (ENABLE_CPP_STD)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_ENABLE_CPP_STD_")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_ENABLE_CPP_STD_")
message(STATUS "ENABLING C++ Standard Atomics Implementation")
else()
message(STATUS "DISABLING C++ Standard Atomics Implementation")
endif()
if (ENABLE_CUDA)
cmake_minimum_required(VERSION 3.17)
enable_language(CUDA)
find_package(CUDAToolkit REQUIRED)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_ENABLE_CUDA_")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_ENABLE_CUDA_")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -D_ENABLE_CUDA_")
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -D_ENABLE_CUDA_")
message(STATUS "ENABLING CUDA Implementation")
else()
message(STATUS "DISABLING CUDA Implementation")
endif()
#------------------------------------------------------------------------
# Add package paths
#------------------------------------------------------------------------
if(NOT CT_INCLUDE_PATH)
set(CT_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include")
message(STATUS "CT_INCLUDE_PATH set to ${CT_INCLUDE_PATH}")
endif()
if(NOT CT_SRC_PATH)
set(CT_SRC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/CircusTent")
message(STATUS "CT_SRC_PATH set to ${CT_SRC_PATH}")
endif()
#------------------------------------------------------------------------
#-- TESTING
#------------------------------------------------------------------------
# Enable testing
enable_testing()
#------------------------------------------------------------------------
#-- PACKAGING
#------------------------------------------------------------------------
#-- builds a standard redhat/centos rpm
if(CIRCUSTENT_BUILD_RPM)
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_GENERATOR "RPM")
set(CPACK_PACKAGE_NAME "CircusTent")
set(CPACK_PACKAGE_RELEASE 1)
set(CPACK_PACKAGE_CONTACT "John Leidel")
set(CPACK_PACKAGE_VENDOR "Tactical Computing Laboratories, LLC")
set(CPACK_RPM_PACKAGE_REQUIRES "devtoolset-7-gcc-c++")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}")
include(CPack)
endif()
#-- builds a standard debian/ubuntu deb
if(CIRCUSTENT_BUILD_DEB)
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_NAME "CircusTent")
set(CPACK_PACKAGE_RELEASE 1)
set(CPACK_PACKAGE_CONTACT "John Leidel")
set(CPACK_PACKAGE_VENDOR "Tactical Computing Laboratories, LLC")
#-- setup package deps
if( "${CT_RELEASE_CODENAME}" STREQUAL "bionic" )
message(STATUS "Setting package dependencies for Ubuntu 18.04 (bionic)")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "")
elseif( "${CT_RELEASE_CODENAME}" STREQUAL "xenial" )
message(STATUS "Setting package dependencies for Ubuntu 16.04 (xenial)")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "")
else()
message(STATUS "Unknown debian version: ${CT_RELEASE_CODENAME}")
message(STATUS "No debian package dependencies are set!!!")
endif()
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}")
include(CPack)
endif()
#-- builds a tgz
if(CIRCUSTENT_BUILD_TGZ)
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_GENERATOR "TGZ")
set(CPACK_PACKAGE_NAME "CircusTent")
set(CPACK_PACKAGE_RELEASE 1)
set(CPACK_PACKAGE_CONTACT "John Leidel")
set(CPACK_PACKAGE_VENDOR "Tactical Computing Laboratories, LLC")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}")
include(CPack)
endif()
#-- builds an osx dmg
if(CIRCUSTENT_BUILD_DMG)
set(CPACK_PACKAGE_VERSION ${VERSION})
set(CPACK_GENERATOR "DMG")
set(CPACK_PACKAGE_NAME "CircusTent")
set(CPACK_PACKAGE_RELEASE 1)
set(CPACK_PACKAGE_CONTACT "John Leidel")
set(CPACK_PACKAGE_VENDOR "Tactical Computing Laboratories, LLC")
set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}")
include(CPack)
endif()
#------------------------------------------------------------------------
#-- SUBDIRECTORIES
#------------------------------------------------------------------------
# Add subdirectories
add_subdirectory(src)
add_subdirectory(include)
add_subdirectory(test)
# EOF