-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
466 lines (447 loc) · 17.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
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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
cmake_minimum_required(VERSION 3.5.0)
project(bezitopo)
# Copyright 2012-2022,2024 Pierre Abbat.
# Copyright 2020 звездочёт.
# This file is part of Bezitopo.
#
# Bezitopo 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.
#
# Bezitopo 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 General Public License and Lesser General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# and Lesser General Public License along with Bezitopo. If not, see
# <http://www.gnu.org/licenses/>.
include(TestBigEndian)
include(CheckTypeSize)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS ON)
set(SHARE_DIR ${CMAKE_INSTALL_PREFIX}/share/bezitopo)
option (FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." FALSE)
if (${FORCE_COLORED_OUTPUT})
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options (-fdiagnostics-color=always)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options (-fcolor-diagnostics)
endif ()
endif ()
set(FUZZ none)
#Setting FUZZ to boldatni disables reading all geoid formats except boldatni
#in convertgeoid and disables the boldatni magic string check.
# To build with Address Sanitizer: cmake -DSANITIZE=ON <...>
# The build products are slower and bigger, but run faster than using Valgrind.
# See: https://clang.llvm.org/docs/AddressSanitizer.html
#
option(SANITIZE "Enable AddressSanitizer" OFF)
if (SANITIZE)
message(STATUS "AddressSanitizer enabled")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fsanitize=address")
endif()
# To enable rigorous compilation settings: cmake -DRIGOROUS=ON <...>
# This converts all warnings to errors and raises the compiler warning levels.
# Some useful warnings are disabled pending review of stylistic choices
#
option(RIGOROUS "Enable rigorous compilation settings" OFF)
if (RIGOROUS)
message(STATUS "Rigorous compilation settings enabled")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -pedantic")
set(DISABLED_WARNINGS
-Wno-sign-compare
-Wno-unused-parameter
-Wno-unused-variable
-Wno-unused-but-set-variable
-Wno-overloaded-virtual
-Wno-parentheses
-Wno-empty-body
-Wno-implicit-fallthrough
-Wno-maybe-uninitialized # a bad one to disable!
-Wno-unused-result # also not good to turn off
)
foreach(WARNING ${DISABLED_WARNINGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING}")
endforeach()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX")
# TBD: MSVC warning disablements to get RIGOROUS working
endif ()
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
find_package(Qt5 COMPONENTS Core Widgets Gui LinguistTools REQUIRED)
find_package(FFTW)
qt5_add_resources(lib_resources src/viewtin.qrc)
qt5_add_translation(qm_files src/bezitopo_en.ts
src/bezitopo_es.ts)
# To update translations, run "lupdate *.cpp -ts *.ts" in the source directory.
set(header_files src/angle.h
src/arc.h
src/bezier.h
src/bezier3d.h
src/binio.h
src/boundrect.h
src/breakline.h
src/circle.h
src/cogo.h
src/cogospiral.h
src/color.h
src/contour.h
src/csv.h
src/curvefit.h
src/document.h
src/drawobj.h
src/ellipsoid.h
src/except.h
src/geoid.h
src/geoidboundary.h
src/globals.h
src/halton.h
src/intloop.h
src/latlong.h
src/layer.h
src/ldecimal.h
src/leastsquares.h
src/linetype.h
src/manyarc.h
src/manysum.h
src/matrix.h
src/measure.h
src/minquad.h
src/objlist.h
src/penwidth.h
src/pnezd.h
src/point.h
src/pointlist.h
src/polyline.h
src/projection.h
src/ps.h
src/qindex.h
src/quaternion.h
src/random.h
src/relprime.h
src/rootfind.h
src/roscat.h
src/segment.h
src/spiral.h
src/spolygon.h
src/tin.h
src/vball.h
src/vcurve.h
src/xml.h
src/xyz.h
src/zoom.h)
# MS Visual C++ cannot build both static and shared libraries with the same name.
# If you ask for a static library, it makes bezitopo.lib. If you ask for a
# shared library, it makes bezitopo.dll, which is the shared library, and
# bezitopo.lib, the import library for the DLL.
# This is not a problem for MinGW, which makes three files: libbezitopo.a,
# the static library; libbezitopo.dll, the shared library; and libbezitopo.dll.a,
# the import library for the DLL.
set(MAKE_STATIC bezilib0)
set(MAKE_SHARED bezilib1)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" AND DEFINED MSVC_STATIC)
set(MAKE_SHARED "")
endif ()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" AND NOT DEFINED MSVC_STATIC)
set(MAKE_STATIC "")
endif ()
set(sourcelib src/angle.cpp
src/arc.cpp
src/bezier.cpp
src/bezier3d.cpp
src/binio.cpp
src/boundrect.cpp
src/breakline.cpp
src/circle.cpp
src/cogo.cpp
src/cogospiral.cpp
src/color.cpp
src/contour.cpp
src/csv.cpp
src/curvefit.cpp
src/document.cpp
src/drawobj.cpp
src/ellipsoid.cpp
src/except.cpp
src/geoid.cpp
src/geoidboundary.cpp
src/halton.cpp
src/intloop.cpp
src/latlong.cpp
src/layer.cpp
src/ldecimal.cpp
src/leastsquares.cpp
src/manyarc.cpp
src/manysum.cpp
src/matrix.cpp
src/measure.cpp
src/minquad.cpp
src/objlist.cpp
src/penwidth.cpp
src/pnezd.cpp
src/point.cpp
src/pointlist.cpp
src/polyline.cpp
src/projection.cpp
src/ps.cpp
src/qindex.cpp
src/quaternion.cpp
src/random.cpp
src/relprime.cpp
src/rootfind.cpp
src/segment.cpp
src/smooth5.cpp
src/spiral.cpp
src/spolygon.cpp
src/stl.cpp
src/tin.cpp
src/vball.cpp
src/vcurve.cpp
src/xml.cpp)
if (MAKE_STATIC)
add_library(bezilib0 STATIC ${sourcelib})
endif ()
if (MAKE_SHARED)
add_library(bezilib1 SHARED ${sourcelib})
endif ()
add_executable(bezitopo ${sourcelib}
src/absorient.cpp
src/bezitopo.cpp
src/closure.cpp
src/cvtmeas.cpp
src/firstarg.cpp
src/icommon.cpp
src/kml.cpp
src/mkpoint.cpp
src/plot.cpp
src/raster.cpp
src/scalefactor.cpp
src/test.cpp)
add_executable(bezitest ${sourcelib}
src/absorient.cpp
src/bezitest.cpp
src/bicubic.cpp
src/carlsontin.cpp
src/crosssection.cpp
src/dxf.cpp
src/firstarg.cpp
src/histogram.cpp
src/hlattice.cpp
src/hnum.cpp
src/kml.cpp
src/plot.cpp
src/ptin.cpp
src/raster.cpp
src/rawdata.cpp
src/readtin.cpp
src/refinegeoid.cpp
src/sourcegeoid.cpp
src/test.cpp
src/textfile.cpp
src/tintext.cpp
src/zoom.cpp)
add_executable(clotilde ${sourcelib}
src/clotilde.cpp
src/cmdopt.cpp)
add_executable(convertgeoid ${sourcelib}
src/bicubic.cpp
src/cmdopt.cpp
src/convertgeoid.cpp
src/histogram.cpp
src/hlattice.cpp
src/kml.cpp
src/raster.cpp
src/refinegeoid.cpp
src/sourcegeoid.cpp)
add_executable(viewtin ${sourcelib}
src/carlsontin.cpp
src/cidialog.cpp
src/dxf.cpp
src/factordialog.cpp
src/fileio.cpp
src/firstarg.cpp
src/kml.cpp
src/linetype.cpp
src/llvalidator.cpp
src/measurebutton.cpp
src/plwidget.cpp
src/ptin.cpp
src/readtin.cpp
src/rendercache.cpp
src/test.cpp
src/textfile.cpp
src/tintext.cpp
src/tinwindow.cpp
src/topocanvas.cpp
src/viewtin.cpp
src/zoom.cpp
src/zoombutton.cpp
${lib_resources}
${qm_files})
add_executable(sitecheck ${sourcelib}
src/carlsontin.cpp
src/cidialog.cpp
src/dxf.cpp
src/factordialog.cpp
src/firstarg.cpp
src/kml.cpp
src/linetype.cpp
src/llvalidator.cpp
src/measurebutton.cpp
src/plwidget.cpp
src/ptin.cpp
src/readtin.cpp
src/rendercache.cpp
src/sitecheck.cpp
src/sitewindow.cpp
src/test.cpp
src/textfile.cpp
src/tintext.cpp
src/topocanvas.cpp
src/zoom.cpp
src/zoombutton.cpp
${lib_resources}
${qm_files})
add_executable(pangeoid src/geoidwindow.cpp src/pangeoid.cpp src/zoom.cpp)
if (${FFTW_FOUND})
add_executable(transmer ${sourcelib}
src/transmer.cpp)
endif (${FFTW_FOUND})
if (MAKE_STATIC)
target_link_libraries(bezilib0 Qt5::Widgets Qt5::Core)
target_compile_definitions(bezilib0 PUBLIC _USE_MATH_DEFINES)
endif ()
if (MAKE_SHARED)
target_link_libraries(bezilib1 Qt5::Widgets Qt5::Core)
target_compile_definitions(bezilib1 PUBLIC _USE_MATH_DEFINES)
endif ()
target_link_libraries(bezitopo Qt5::Widgets Qt5::Core)
target_compile_definitions(bezitopo PUBLIC _USE_MATH_DEFINES)
target_link_libraries(bezitest Qt5::Widgets Qt5::Core)
target_compile_definitions(bezitest PUBLIC _USE_MATH_DEFINES)
target_link_libraries(clotilde Qt5::Widgets Qt5::Core)
target_compile_definitions(clotilde PUBLIC _USE_MATH_DEFINES)
target_link_libraries(convertgeoid Qt5::Widgets Qt5::Core)
target_compile_definitions(convertgeoid PUBLIC _USE_MATH_DEFINES)
target_link_libraries(viewtin Qt5::Widgets Qt5::Core)
target_compile_definitions(viewtin PUBLIC _USE_MATH_DEFINES)
set_target_properties(viewtin PROPERTIES WIN32_EXECUTABLE TRUE)
target_link_libraries(sitecheck Qt5::Widgets Qt5::Core)
target_compile_definitions(sitecheck PUBLIC _USE_MATH_DEFINES)
set_target_properties(sitecheck PROPERTIES WIN32_EXECUTABLE TRUE)
target_link_libraries(pangeoid Qt5::Widgets Qt5::Core)
target_compile_definitions(pangeoid PUBLIC _USE_MATH_DEFINES)
if (${FFTW_FOUND})
target_link_libraries(transmer Qt5::Widgets Qt5::Core ${FFTW_LIBRARIES})
target_compile_definitions(transmer PUBLIC _USE_MATH_DEFINES POINTLIST)
endif (${FFTW_FOUND})
# POINTLIST: the program uses pointlists. Affects BoundRect.
# CONVERTGEOID: the program reads source geoid files. Allows raster output of source geoids.
# NUMSGEOID: the geoquad class needs to count points that are in and out of source geoids.
# FLATTRIANGLE: the program handles only flat triangles.
if (MAKE_STATIC)
target_compile_definitions(bezilib0 PUBLIC POINTLIST)
endif ()
if (MAKE_SHARED)
target_compile_definitions(bezilib1 PUBLIC POINTLIST)
endif ()
target_compile_definitions(convertgeoid PUBLIC CONVERTGEOID NUMSGEOID POINTLIST)
target_compile_definitions(bezitest PUBLIC NUMSGEOID POINTLIST)
target_compile_definitions(bezitopo PUBLIC POINTLIST)
target_compile_definitions(clotilde PUBLIC POINTLIST)
target_compile_definitions(viewtin PUBLIC POINTLIST)
target_compile_definitions(sitecheck PUBLIC POINTLIST FLATTRIANGLE)
#target_compile_definitions(pangeoid PUBLIC CONVERTGEOID NUMSGEOID)
include(CheckIncludeFiles)
check_include_files(time.h HAVE_TIME_H)
check_include_files(sys/time.h HAVE_SYS_TIME_H)
check_include_files(sys/resource.h HAVE_SYS_RESOURCE_H)
check_include_files(windows.h HAVE_WINDOWS_H)
# Define NO_INSTALL when compiling for fuzzing. This avoids the error
# "The install of the perfecttin target requires changing an RPATH", which
# occurs when using the AFL compiler wrapper with the Ninja generator.
# There is no need to install a binary built for fuzzing.
if (NOT DEFINED NO_INSTALL)
install(TARGETS bezitopo convertgeoid viewtin clotilde DESTINATION bin)
install(TARGETS ${MAKE_SHARED} ${MAKE_STATIC} DESTINATION lib)
install(FILES ${PROJECT_BINARY_DIR}/config.h DESTINATION include/bezitopo)
install(FILES ${qm_files} dat/projections.txt dat/transmer.dat DESTINATION share/bezitopo)
install(FILES ${header_files} DESTINATION include/bezitopo)
install(FILES src/bezitopo.h DESTINATION include)
endif ()
if (WIN32)
include(windeployqt)
windeployqt(sitecheck bin)
endif (WIN32)
test_big_endian(BIGENDIAN)
check_type_size("int" INT)
check_type_size("int *" INT_POINTER)
set(BEZITOPO_MAJOR_VERSION 0)
set(BEZITOPO_MINOR_VERSION 1)
set(BEZITOPO_PATCH_VERSION 6)
set(BEZITOPO_VERSION ${BEZITOPO_MAJOR_VERSION}.${BEZITOPO_MINOR_VERSION}.${BEZITOPO_PATCH_VERSION})
set(COPY_YEAR 2024)
if (MAKE_STATIC)
set_target_properties(bezilib0 PROPERTIES OUTPUT_NAME "bezitopo" VERSION ${BEZITOPO_VERSION})
endif ()
if (MAKE_SHARED)
set_target_properties(bezilib1 PROPERTIES OUTPUT_NAME "bezitopo" VERSION ${BEZITOPO_VERSION})
endif ()
include_directories(${PROJECT_BINARY_DIR})
if (${FFTW_FOUND})
include_directories(${FFTW_INCLUDES})
endif (${FFTW_FOUND})
configure_file (config.h.in config.h)
configure_file (dat/tinytin-txt.dxf tinytin-txt.dxf COPYONLY)
configure_file (dat/tinytin-bin.dxf tinytin-bin.dxf COPYONLY)
configure_file (dat/transmer.dat transmer.dat COPYONLY)
set(CPACK_PACKAGE_VERSION_MAJOR ${BEZITOPO_MAJOR_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR ${BEZITOPO_MINOR_VERSION})
set(CPACK_PACKAGE_VERSION_PATCH ${BEZITOPO_PATCH_VERSION})
set(CPACK_SOURCE_IGNORE_FILES /\\\\.git;.*~)
include(CPack)
include(CTest)
add_test(geom bezitest area3 in intersection invalidintersectionlozenge invalidintersectionaster circle)
add_test(arith bezitest relprime manysum brent newton zoom)
add_test(measure bezitest measure)
add_test(calculus bezitest parabinter derivs)
add_test(random bezitest random)
add_test(matrix bezitest matrix)
add_test(quaternion bezitest quaternion)
add_test(drawobj bezitest property objlist)
add_test(bezier bezitest triangle vcurve trianglecontours grad)
add_test(pointlist bezitest copytopopoints intloop tripolygon)
add_test(maketin bezitest maketin123 maketindouble maketinaster maketinbigaster maketinstraightrow maketinlongandthin maketinlozenge maketinring maketinwheel maketinellipse)
add_test(angle bezitest integertrig angleconv)
add_test(leastsquares bezitest leastsquares)
add_test(minquad bezitest minquad)
add_test(segment bezitest segment)
add_test(arc bezitest arc)
add_test(spiral bezitest spiral spiralarc cogospiral curly manyarc)
add_test(curvefit bezitest curvefit)
add_test(qindex bezitest qindex)
add_test(makegrad bezitest makegrad)
add_test(raster bezitest rasterdraw)
add_test(dirbound bezitest dirbound)
add_test(stl bezitest stl)
add_test(dxf bezitest tindxf)
add_test(halton bezitest halton)
add_test(polyline bezitest polyline alignment)
add_test(bezier3d bezitest bezier3d)
add_test(fileio bezitest csvline pnezd ldecimal)
add_test(geodesy bezitest ellipsoid projection vball geoid geint)
add_test(convertgeoid0 bezitest hlattice bicubic smooth5 quadhash)
add_test(convertgeoid1 bezitest smallcircle cylinterval geoidboundary gpolyline kml)
add_test(layer bezitest layer color)
add_test(contour bezitest contour foldcontour zigzagcontour tracingstop)
add_test(roscat bezitest roscat absorient)
add_test(histogram bezitest histogram)