-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathCMakeLists.txt
executable file
·336 lines (293 loc) · 12.5 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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# ===================================================== #
# #
# # ## # # # # #
# # # # # # # # # # #
# ##### # # # # ##### ## ### # # ## ### ### #
# # # # # # # # # # # # # # # # # # # # #
# # # # # # # # # # # # # # # # # # # # #
# # # ## # ## # # ### ### ### ## ### # # #
# # # # #
# ## # # #
# #
# ===================================================== #
# #
# Authors: #
# - Jose Luis Cercos-Pita #
# - Leo Miguel Gonzalez #
# - Antonio Souto-Iglesias #
# #
# ===================================================== #
# ===================================================== #
# General CMake options #
# ===================================================== #
cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message("ERROR: In-source builds are not allowed")
message("=======================================")
message("")
message("cmake cannot be executed in the same folder were AQUAgpusph has")
message("been downloaded")
message("See https://gitlab.com/sanguinariojoe/aquagpusph/-/wikis/install#compiling")
message("")
message("To fix this issue, you can remove CMakeCache.txt, create a")
message("subfolder, and execute CMake from there.")
message("")
message("For instance, if you originally executed the following command:")
message("")
message("cmake -DCMAKE_BUILD_TYPE=Release .")
message("")
message("You can fix the problem typing")
message("rm CMakeCache.txt")
message("mkdir -p build && cd build")
message("cmake -DCMAKE_BUILD_TYPE=Release ..")
message("")
message("Note that the single period at the end of the CMake command has")
message("been replace by two periods (pointing to the parent folder)")
message("")
message(FATAL_ERROR "In-source builds are not allowed. Please, run cmake in a different folder.")
endif("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
project(AQUAgpusph)
set(AQUAGPUSPH_VERSION "4.1.2")
set(PACKAGE_NAME "AQUAgpusph")
set(PACKAGE_VERSION_MAJOR "4")
set(PACKAGE_VERSION_MINOR "1")
set(PACKAGE_VERSION_PATCH "2")
set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
# include local modules
include(AddFileDependencies)
# Setup CTest to build tests
include(CTest)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cMake")
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
# No Debug/Release output paths
set(DEBUG_MAIN_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
set(RELEASE_MAIN_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
if(WIN32)
set(PLATFORM_CP xcopy /Y /S)
set(PLATFORM_MK mkdir)
else(WIN32)
set(PLATFORM_CP cp)
set(PLATFORM_MK mkdir -p)
endif(WIN32)
# ===================================================== #
# Output directories for install target #
# ===================================================== #
if(WIN32)
SET(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "Installation root directory")
else(WIN32)
SET(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Installation root directory")
SET(INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif(WIN32)
SET(CMAKE_INSTALL_DATADIR share/aquagpusph CACHE PATH "Output directory for data and resource files")
SET(CMAKE_INSTALL_INCLUDEDIR include/AQUAgpusph CACHE PATH "Output directory for header files")
SET(CMAKE_INSTALL_DOCDIR share/doc/aquagpusph CACHE PATH "Output directory for documentation and license files")
SET(CMAKE_INSTALL_BINDIR bin CACHE PATH "Output directory for binary files")
SET(CMAKE_INSTALL_LIBDIR lib CACHE PATH "Output directory for library files")
# used as compiler defines
SET(RESOURCEDIR "${CMAKE_INSTALL_DATADIR}")
SET(DOCDIR "${CMAKE_INSTALL_DOCDIR}")
MESSAGE(STATUS "prefix: ${CMAKE_INSTALL_PREFIX}")
MESSAGE(STATUS "datadir: ${CMAKE_INSTALL_DATADIR}")
MESSAGE(STATUS "docdir: ${CMAKE_INSTALL_DOCDIR}")
MESSAGE(STATUS "bindir: ${CMAKE_INSTALL_BINDIR}")
MESSAGE(STATUS "libdir: ${CMAKE_INSTALL_LIBDIR}")
# ===================================================== #
# All the options for the build process #
# ===================================================== #
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "Release")
ENDIF(NOT CMAKE_BUILD_TYPE)
OPTION(AQUAGPUSPH_3D "Build 3D AQUAgpusph version. 2D and 3D versions can be installed on the same system." ON)
OPTION(AQUAGPUSPH_USE_MPI "Build AQUAgpusph with MPI support, for multidevice running." ON)
OPTION(AQUAGPUSPH_USE_VTK "Build AQUAgpusph with VTK output format support (on development)." ON)
OPTION(AQUAGPUSPH_BUILD_TOOLS "Build AQUAgpusph tools" ON)
OPTION(AQUAGPUSPH_BUILD_EXAMPLES "Build AQUAgpusph examples" ON)
OPTION(AQUAGPUSPH_USE_NCURSES "Build AQUAgpusph with Ncurses terminal support." OFF)
OPTION(AQUAGPUSPH_BUILD_DOC "Build AQUAgpusph documentation" OFF)
OPTION(AQUAGPUSPH_GPU_PROFILE "Profile the GPU during the runtime (consuming additional resources)" OFF)
MARK_AS_ADVANCED(
AQUAGPUSPH_GPU_PROFILE
)
# ===================================================== #
# Search the packages #
# ===================================================== #
# 2D/3D
IF(AQUAGPUSPH_3D)
ADD_DEFINITIONS(-DHAVE_3D)
ELSE(AQUAGPUSPH_3D)
ADD_DEFINITIONS(-DHAVE_2D)
ENDIF(AQUAGPUSPH_3D)
# xxd
FIND_PACKAGE(XXD REQUIRED)
IF(NOT XXD_FOUND)
MESSAGE(FATAL_ERROR "xxd not found, but ${PACKAGE_NAME} requires it. Please install vim!")
ENDIF(NOT XXD_FOUND)
# MPI
IF(AQUAGPUSPH_USE_MPI)
FIND_PACKAGE(MPI)
IF(NOT MPI_MPICXX_FOUND)
MESSAGE(FATAL_ERROR "MPI not found, but AQUAGPUSPH_USE_MPI is ON. Install MPI or set AQUAGPUSPH_USE_MPI=OFF")
ENDIF(NOT MPI_MPICXX_FOUND)
SET(HAVE_MPI TRUE)
ENDIF(AQUAGPUSPH_USE_MPI)
# Python
FIND_PACKAGE(Python REQUIRED COMPONENTS
Interpreter
Development
NumPy)
IF(NOT Python_FOUND)
MESSAGE(FATAL_ERROR "Python not found, but ${PACKAGE_NAME} requires it. Please install Python!")
ENDIF(NOT Python_FOUND)
# Xerces-C
FIND_PACKAGE(XercesC REQUIRED)
IF(NOT XercesC_FOUND)
MESSAGE(FATAL_ERROR "Xerces-C not found, but ${PACKAGE_NAME} requires it. Please install Xerces-C!")
ENDIF(NOT XercesC_FOUND)
# OpenCL
FIND_PACKAGE(OpenCL REQUIRED)
IF(NOT OpenCL_FOUND)
MESSAGE(FATAL_ERROR "OpenCL not found, but ${PACKAGE_NAME} requires it. Please install OpenCL!")
ENDIF(NOT OpenCL_FOUND)
IF(OpenCL_VERSION_MAJOR LESS 2)
MESSAGE(FATAL_ERROR "OpenCL ${OpenCL_VERSION_MAJOR}.${OpenCL_VERSION_MINOR} found, but OpenCL >= 2.0 is required.")
ENDIF(OpenCL_VERSION_MAJOR LESS 2)
# CLang
FIND_PACKAGE(CLang REQUIRED)
IF(NOT CLANG_FOUND)
MESSAGE(FATAL_ERROR "libCLang not found, but ${PACKAGE_NAME} requires it. Please install libCLang!")
ENDIF(NOT CLANG_FOUND)
# NCURSES
IF(AQUAGPUSPH_USE_NCURSES)
SET(CURSES_NEED_NCURSES TRUE)
FIND_PACKAGE(Curses)
IF(NOT CURSES_FOUND)
MESSAGE(FATAL_ERROR "Curses not found, but AQUAGPUSPH_USE_NCURSES is ON. Install Curses or set AQUAGPUSPH_USE_NCURSES=OFF")
ENDIF(NOT CURSES_FOUND)
SET(HAVE_NCURSES TRUE)
ENDIF(AQUAGPUSPH_USE_NCURSES)
# VTK
IF(AQUAGPUSPH_USE_VTK)
FIND_PACKAGE(VTK REQUIRED COMPONENTS
CommonCore
IOXML)
IF(NOT VTK_FOUND)
MESSAGE(FATAL_ERROR "VTK not found, but AQUAGPUSPH_USE_VTK is ON. Install VTK or set AQUAGPUSPH_USE_VTK=OFF")
ENDIF(NOT VTK_FOUND)
IF (VTK_VERSION VERSION_LESS "8.90.0")
MESSAGE(FATAL_ERROR "VTK >= 8.9 is required if AQUAGPUSPH_USE_VTK is ON. Update VTK or set AQUAGPUSPH_USE_VTK=OFF")
ENDIF (VTK_VERSION VERSION_LESS "8.90.0")
MESSAGE(STATUS "Found VTK ${VTK_VERSION}")
SET(HAVE_VTK TRUE)
ENDIF(AQUAGPUSPH_USE_VTK)
# muparser
FIND_PACKAGE(MuParser REQUIRED)
IF(NOT MUPARSER_FOUND)
MESSAGE(FATAL_ERROR "MuParser not found, but ${PACKAGE_NAME} requires it. Please install MuParser!")
ENDIF(NOT MUPARSER_FOUND)
# GPU profile
IF(AQUAGPUSPH_GPU_PROFILE)
ADD_DEFINITIONS(-DHAVE_GPUPROFILE)
ENDIF(AQUAGPUSPH_GPU_PROFILE)
# Tests building
IF(BUILD_TESTING)
FIND_PROGRAM(BASH_PROGRAM bash)
IF(NOT BASH_PROGRAM)
MESSAGE(FATAL_ERROR "Bash not found, but BUILD_TESTING has been set. Install Bash or set BUILD_TESTING=OFF")
ENDIF(NOT BASH_PROGRAM)
MARK_AS_ADVANCED(BASH_PROGRAM)
ENDIF()
# ===================================================== #
# Search special packages needed to build doc #
# ===================================================== #
IF(AQUAGPUSPH_BUILD_DOC)
FIND_PACKAGE(Doxygen)
IF(NOT DOXYGEN_FOUND)
MESSAGE(FATAL_ERROR "Doxygen not found, but AQUAGPUSPH_BUILD_DOC is ON. Install Doxygen or set AQUAGPUSPH_BUILD_DOC=OFF")
ENDIF(NOT DOXYGEN_FOUND)
IF(NOT DOXYGEN_DOT_FOUND)
MESSAGE(FATAL_ERROR "Graphviz not found, but AQUAGPUSPH_BUILD_DOC is ON. Install Graphviz or set AQUAGPUSPH_BUILD_DOC=OFF")
ENDIF(NOT DOXYGEN_DOT_FOUND)
ENDIF(AQUAGPUSPH_BUILD_DOC)
# ===================================================== #
# config.h stuff #
# ===================================================== #
include(cMake/ConfigureChecks.cmake)
IF(CMAKE_COMPILER_IS_GNUCXX)
CONFIGURE_FILE(config.h.gcc.cmake ${CMAKE_BINARY_DIR}/config.h)
ELSEIF (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
CONFIGURE_FILE(config.h.clang.cmake ${CMAKE_BINARY_DIR}/config.h)
ENDIF()
add_definitions(-DHAVE_CONFIG_H)
add_definitions(-Wno-write-strings)
add_definitions(-Wno-deprecated)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
# ===================================================== #
# Global Compiler and Linker Settings #
# ===================================================== #
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/include ${CMAKE_SOURCE_DIR}/include)
# check for 64-bit platform
IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
MESSAGE(STATUS "Platform is 64-bit")
ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8)
MESSAGE(STATUS "Platform is 32-bit")
ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
SET (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DAQUA_DEBUG")
MESSAGE(STATUS "DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}")
# ===================================================== #
# Compilation parts #
# ===================================================== #
ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(resources)
IF(AQUAGPUSPH_BUILD_TOOLS)
ADD_SUBDIRECTORY(tools)
ENDIF(AQUAGPUSPH_BUILD_TOOLS)
IF(AQUAGPUSPH_BUILD_EXAMPLES)
ADD_SUBDIRECTORY(examples)
ENDIF(AQUAGPUSPH_BUILD_EXAMPLES)
IF(AQUAGPUSPH_BUILD_DOC)
ADD_SUBDIRECTORY(doc)
ENDIF(AQUAGPUSPH_BUILD_DOC)
IF(BUILD_TESTING)
ADD_SUBDIRECTORY(tests)
ENDIF()
# ===================================================== #
# Show a brief #
# ===================================================== #
MESSAGE("=====================================================")
IF(AQUAGPUSPH_3D)
MESSAGE("Target: AQUAgpusph")
ELSE(AQUAGPUSPH_3D)
MESSAGE("Target: AQUAgpusph2D")
ENDIF(AQUAGPUSPH_3D)
MESSAGE("Binary destination: ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
MESSAGE("Libraries destination: ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
MESSAGE("Resources destination: ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/resources")
IF(AQUAGPUSPH_BUILD_EXAMPLES)
MESSAGE("Examples destination: ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/examples")
ENDIF(AQUAGPUSPH_BUILD_EXAMPLES)
IF(AQUAGPUSPH_BUILD_DOC)
MESSAGE("Documentation destination: ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DOCDIR}")
ENDIF(AQUAGPUSPH_BUILD_DOC)
MESSAGE("OPTIONS:")
IF(AQUAGPUSPH_USE_MPI)
MESSAGE(" - With MPI")
ELSE(AQUAGPUSPH_USE_MPI)
MESSAGE(" - Without MPI")
ENDIF(AQUAGPUSPH_USE_MPI)
IF(AQUAGPUSPH_USE_NCURSES)
MESSAGE(" - With NCurses")
ELSE(AQUAGPUSPH_USE_NCURSES)
MESSAGE(" - Without NCurses")
ENDIF(AQUAGPUSPH_USE_NCURSES)
IF(AQUAGPUSPH_USE_VTK)
MESSAGE(" - With VTK")
ELSE(AQUAGPUSPH_USE_VTK)
MESSAGE(" - Without VTK")
ENDIF(AQUAGPUSPH_USE_VTK)
MESSAGE("=====================================================")