-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
286 lines (246 loc) · 10.9 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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# Copyright (c) 2017-2024 King Abdullah University of Science and Technology,
# All rights reserved.
# ExaGeoStat is a software package, provided by King Abdullah University of Science and Technology (KAUST).
# @file CMakeLists.txt
# @brief This is a CMakeLists.txt file for a C++ project ExaGeoStat.
# The project is a parallel high performance unified framework for geographical statistics on manycore systems.
# The file sets up variables and finds dependencies required for the project.
# It also provides options to enable building tests, building examples, building documentation, and enabling a packaging system for distribution.
# @version 1.1.0
# @author Mahmoud ElKarargy
# @author Sameh Abdulah
# @date 2024-02-04
# Set the minimum CMake version required to 3.20
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)
cmake_policy(SET CMP0048 NEW)
# Set project options
option(USE_CUDA "Use Cuda, if available" false)
option(USE_MPI "Use MPI, if available" false)
option(BUILD_TESTS "Option to enable building tests" OFF)
option(BUILD_HEAVY_TESTS "Option to enable building heavy tests, This may take a lot of time" OFF)
option(BUILD_EXAMPLES "Option to enable building examples" ON)
option(BUILD_DOCS "Build documentation in docs directory" ON)
option(USE_R "Enable the use of R and Rcpp in the project" OFF)
option(CREATE_PACKAGE "Enable a packaging system for distribution" OFF)
# Cmake Module Paths
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
if (${BUILD_SHARED_LIBS})
set(BLA_STATIC OFF)
else ()
set(BLA_STATIC ON)
endif ()
# Select toolchain based on whether CUDA is enabled or not
if (USE_CUDA)
message("")
message("---------------------------------------- CUDA")
# Enable CUDA and include CudaToolchain
add_definitions(-DUSE_CUDA=TRUE)
enable_language(CUDA)
include(toolchains/CudaToolchain)
# Set BLA_VENDOR to NVHPC for CUDA-enabled builds
set(BLA_VENDOR NVHPC)
list(APPEND STARPU_COMPONENT_LIST "CUDA")
else ()
message("-- Build x86 Support")
# Include GccToolchain for non-CUDA builds - Gcc
include(toolchains/GccToolchain)
endif ()
# Project Name and Version
project(ExaGeoStatCPP VERSION 1.0.0 DESCRIPTION "ExaGeoStatCPP is a parallel high performance unified framework for geostatistics on manycore systems.")
# Show the current version of CMake.
message(STATUS "CMAKE VERSION: ${CMAKE_VERSION}")
# Enable C++ language
enable_language(CXX)
# Get the current path of the project.
add_compile_definitions(PROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}/")
# Set kernels path.
add_definitions(-DKERNELS_PATH="${PROJECT_SOURCE_DIR}/inst/include/kernels/concrete/")
# ExaGeoStatCPP depends on CUDA
# -------------------------------
if (USE_CUDA)
message("-- Build CUDA Support")
else ()
message("-- Build x86 Support")
set(gpu_backend CACHE STRING "none" FORCE)
unset(BLA_VENDOR)
endif ()
# ExaGeoStatCPP depends on MPI
# -------------------------------
if (USE_MPI)
message("")
message("---------------------------------------- MPI")
# Enable MPI and include MPI
add_definitions(-DUSE_MPI=TRUE)
message(STATUS "Trying to find MPI")
find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})
list(APPEND LIBS ${MPI_LIBRARIES})
list(APPEND STARPU_COMPONENT_LIST "MPI")
endif ()
# ExaGeoStatCPP depends on LAPACKE
#-----------------------------
message("")
message("---------------------------------------- LAPACKE")
find_package(LAPACKE)
list(APPEND LIBS ${LAPACKE_LIBRARIES})
link_directories(${LAPACKE_LIBRARY_DIRS_DEP})
include_directories(${LAPACKE_INCLUDE_DIRS})
# Add all dependencies for ExaGeoStatCPP
#-----------------------------
# Print installation path of ExaGeoStatCPP.
message(STATUS "Installation path : ${CMAKE_INSTALL_PREFIX}")
# ExaGeoStatCPP depends on HWLoc
# -------------------------------
include(ImportHwloc)
list(APPEND STARPU_COMPONENT_LIST "HWLOC")
string(REPLACE ";" " " STARPU_COMPONENT_STRING "${STARPU_COMPONENT_LIST}")
# ExaGeoStatCPP depends on StarPU runtime
# -------------------------------
include(ImportStarPu)
# ExaGeoStatCPP depends on GSL
# -------------------------------
include(ImportGSL)
# ExaGeoStatCPP depends on NLOPT
# -------------------------------
include(ImportNLOPT)
# ExaGeoStatCPP depends on HiCMA
# -------------------------------
if (USE_HICMA)
add_definitions(-DUSE_HICMA=TRUE)
include(ImportHCore)
include(ImportStarsH)
include(ImportHiCMA)
endif ()
# ExaGeoStatCPP depends on Chameleon
# -------------------------------
include(ImportChameleon)
# ExaGeoStatCPP depends on LAPACK/BLASPP
# -------------------------------
include(ImportBLASPP)
include(ImportLapack)
# ExaGeoStatCPP Documentation
if (BUILD_DOCS)
find_package(Doxygen)
if (DOXYGEN_FOUND)
add_subdirectory("docs")
else ()
message(STATUS "Doxygen NOT found, skipping it")
endif ()
endif ()
# Include directories for ExaGeoStatCPP
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inst/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/prerequisites)
set(MY_LOGGER_PATH ${CMAKE_CURRENT_SOURCE_DIR})
add_definitions(-DMY_LOGGER_PATH="${CMAKE_CURRENT_SOURCE_DIR}")
if (USE_R)
message("")
message("---------------------------------------- Rcpp")
# Find R and Rcpp using FindR Module
find_package(R REQUIRED)
if (${R_FOUND})
message(STATUS "Using R technology")
list(APPEND LIBS R)
add_definitions(-DUSING_R)
endif ()
endif ()
# Add src Directory to expose added libraries
add_subdirectory(src)
# Creates a new INTERFACE library target named ${PROJECT_NAME}_INTERFACE.
# The INTERFACE keyword specifies that this library will not be built, but instead will only be used for its properties.
add_library(${PROJECT_NAME}_INTERFACE INTERFACE)
target_link_libraries(${PROJECT_NAME}_INTERFACE INTERFACE ${PROJECT_NAME})
# Add linker options to the target
target_link_options(${PROJECT_NAME}_INTERFACE INTERFACE "SHELL:-Wl,--whole-archive $<TARGET_FILE:${PROJECT_NAME}> -Wl,--no-whole-archive")
# Add tests if enabled
if (${BUILD_TESTS})
message(STATUS "Building Tests")
include(ImportCatch2)
include(Catch)
include(CTest)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests/cpp-tests)
enable_testing()
endif ()
# Add heavy tests if enabled
if (${BUILD_HEAVY_TESTS})
message(STATUS "Building Heavy Tests")
include(ImportCatch2)
include(Catch)
include(CTest)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests/heavy-tests)
enable_testing()
message(STATUS "Building heavy tests will enable examples too")
set(BUILD_EXAMPLES ON)
endif ()
# Add examples if enabled
if (BUILD_EXAMPLES)
message(STATUS "Building Examples is Enabled")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/examples)
endif ()
# ExaGeoStatCPP Dependence export messages for users
# -------------------------------
message(" \n \t ** Configurations of ExaGeoStatCPP and installation of dependence is done successfully ** ")
message("\t - Export the following line to avoid re-install dependencies each time. -")
message("\t ----------------------------------------------------------------------------------------------------------------------------------- ")
message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/CHAMELEON/lib/pkgconfig:$PKG_CONFIG_PATH")
message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/STARPU/lib/pkgconfig:$PKG_CONFIG_PATH")
message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/HWLOC/lib/pkgconfig:$PKG_CONFIG_PATH")
message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/GSL/lib/pkgconfig:$PKG_CONFIG_PATH")
message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/NLOPT/lib/pkgconfig:${CMAKE_INSTALL_PREFIX}/NLOPT/lib64/pkgconfig:$PKG_CONFIG_PATH")
if(USE_HICMA)
message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/STARSH/lib/pkgconfig:$PKG_CONFIG_PATH")
message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/HCORE/lib/pkgconfig:$PKG_CONFIG_PATH")
message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/HICMA/lib/pkgconfig:$PKG_CONFIG_PATH")
endif()
message("\t ----------------------------------------------------------------------------------------------------------------------------------- \n")
# Installation of ExaGeoStatCPP
install(DIRECTORY inst/include/ DESTINATION ${CMAKE_INSTALL_PREFIX}/EXAGEOSTATCPP/include)
## Install cmake find package.
include(CMakePackageConfigHelpers)
write_basic_package_version_file("${CMAKE_INSTALL_PREFIX}/EXAGEOSTATCPP/${PROJECT_NAME}ConfigVersion.cmake" COMPATIBILITY ExactVersion)
install(
FILES
"${CMAKE_INSTALL_PREFIX}/EXAGEOSTATCPP/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_PREFIX}/EXAGEOSTATCPP/lib/cmake/${PROJECT_NAME}
)
configure_file(${PROJECT_NAME}Config.cmake.in
${CMAKE_INSTALL_PREFIX}/EXAGEOSTATCPP/${PROJECT_NAME}Config.cmake @ONLY)
install(
FILES
"${CMAKE_INSTALL_PREFIX}/EXAGEOSTATCPP/${PROJECT_NAME}Config.cmake"
DESTINATION ${CMAKE_INSTALL_PREFIX}/EXAGEOSTATCPP/lib/cmake/${PROJECT_NAME}
)
install(
DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
DESTINATION ${CMAKE_INSTALL_PREFIX}/EXAGEOSTATCPP/Modules
)
## Generate pkg-config file
configure_file(package.pc.in
${CMAKE_INSTALL_PREFIX}/EXAGEOSTATCPP/lib/pkgconfig/${PROJECT_NAME}.pc @ONLY)
install(
FILES
"${CMAKE_INSTALL_PREFIX}/EXAGEOSTATCPP/lib/pkgconfig/${PROJECT_NAME}.pc"
DESTINATION ${CMAKE_INSTALL_PREFIX}/EXAGEOSTATCPP/lib/pkgconfig/
)
if (CREATE_PACKAGE)
##################
# Release source #
##################
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "ExaGeoStatCPP is a parallel high performance unified framework for geostatistics on manycore systems. Its abbreviation stands for 'Exascale Geostatistics'.")
set(CPACK_PACKAGE_VERSION "${${PROJECT_NAME}_VERSION}")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
set(CPACK_PACKAGE_VENDOR "KAUST")
set(CPACK_PACKAGE_CONTACT "sameh.abdulah@kaust.edu.sa")
set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE)
set(CPACK_SOURCE_IGNORE_FILES "bin;.git;Jenkinsfile")
include(CPack)
message("\t - Export the following line if you want to use ExaGeoStatCPP in another software. -")
message("\t ----------------------------------------------------------------------------------------------------------------------------------------------------- ")
message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/EXAGEOSTATCPP/lib/pkgconfig:$PKG_CONFIG_PATH")
message("\t ----------------------------------------------------------------------------------------------------------------------------------------------------- ")
endif ()