forked from dwcaress/MB-System
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
369 lines (345 loc) · 13 KB
/
Copy pathCMakeLists.txt
File metadata and controls
369 lines (345 loc) · 13 KB
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
#------------------------------------------------------------------------------
# The MB-system: CMakeLists.txt 16 June 2025
#
# Copyright (c) 2023-2025 by
# David W. Caress (caress@mbari.org)
# Monterey Bay Aquarium Research Institute
# Moss Landing, California, USA
# Dale N. Chayes
# Center for Coastal and Ocean Mapping
# University of New Hampshire
# Durham, New Hampshire, USA
# Christian dos Santos Ferreira
# MARUM
# University of Bremen
# Bremen Germany
#
# MB-System was created by Caress and Chayes in 1992 at the
# Lamont-Doherty Earth Observatory
# Columbia University
# Palisades, NY 10964
#
# See README.md file for copying and redistribution conditions.
#------------------------------------------------------------------------------
#
# To build MB-System from source using CMake do (example):
#
# mkdir build
# cd build
# cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
#
# CMAKE_BUILD_TYPE can be: empty, Debug, Release, RelWithDebInfo or MinSizeRel
#
#------------------------------------------------------------------------------
#
# Two optional documentation targets are not part of the default build (the
# "all" target) and must be built explicitly. Both require Homebrew (or
# equivalent) installs of pandoc and weasyprint; htmldocs additionally
# requires groff and perl. If any required tool is missing, CMake prints a
# status message at configure time and the target is simply unavailable.
#
# brew install pandoc weasyprint groff
#
# - changelog: regenerates the top-level ChangeLog.html and ChangeLog.pdf
# from ChangeLog.md (via pandoc + weasyprint), replacing the previously
# manual MacDown export workflow.
#
# cmake --build . --target changelog
#
# - htmldocs: regenerates src/html/*.html and src/html/*.pdf from the man
# pages in src/man/ plus ChangeLog.md/COPYING.md/GPL.md (via man2html,
# groff, and pandoc + weasyprint), replacing the previously manual
# make_mbhtml workflow.
#
# cmake --build . --target htmldocs
#
#------------------------------------------------------------------------------
message("----------------------------------------------------------")
message("MB-System")
message("CMake Build System")
message("David Caress (Monterey Bay Aquarium Research Institute)")
message("Johannes Schauer (University of Weurzburg)")
message("Tom O'Reilly (Monterey Bay Aquarium Research Institute)")
message("----------------------------------------------------------")
message("CMake version: ${CMAKE_VERSION}")
message("Set install directory using -DCMAKE_INSTALL_PREFIX=directory (default is /usr/local)")
message("The default build mode is release (optimized for performance, not debuggable).")
message("Enable debugging with -DCMAKE_BUILD_TYPE=Debug")
message("Build shared/static libraries with -DBUILD_SHARED_LIBS=ON/OFF")
message("Disable building graphical utilities with -DbuildGUIs=OFF")
message("Disable building TRN software with -DbuildTRN=OFF")
message("Disable building photomosaicing software with -DbuildOpenCV=OFF")
message("Disable supporting GSF format data with -DbuildGSF=OFF")
message("Build Qt-based GUIs with -DbuildQt=ON")
message("Build deprecated programs with -DbuildDeprecated=ON")
message("Disable unit tests with -DbuildTests=OFF (run unit tests with make test)")
message("Specify OTPS install location with -DotpsDir=directory")
message("Print out all CMake variables with -Dverbose=1")
message("----------------------------------------------------------")
# Define minimum CMake version required
cmake_minimum_required(VERSION 3.16)
# Export compile commands for IDE tools
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Define project
project(MB-System
DESCRIPTION "Open Source software for the processing and display of seafloor mapping data"
HOMEPAGE_URL https://www.mbari.org/technology/mb-system/
LANGUAGES C CXX )
# Disallow in-source builds
get_filename_component (srcdir "${CMAKE_SOURCE_DIR}" REALPATH)
get_filename_component (bindir "${CMAKE_BINARY_DIR}" REALPATH)
if (${srcdir} STREQUAL ${bindir})
message(FATAL_ERROR "In-source builds are not allowed. "
"Please create a directory and run cmake from there, passing the path "
"to this source directory as the last argument. This process created "
"the file `CMakeCache.txt' and the directory `CMakeFiles' in ${srcdir}. "
"Please remove them.")
endif (${srcdir} STREQUAL ${bindir})
add_compile_definitions(CMAKE_BUILD_SYSTEM=1)
if (CMAKE_C_BYTE_ORDER STREQUAL "LITTLE_ENDIAN")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DBYTESWAPPED")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBYTESWAPPED")
endif()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/build-utils")
option(BUILD_SHARED_LIBS "Build and link with shared libraries" ON)
option(buildGSF "build GSF library" ON)
option(buildGUIs "build graphical tools" ON)
option(buildOpenCV "build OpenCV tools" ON)
option(buildTRN "build MBTRN tools" ON)
option(buildTRNLCM "build MBTRN LCM tools" OFF)
option(buildTrnNoRand "build with TRN_NORAND (random seed disabled)" OFF)
option(buildPCL "build point-cloud-library tools" OFF)
option(buildQt "build Qt tools" OFF)
option(buildTests "build unit tests exercised by make test" ON)
if (DEFINED CACHE{otpsDir})
set(otpsDir $CACHE{otpsDir})
else()
set(otpsDir "/usr/local/src/otps")
endif()
if(APPLE)
execute_process(
COMMAND sw_vers -productVersion
OUTPUT_VARIABLE MACOS_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET
)
find_program(MACOS_HAVE_HOMEBREW NAMES brew)
find_program(MACOS_HAVE_MACPORTS NAMES port)
if(${MACOS_VERSION} VERSION_LESS "16")
if (MACOS_HAVE_MACPORTS)
set(MACOS_USE_MACPORTS TRUE)
set(MACOS_USE_HOMEBREW FALSE)
elseif (MACOS_HAVE_HOMEBREW)
set(MACOS_USE_MACPORTS FALSE)
set(MACOS_USE_HOMEBREW TRUE)
else()
set(MACOS_USE_MACPORTS FALSE)
set(MACOS_USE_HOMEBREW FALSE)
endif()
message("MacOS 15 Sequoia or prior detected")
else()
if (MACOS_HAVE_HOMEBREW)
set(MACOS_USE_MACPORTS FALSE)
set(MACOS_USE_HOMEBREW TRUE)
elseif (MACOS_HAVE_MACPORTS)
set(MACOS_USE_MACPORTS TRUE)
set(MACOS_USE_HOMEBREW FALSE)
else()
set(MACOS_USE_MACPORTS FALSE)
set(MACOS_USE_HOMEBREW FALSE)
endif()
message("MacOS 26 Tahoe or later detected")
endif()
if(MACOS_HAVE_HOMEBREW)
message("MacOS: package manager Homebrew is installed")
endif()
if(MACOS_HAVE_MACPORTS)
message("MacOS: package manager MacPorts is installed")
endif()
if(MACOS_USE_HOMEBREW)
message("MacOS: using packages installed with Homebrew")
endif()
if(MACOS_USE_MACPORTS)
message("MacOS: using packages installed with MacPorts")
endif()
message("----------------------------------------------------------")
endif()
set(CMAKE_INSTALL_SHARE share)
set(CMAKE_INSTALL_MANPAGES share/man)
set(CMAKE_INSTALL_DOC share/doc)
set(levitusDir "share/mbsystem")
include(GNUInstallDirs)
include(CTest)
# uninstall target
if(NOT TARGET uninstall)
add_custom_target(uninstall COMMAND xargs rm -vf < install_manifest.txt)
endif()
# set RPATH
if (NOT CMAKE_INSTALL_RPATH)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
endif()
if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
endif()
# Libraries
if(buildGSF)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DENABLE_GSF")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_GSF")
add_subdirectory(src/gsf)
endif()
add_subdirectory(src/mbaux)
add_subdirectory(src/mbbitpack)
add_subdirectory(src/mbio)
add_subdirectory(src/bsio)
add_subdirectory(src/surf)
# GMT modules
add_subdirectory(src/gmt)
# Executables
add_subdirectory(src/utilities)
add_subdirectory(src/macros)
add_subdirectory(src/mbgrd2gltf)
add_subdirectory(src/mbmesh)
add_subdirectory(src/otps)
# src/mbnavadjust always builds the mbnavadjust_core library and the
# Motif/X11-free mbnavadjustmerge CLI; the mbnavadjust GUI (and
# mbnavadjustfine) are gated internally by that directory's own
# CMakeLists.txt via buildGUIs.
add_subdirectory(src/mbnavadjust)
if(buildGUIs)
add_subdirectory(src/mbview)
add_subdirectory(src/mbedit)
add_subdirectory(src/mbgrdviz)
add_subdirectory(src/mbeditviz)
add_subdirectory(src/mbnavedit)
add_subdirectory(src/mbvelocitytool)
endif()
if(buildOpenCV)
add_subdirectory(src/photo)
endif()
if(buildTRN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTRN_USE_PROJ")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTRN_USE_PROJ")
add_subdirectory(src/mbtrnframe)
add_subdirectory(src/mbtrn)
add_subdirectory(src/mbtrnav)
add_subdirectory(src/mbtrnutils)
if(buildTRNLCM)
add_subdirectory(src/mbtrnav/opt/rov)
endif()
endif()
if(buildQt)
set(MIN_VTK_VERSION "9.3")
add_subdirectory(src/qt-guilib)
add_subdirectory(src/qt-mbgrdviz)
add_subdirectory(src/qt-mbgrdviz-3)
add_subdirectory(src/qt-mbedit)
add_subdirectory(src/qt-mbedit-widgets)
add_subdirectory(src/pointCloudEditor)
endif()
if(buildDeprecated)
add_subdirectory(src/deprecated)
endif()
if(buildTests)
add_subdirectory(third_party)
add_subdirectory(test/mbio)
add_subdirectory(test/utilities)
if(buildDeprecated)
add_subdirectory(test/deprecated)
endif()
endif()
add_subdirectory(src/man)
add_subdirectory(src/html)
add_subdirectory(src/share)
# src/htmlsrc provides the optional "htmldocs" target that regenerates the
# man page HTML/PDF documentation installed from src/html; it depends on the
# mbformat target built above in src/utilities.
add_subdirectory(src/htmlsrc)
# Optional target to regenerate ChangeLog.html and ChangeLog.pdf from
# ChangeLog.md, replacing the previously-manual MacDown export workflow.
# Not part of the default build - run explicitly via:
# cmake --build . --target changelog
find_program(PANDOC_EXECUTABLE pandoc)
find_program(WEASYPRINT_EXECUTABLE weasyprint)
if(PANDOC_EXECUTABLE AND WEASYPRINT_EXECUTABLE)
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/ChangeLog.html
COMMAND ${PANDOC_EXECUTABLE} ${CMAKE_SOURCE_DIR}/ChangeLog.md
-f gfm -t html5 --standalone
--metadata title=ChangeLog
--css=${CMAKE_SOURCE_DIR}/src/htmlsrc/ChangeLog_style.css
--embed-resources
-o ${CMAKE_SOURCE_DIR}/ChangeLog.html
DEPENDS ${CMAKE_SOURCE_DIR}/ChangeLog.md ${CMAKE_SOURCE_DIR}/src/htmlsrc/ChangeLog_style.css
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating ChangeLog.html from ChangeLog.md via pandoc"
VERBATIM)
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/ChangeLog.pdf
COMMAND ${WEASYPRINT_EXECUTABLE} ${CMAKE_SOURCE_DIR}/ChangeLog.html ${CMAKE_SOURCE_DIR}/ChangeLog.pdf
DEPENDS ${CMAKE_SOURCE_DIR}/ChangeLog.html
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating ChangeLog.pdf from ChangeLog.html via weasyprint"
VERBATIM)
add_custom_target(changelog
DEPENDS ${CMAKE_SOURCE_DIR}/ChangeLog.html ${CMAKE_SOURCE_DIR}/ChangeLog.pdf)
else()
message(STATUS "pandoc and/or weasyprint not found - 'changelog' build target "
"unavailable (install via: brew install pandoc weasyprint)")
endif()
message("----------------------------------------------------------")
message("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}")
message("CMAKE_C_COMPILER_ID: ${CMAKE_C_COMPILER_ID}")
if(APPLE)
message("MacOS Version: ${MACOS_VERSION}")
if(${MACOS_VERSION} VERSION_LESS "16")
message("MacOS Sequoia or earlier")
else()
message("MacOS Tahoe or later")
endif()
if(MACOS_USE_HOMEBREW)
message("MacOS: Homebrew used")
else()
message("MacOS: Homebrew not used")
endif()
if(MACOS_USE_MACPORTS)
message("MacOS: MacPorts used")
else()
message("MacOS: MacPorts not used")
endif()
endif()
message("CMAKE_SOURCE_DIR: ${CMAKE_SOURCE_DIR}")
message("CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
message("CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}")
message("CMAKE_INSTALL_FULL_LIBDIR: ${CMAKE_INSTALL_FULL_LIBDIR}")
message("CMAKE_INSTALL_FULL_INCLUDEDIR: ${CMAKE_INSTALL_FULL_INCLUDEDIR}")
message("CMAKE_INSTALL_FULL_BINDIR: ${CMAKE_INSTALL_FULL_BINDIR}")
message("CMAKE_INSTALL_FULL_DOCDIR: ${CMAKE_INSTALL_FULL_DOCDIR}")
message("CMAKE_INSTALL_FULL_DATADIR: ${CMAKE_INSTALL_FULL_DATADIR}")
message("CMAKE_INSTALL_FULL_DATAROOTDIR: ${CMAKE_INSTALL_FULL_DATAROOTDIR}")
message("CMAKE_SYSTEM_PREFIX_PATH: ${CMAKE_SYSTEM_PREFIX_PATH}")
message("CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES: ${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}")
message("CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES: ${CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES}")
message("BYTESWAPPED: ${BYTESWAPPED}")
message("CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
message("CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
message("CMAKE_INSTALL_RPATH: ${CMAKE_INSTALL_RPATH}")
if(APPLE)
message("CMAKE_MACOSX_RPATH: ${CMAKE_MACOSX_RPATH}")
endif()
message(OTPS directory: ${otpsDir})
# For debugging: print all set variables
message("----------------------------------------------------------")
if (verbose)
message("All CMake variables:")
message(" ")
get_cmake_property(_variableNames VARIABLES)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
message("----------------------------------------------------------")
endif()