forked from MmgTools/mmg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
342 lines (283 loc) · 11.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
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
337
338
339
340
341
342
## =============================================================================
## This file is part of the mmg software package for the tetrahedral
## mesh modification.
## Copyright (c) Bx INP/Inria/UBordeaux/UPMC, 2004- .
##
## mmg is free software: you can redistribute it and/or modify it
## under the terms of the GNU Lesser General Public License as published
## by the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## mmg is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
## License for more details.
##
## You should have received a copy of the GNU Lesser General Public
## License and of the GNU General Public License along with mmg (in
## files COPYING.LESSER and COPYING). If not, see
## <http://www.gnu.org/licenses/>. Please read their terms carefully and
## use this copy of the mmg distribution only if you accept them.
## =============================================================================
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
# if PROJECT_NAME is defined, mmg is a subproject
if(DEFINED PROJECT_NAME)
set(MMG_SUBPROJECT ON)
endif()
INCLUDE(CMakeDependentOption)
PROJECT (mmg)
LIST(APPEND CMAKE_MODULE_PATH
${PROJECT_SOURCE_DIR}/cmake/modules
${PROJECT_SOURCE_DIR}/cmake/testing )
INCLUDE(macros)
# Executable path
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
SET(MMGCOMMON_SOURCE_DIR ${PROJECT_SOURCE_DIR}/src/common)
SET(MMGCOMMON_BINARY_DIR ${PROJECT_BINARY_DIR}/src/common)
FILE(MAKE_DIRECTORY ${MMGCOMMON_BINARY_DIR})
# Path toward the continuous integration directory
SET ( CI_DIR ${PROJECT_SOURCE_DIR}/ci_tests
CACHE PATH "Path toward the continuous integration directory" )
MARK_AS_ADVANCED ( CI_DIR )
include(CMakePackageConfigHelpers)
# various variables to help standard install directories
include(GNUInstallDirs)
###############################################################################
#####
##### Release version and date
#####
###############################################################################
SET (CMAKE_RELEASE_VERSION_MAJOR "5" )
SET (CMAKE_RELEASE_VERSION_MINOR "7" )
SET (CMAKE_RELEASE_VERSION_PATCH "0" )
SET (CMAKE_RELEASE_DATE "Dec. 13, 2022" )
SET (CMAKE_RELEASE_VERSION
"${CMAKE_RELEASE_VERSION_MAJOR}.${CMAKE_RELEASE_VERSION_MINOR}.${CMAKE_RELEASE_VERSION_PATCH}")
###############################################################################
#####
##### Set preprocessor flags and manage automatically generated headers data
#####
###############################################################################
# Architecture detection
IF (NOT WIN32)
# Set preprocessor flags to say that we are posix and gnu compatible
SET (DEF_POSIX "#define MMG_POSIX")
SET (DEF_GNU "#define MMG_GNU")
ELSEIF(MINGW)
SET (DEF_GNU "#define MMG_GNU")
ENDIF ()
############################################################################
#####
##### Integer type
#####
############################################################################
# type of integer
SET (MMG5_INT "int32_t" CACHE STRING "Integer type")
IF (${MMG5_INT} STREQUAL "int64_t")
SET ( DEF_MMG5_INT "#define MMG5_int int64_t")
SET ( DEF_MMG5_PRId "#define MMG5_PRId PRId64")
SET ( DEF_MMG5F_INT "#define MMG5F_INT SELECTED_INT_KIND(18)")
SET ( DEF_MMG_SWPBIN "#define MMG5_SWAPBIN(x) MMG5_swapbin_int(x)")
SET ( DEF_MMG_ABS "#define MMG5_abs(x) (int64_t)labs((int64_t)x)")
ELSE ()
SET ( DEF_MMG5_INT "#define MMG5_int int32_t")
SET ( DEF_MMG5_PRId "#define MMG5_PRId PRId32")
SET ( DEF_MMG5F_INT "#define MMG5F_INT SELECTED_INT_KIND(9)")
SET ( DEF_MMG_SWPBIN "#define MMG5_SWAPBIN(x) MMG5_swapbin(x)")
SET ( DEF_MMG_ABS "#define MMG5_abs(x) abs(x)")
ENDIF ()
# Create mmgcmakedefines.h file with the architecture infos and the definition
# ot the USE_POINTMAP flag. Create also mmgcmakedefinesf.h file for automatic
# definition of integer size for Fortran API
###############################################################################
SET(MMG_DYN_LIB ${BUILD_SHARED_LIBS} CACHE INTERNAL "" FORCE)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/common/mmgcmakedefines.h.in
${PROJECT_BINARY_DIR}/src/common/mmgcmakedefines.h @ONLY)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/common/mmgcmakedefinesf.h.in
${PROJECT_BINARY_DIR}/src/common/mmgcmakedefinesf.h @ONLY)
# Create mmgversion.h file with the release infos
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/common/mmgversion.h.in
${PROJECT_BINARY_DIR}/src/common/mmgversion.h @ONLY)
# Print git hash to source file
IF (NOT WIN32 OR MINGW)
ADD_CUSTOM_TARGET(GenerateGitHashMmg
COMMAND ./git_log_mmg.sh ${PROJECT_SOURCE_DIR} ${MMGCOMMON_BINARY_DIR}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/scripts/
COMMENT "Getting git commit hash"
BYPRODUCTS ${MMGCOMMON_BINARY_DIR}/git_log_mmg.h
)
ENDIF ()
###############################################################################
#####
##### CMake flags / variables
#####
###############################################################################
# Hide some options
MARK_AS_ADVANCED(CMAKE_OSX_ARCHITECTURES
CMAKE_OSX_DEPLOYMENT_TARGET
CMAKE_OSX_SYSROOT)
include(add_build_types)
# List CMake build types
IF(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
MESSAGE(STATUS "Setting build type to 'Release' as none was specified.")
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
SET_PROPERTY(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo" "Maintainer" "RelWithAssert")
ELSEIF( CMAKE_CONFIGURATION_TYPES )
LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer RelWithAssert )
ENDIF()
# Explicitly set the DNDEBUG flag in case the user or a parent project overrides
# it.
if (NOT CMAKE_BUILD_TYPE MATCHES Debug AND NOT CMAKE_BUILD_TYPE MATCHES RelWithAssert)
add_definitions(-DNDEBUG)
endif()
# Do not print warnings about the use of secure function with MSVC and the use
# of POSIX strdup
if ( MSVC )
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-Dstrdup=_strdup)
endif()
###############################################################################
#####
##### Choose executable target to compile
#####
###############################################################################
SET ( BUILD "MMG" CACHE STRING
"\"MMG3D\", \"MMGS\",\"MMG2D\", or \"MMG\" to compile both MMGS, MMG3D and MMG2D" )
IF ( BUILD MATCHES "MMGS" )
SET(BUILD_MMG OFF )
SET(BUILD_MMG3D OFF )
SET(BUILD_MMGS ON )
SET(BUILD_MMG2D OFF )
ELSEIF ( BUILD MATCHES "MMG3D" )
SET(BUILD_MMG3D ON )
SET(BUILD_MMGS OFF )
SET(BUILD_MMG OFF )
SET(BUILD_MMG2D OFF )
ELSEIF ( BUILD MATCHES "MMG2D" )
SET(BUILD_MMG OFF )
SET(BUILD_MMG3D OFF )
SET(BUILD_MMGS OFF )
SET(BUILD_MMG2D ON )
ELSEIF ( BUILD MATCHES "MMG" )
SET(BUILD_MMG ON )
SET(BUILD_MMGS ON )
SET(BUILD_MMG3D ON )
SET(BUILD_MMG2D ON )
ELSE ( )
MESSAGE ( ERROR " Nothing to build.\n"
"Please choose the target to build (set the BUILD CMake's"
" variable to \"MMG\", \"MMG2D\", \"MMGS\" OR"
" \"MMG3D\")" )
ENDIF()
IF ( BUILD_MMG3D OR BUILD_MMGS )
SET(BUILD_MMGS3D ON)
ELSE ()
SET(BUILD_MMGS3D OFF)
ENDIF()
FIND_PACKAGE(Perl)
IF (NOT PERL_FOUND)
message(WARNING "Perl not found -> we do not generate Fortran Headers")
ENDIF(NOT PERL_FOUND)
############################################################################
#####
##### Fortran header: libmmgtypesf.h
#####
############################################################################
ADD_EXECUTABLE(genheader ${PROJECT_SOURCE_DIR}/scripts/genheader.c)
TARGET_LINK_LIBRARIES ( genheader PRIVATE ${LIBRARIES} )
IF (PERL_FOUND)
GENERATE_FORTRAN_HEADER ( mmg
${MMGCOMMON_SOURCE_DIR} libmmgtypes.h
${MMGCOMMON_BINARY_DIR}
${MMGCOMMON_BINARY_DIR} libmmgtypesf.h
)
ENDIF (PERL_FOUND)
###############################################################################
#####
##### libraries
#####
###############################################################################
# Libraries
IF ( NOT (WIN32 OR MINGW) )
IF(NOT DEFINED M_LIB)
MESSAGE(STATUS "M_LIB not defined. Searching it")
FIND_LIBRARY(M_LIB m)
ENDIF(NOT DEFINED M_LIB)
MARK_AS_ADVANCED(FORCE M_LIB)
SET( LIBRARIES ${M_LIB} ${LIBRARIES})
ENDIF()
############################################################################
#####
##### Point map
#####
############################################################################
# add point map?
OPTION ( USE_POINTMAP "Use map for point tracking" OFF )
############################################################################
#####
##### Search for optional libraries: scotch, vtk, linearelasticity
#####
############################################################################
INCLUDE(optional-dependencies)
############################################################################
#####
##### RPATH for MacOSX
#####
############################################################################
SET(CMAKE_MACOSX_RPATH 1)
###############################################################################
#####
##### Add Mmg options
#####
###############################################################################
INCLUDE(add-mmg-options)
###############################################################################
#####
##### Build Targets and libmmg if needed
#####
###############################################################################
INCLUDE(build-targets)
###############################################################################
#####
##### Continuous integration
#####
###############################################################################
CMAKE_DEPENDENT_OPTION (
ONLY_VERY_SHORT_TESTS "Enable/Disable very short tests" OFF
"BUILD_TESTING;NOT LONG_TESTS" OFF )
MARK_AS_ADVANCED(ONLY_VERY_SHORT_TESTS)
CMAKE_DEPENDENT_OPTION (
LONG_TESTS "Enable/Disable time consuming tests for the project" OFF
"BUILD_TESTING" OFF )
MARK_AS_ADVANCED(LONG_TESTS)
IF( BUILD_TESTING )
IF ( NOT ONLY_VERY_SHORT_TESTS )
# Get the continuous integration tests
INCLUDE(LoadCiTests)
ENDIF ( )
# Set the continuous integration options
SET ( MMG_CI_TESTS ${CI_DIR}/mmg )
# Copy config file and custom file in the good directories
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/cmake/config/CTestCustom.cmake
./CTestCustom.cmake)
ENABLE_TESTING()
INCLUDE(CTest)
IF ( ( MMG3D_CI OR MMGS_CI ) AND NOT ONLY_VERY_SHORT_TESTS )
# Add common tests for mmgs/3d appli
INCLUDE( mmg_tests )
ENDIF ( )
ENDIF ( BUILD_TESTING )
###############################################################################
#####
##### Create API Documentation
#####
###############################################################################
include(doxygen)
###############################################################################
#####
##### Create Package
#####
###############################################################################
include(packages)